sublime text3格式化json
第一步:安裝install package
點擊菜單中的 “View”–“Show Console”(也可通過快捷鍵 Ctrl + ` 打開,不過可能因與系統其他軟件快捷鍵衝突而打不開)調出 Console。然後把下面的代碼粘貼進去後回車即可,需稍微等待一段時間。(以下代碼可能會因更新而導致失效,請以官網(https://packagecontrol.io/installation#st2)代碼爲準。)
sublime3
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
sublime2
import urllib2,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')
在輸入命令之後,記得重啓sublime。
第二步:安裝 pretty json
使用 Command(或ctrl) + Shift + P 調出面板,然後輸入 pci ,選中“Package Control: Install Package”並回車,然後通過輸入插件的名字pretty json找到插件並回車安裝即可。
第三步:使用command + ctrl + j快捷鍵來格式化當前頁面的內容。