最近使用Subline Text 的场景越来越多,尤其是在网络比较差的时候,需要格式化一个很大的Json,就想到一个简单的记事本Subline Text3,安装一个JSON格式化工具,就解决问题,所以网上找一些资料,下面分享一些安装经验:
1. 安装插件前先找到Package Control:Install Package,使用快捷键Win/Linux: ctrl+shift+p, Mac: cmd+shift+p,如果没有找到,通过ctrl +`快捷方式或View> Show>Console菜单访问控制台
Sublime Text 3粘贴如下代码:
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; 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/](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)
Sublime Text 2粘贴如下代码:
import urllib2,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; 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/](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’)
运行报错需要运行代理全局模式,可以用手动下载安装包的方法完成安装,详细看官网:https://packagecontrol.io/installation#st2
Click the Preferences > Browse Packages… menu
Browse up a folder and then into the Installed Packages/ folder
Download Package Control.sublime-package and copy it into the Installed Packages/ directory
Restart Sublime Text