恢复到初始状态

概述

Sublime Text可以通过删除data文件夹的方式恢复到初始状态。不同操作系统这个文件夹的位置也不同:

  • OS X:~/Library/Application Support/Sublime Text 3
  • Windows:%APPDATA%\Sublime Text 3
  • Linux:~/.config/sublime-text-3

恢复到初始状态,你需要:

  1. 退出Sublime Text
  2. 删除上面列出的data文件夹
  3. 重启Sublime Text

重启时,一个新的data文件夹会被创建,就像是第一次启动Sublime Text一样。需要注意的是这也会删掉你所有的设置和包。

OS X Lion

在Lion中,~/Library文件夹默认是隐藏的。要导航到那个地方,需要从菜单栏的Go/Go to Folder操作,输入~/Library

Windows

Windows中,缓存文件是存放在独立的位置的,%LOCALAPPDATA%\Sublime Text 3,这是为了提高性能。

OS X命令行

概述

Sublime Text包含了一个命令行工具,subl,以在命令行操作文件。在Sublime Text中这可以被用来打开文件或项目,也可以像unix工具一样作为一个EDITOR使用,如作为gitsubversion

起步

第一步是给subl添加一个链接。假设你已经把Sublime Text放到了Applications文件夹下,并且你的路径下有~/bin目录,你可以运行:

  1. ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

使用

执行subl —help

  1. Usage: subl [arguments] [files] edit the given files
  2. or: subl [arguments] [directories] open the given directories
  3. or: subl [arguments] - edit stdin
  4. Arguments:
  5. --project <project>: Load the given project
  6. --command <command>: Run the given command
  7. -n or --new-window: Open a new window
  8. -a or --add: Add folders to the current window
  9. -w or --wait: Wait for the files to be closed before returning
  10. -b or --background: Don't activate the application
  11. -s or --stay: Keep the application activated after closing the file
  12. -h or --help: Show help (this message) and exit
  13. -v or --version: Show version and exit
  14. --wait is implied if reading from stdin. Use --stay to not switch back
  15. to the terminal when a file is closed (only relevant if waiting for a file).
  16. Filenames may be given a :line or :line:column suffix to open at a specific
  17. location.

EDITOR

要把Sublime Text作为许多命令的editor来给输入增加提示,设置EDITOR的环境变量:

  1. export EDITOR='subl -w'

指定-w表示只有文件关闭时subl命令才会退出。