Sublime Text 3安装Package Control

时间:2021-08-04 17:43:15

打开Sublime Text 3,按快捷键ctrl+`或者View > Show Console调出控制台,然后将以下代码粘贴到控制台上:

Sublime Text 3

import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; 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) 

Sublime Text 2

import urllib2,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; 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') 

上面的代码会自动为你创建Installed Packages文件夹,然后会下载 Control.sublime-package包到里面。

手动安装

如果不能自动安装,可以使用下面的方法来手动安装Package Control:
  1. 点击Preferences > Browse Packages…菜单
  2. 浏览文件夹,进入Installed Packages/目录
  3. 下载Package Control.sublime-package并将它拷贝到Installed Packages/目录
  4. 重启Sublime Text
官网地址: https://packagecontrol.io/installation#st2