Sublime

Package Control

The simplest method of installation is through the Sublime Text console. The console is accessed via the ctrl+` shortcut or the View > Show Console menu. Once open, paste the appropriate Python code for your version of Sublime Text into the console.

  • SUBLIME TEXT 3

    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)

    This code creates the Installed Packages folder for you (if necessary), and then downloads the Package Control.sublime-package into it.

Syncing

To properly sync your installed packages across different machines, you actually do not want to sync the whole Packages/ and Installed Packages/ folders. The reason for this is that some packages have different versions for different operating systems. By syncing the actual package contents across operating systems, you will possibly run into broken packages.

The proper solution is to install Package Control on all machines and then to sync only the Packages/User/ folder. This folder contains the Package Control.sublime-settings file, which includes a list of all installed packages. If this file is copied to another machine, the next time Sublime Text is started, Package Control will install the correct version of any missing packages.

Using Dropbox

Dropbox is popular choice for syncing settings. It has the benefit of automatically syncing files and not having to worry about privacy. In order to use this properly, symlinks must be set up via the command line. The following instructions should provide some guidance.

Windows

These instructions work for Windows Vista and newer, but unfortunately do not work for Windows XP. If your Dropbox folder is not in the default location, you’ll need to change $env:userprofile\Dropbox to your location.
1. Close Sublime Text
2. Open PowerShell(cmd) by right-clicking and selecting Run as administrator

First Machine

On your first machine, use the following instructions.
- SUBLIME TEXT 3

cd "$env:appdata\Sublime Text 3\Packages\"
mkdir $env:userprofile\Dropbox\Sublime
mv User $env:userprofile\Dropbox\Sublime\
cmd /c mklink /D User $env:userprofile\Dropbox\Sublime\User

概括起來就是:在Dropbox目錄中創建文件夾Sublime,然後將Packages目錄中的User文件夾複製到剛纔創建的Sublime文件夾中,最後在Packages目錄下以管理員權限打開控制檯,執行cmd /c mklink /D User $env:userprofile\Dropbox\Sublime\User

如何進入Packages目錄:
這裏寫圖片描述

Other Machine(s)

On your other machine(s), use the following instructions. These instructions will remove your User/ folder and all contents!
- SUBLIME TEXT 3

cd "$env:appdata\Sublime Text 3\Packages\"
rmdir -recurse User
cmd /c mklink /D User $env:userprofile\Dropbox\Sublime\User

進入Packages目錄,刪除目錄下的User文件夾,然後在Packages目錄下以管理員權限打開控制檯,執行cmd /c mklink /D User $env:userprofile\Dropbox\Sublime\User

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章