Wonderful Editor Sublime Text 2

Better than TextMate

  • Cross platform, Mac/Linux/Windows all works!
  • Well designed UI and highly customizable!
  • Support Chinese characters!
  • Rich and convenient package system, easy to hack
  • Support VIM commands
  • Great support to GIT
  • Other great packages, eg. SFTP …

Useful packages

You need to install package control before using these packages.

Convenient shortcuts

Below are some interesting keys in Mac:

  • Cmd Shift p : open command window
  • Cmd t : file finder, support fuzzy query!
  • Cmd Shift [ or ] : jump to left or right file
  • Cmd w : close file
  • Cmd r (Cmd t + @) : find id in html file
  • Cmd t + # : find class or html tags in html file
  • Cmd l : select line/s
  • Cmd (number) : jump to file (number)
  • Cmd t + :(number): jump to line (number)
  • Cmd k b : toggle sidebar
  • Cmd Opt 2 : split to 2 screens
  • Ctrl Shift (number) : move file to screen (number)

Setup package control

It is very simple to setup package control. To check if you successful install, go to Preference -> Browse Packages , go up a folder, and check in Installed Packages .

After installed, you should find Package Control … in command window. Eg. Package Control - Install will connect to remote repo. and show all packages

Setup VIM commands

Vintage provides simulated vim commands in Sublime Text. Default settings ignored it, so you just have to modify this, and add a shortcut key to use it. Official is shared in vintage document and a simple tutorial

Remove Vintage from ignore_packages

  1. Preferences -> Settings - Default
  2. Edit file, remove Vintage from ignored_packages
1
2
3
4
  // List any packages to ignore here. When removing entries from this list,
  // a restart may be required if the package contains plugins.
  //"ignored_packages": ["Vintage"]
  "ignored_packages": []
  1. Preferences -> Settings - User, and do step 2

Setup shortcut key binding

  1. Preferences -> Key Bindings - User ( I use User mode, since in Default mode, updating the software, will reset default settings)
  2. Edit file, add your preferred shortcut key
1
2
3
4
5
6
7
8
9
10
[
  // Add key shortcut to VIM, using escape key in this example
  { "keys": ["escape"], "command": "exit_insert_mode",
      "context":
      [
          { "key": "setting.command_mode", "operand": false },
          { "key": "setting.is_widget", "operand": false }
      ]
  }
]

Now everytime you press ‘escape’ key, it will switch to VIM edit mode!

If you want VIM commands, you can install Vintage Ex through package control.

Setup SFTP

The official website will teach you to install, and configure parameters. I use this simple tutorial to setup remote server and sync remote to local .

Note that, when creating a local repo., sftp-config.json will be created, and server settings are done in this file. I made a few tweaks to make it work better.

1
2
3
4
5
6
7
"save_before_upload": true,
"upload_on_save": true # when save, file will be uploaded, ensure remote file be up to date
"sync_down_on_open": false,
"sync_skip_deletes": false,
"confirm_downloads": false,
"confirm_sync": false,
"confirm_overwrite_newer": true, # warning if remote is being modified

Very simple and works well. Only a pity that .git is not synced, so git tools cannot be used.

Setup Rails Related Files

Just install the package via package control, and add key binding, reference Default (OSX).sublime-keymap in github source.

Default uses Cmd Shift o .

Setup Rails Migration List

Just install via package control. Default uses Cmd Shift m .