Fei

调教 Sublime Text 3

2014-05-25

下文基于 64 位 Windows 7 SP1 系统,不保证其它平台通用。

下载与安装

  1. 下载 Sublimte Text 3
  2. 安装,勾上 Add to explorer context menu

安装 Package Control

  1. 同时按下 Ctrl + `
  2. 输入
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; 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://sublime.wbond.net/' + 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)

安装 Soada 主题

  1. 同时按下 Ctrl + Shift + p,输入 Install Package,回车
  2. 输入 theme soda,回车
  3. 菜单栏选择 Preferences -> Settings - User
  4. 加入 "theme": "Soda Dark.sublime-theme"
  5. 重启 Sublime Text 3

安装代码配色

  1. 下载 colour-schemes.zip
  2. 菜单栏选择 Preferences -> Browse Packages...
  3. 解压下载文件到 user 目录
  4. 菜单栏选择 Preferences -> Color Scheme -> User -> Monokai Soda 启用配色

安装 ConvertToUTF8

  1. 同时按下 Ctrl + Shift + p,输入 `Install Package’,回车
  2. 输入 `ConvertToUTF8’,回车

更改用户配置

"font_size": 11,
"tab_size": 2,
"trim_trailing_white_space_on_save": true,
"translate_tabs_to_spaces": true

关联 Powershell

最终实现命令行中输入 sub test.txt 自动打开 Sublime Text 3 编辑该文件。

  1. 以管理员方式运行 Powershell,输入 Set-ExecutionPolicy RemoteSigned 用以获得脚本执行权限
  2. 输入 Test-Path $profile 检查配置文件是否存在
  3. 若返回 False,输入 ni -path $profile -type file -force 创建配置文件
  4. 输入 notepad $profile 编辑该配置文件,加入 Set-Alias sub "C:\Program Files\Sublime Text 3\sublime_text.exe"
  5. 保存该文件,重启 Poweshell