Sublime text 2 is a very good source code and text editor, but does not support gb2312 and GBK encoding in many cases will be very troublesome. However, the sublime package control plug-in allows sublime text 2 to support CJK-encoded text almost perfectly.
Installing sublime package control is very simple. use Ctrl + ~ On sublime text 2 ~ Open the console and enter the following code in, or enter the official code (https://sublime.wbond.net/installation ). Sublime text 2 will automatically install package control.
1 import urllib2,os,hashlib; h = ‘7183a2d3e96f11eeadd761d777e62404‘ + ‘e330c659d4bb41d3bdf022e94cab3cd0‘; 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://sublime.wbond.net/‘ + 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‘)
If this method cannot be correctly installed, you can also directly install it by copying files. If sublime text 2 is installed in a Chinese path or the % username % in the system path contains Chinese characters, you may need to install it manually.
- Open the preferences menu and select Browse packages...
- The system will open the packages folder of sublime text 2, return to the upper menu, and then open the installed packages folder.
- Download and copy the downloaded package control. sublime-package to the installed packages folder (note that this is the installed packages, not the packages folder)
- Restart sublime text 2
Run Ctrl + Shift + P to open the command line mode, and enter install package to search for the required package. Generally, "converttoutf8" and "GBK encoding support" are used to read and write files in CJK format.
Similarly, if sublime text 2 is installed in a Chinese path or the % username % in the system path contains Chinese characters, you may need to manually install these packages, and copy them to the package directory.