Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sublime Text Cheatsheet

Sublime Text Cheatsheet

Command Line

Sublime executable: (recomended name: edit)

/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe $@ &

The path there is intentionally absolute to avoid having to fiddle with sublime itself. You just add the bin directory with your utilities, such as this command and it all just works.

In your config make sure to have: "remember_open_files": false, else things will get troublesome really fast.

Place in something like google drive and add it to your path.

You can now run the following:

# open or switch to sublime window
# open file in sublime
edit /some/file
# open dir in sublime
edit /some/dir
# open current dir in sublime
edit .
# open project
edit /path/to/project_name.sublime-project

If the project was already opened once you can just use Ctrl+Alt+P from sublimetext directly; its much faster. If you end up with a lot of "dead" projects in the Ctrl+Alt+P list (usually as a result of moving) simply do Project / Recent Projects / Clear Items to get rid of them

Opening a project via edit /path/to/project_name.sublime-project can be somewhat of a pain since autocompletion will get confused due to the existance of a project_name.sublime-workspace file. Since 99.9999% of the time you dont even want to go near the file and you just want to access the .sublime-project file one trick you can use to make your life easier is to add this to your ~/.bash_profile file; this will work in windows too assuming you're using something sane such as git bash.

# you may add more extentions to ignore using : as the delimiter
export FIGNORE=.sublime-workspace

The changes take effect on login; to enact them imediatly simply do . ~/.bash_profile. Now typing something like proj[TAB] will magically autocomplete to project_name.sublime-project every time since bash will no longer recognize .sublime-workspace files as being important enough to autocomplete to (as it should).

Sample User Settings

The following are generally useful. Note that hot_exit and remember_open_files are off because of the project based workflow suggested here. If you want to use sublime just for file editing I've had them true for years while using the editor for that purpose and it works just fine.

"tab_size": 4,
"use_tab_stops": true,
"font_size": 10,
"rulers": [ 80 ],
"trim_trailing_white_space_on_save": true,
"word_wrap": false,
"highlight_modified_tabs": true,
"draw_white_space": "selection",
"hot_exit": false,
"remember_open_files": false

Essential Shortcuts

quickly goto line: Ctrl+G

quickly move to symbol: Ctrl+R

quick move to file: Ctrl+P

quick command: Ctrl+Shift+P (ie. Ctrl+P but searching sublime itself)



Creating projects,

Ctrl+Shift+P > "project" > "add folder"

Method 1

Ctrl+Shift+P > "project" > "save as" > ~/sublime-projects/ > save as "[project]"

This will save a local copy. Use this if you want to set hard paths that you have no chance of setting relatively.

Method 2 (prefered)

Alternatively you can actually just save it in the current project root!

Ctrl+Shift+P > "project" > "save as" > path/to/project/files > save as "[project]"

Simply make the file paths relative (the root is the folder where the .sublime-project is created). You can add the .sublime-project file to git but you should make sure the .sublime-workspace file is ignored.

What's good about projects

Creating a porject will also always create a workspace file at the same location; workspaces are essentially your current screen with your current open files.

When you have a project configured, files you haven't even saved that are created while the project is open will persist! So you can switch between projects and not worry about such things as: "Oh here's another stupid file needs saving."

To switch projects: Ctrl+Alt+P

But wait... it gets better.

Ctrl+Shift+P > "project" > "edit project" (will edit current project)

You can also go Project / Edit Project if sublime for whatever reason doesnt want to open the configuration file. (had it happen a few times)

Sample project configuration:

  "folders": [
      "name": "Project Files",
      "path": "sources"
      "name": "Configuration",
      "path": ".",
      "file_exclude_patterns": [ "*.sublime*", ".git*" ],
      "folder_exclude_patterns": [ "build", "sources", "node_modules" ]
  "settings": {
    "rulers": [ 80 ],
    "tab_size": 2,
    "trim_trailing_white_space_on_save": true,
    "use_tab_stops": false
  "build_systems": [
      "name": "Grunt",
      "cmd": ["grunt"],
      "working_dir": "${project_path}"

See it in action:

Will show up in sidebar as:

Project Files
 - jsx
 - lib
 - scss

As oppose to the giant folder mess you see in the actual git repo.


Toggle sidebar: Ctrl+K,B (KB can be delay-pressed)

Toggle layout columns: Alt+Shift+(1 or 2 or 3 or 4 or 5)

Move file between columns: Ctrl+Shift+(1 or 2 or 3 or 4 or 5)

To view the same file in multiple tabs you simply need to duplicate the file view via File / New View into File then move it to whatever tab you wish.

Build Systems

These can be specified either via the menu Tools / Build System or via the project settings.

Once configured you can press F7 to run the build system in the current context.

Magical Editing

Ctrl+Shift+D - duplicate line

Ctrl+Shift+(Up or Down) - move line

Ctrl+Shift+K - del line

Multiple cursors: Ctrl+Click (press Esc to reset) When you have multiple cursors anything you write just gets duplicated to all the cursors.

Line joining: put a cursor on every line you wish to join, then just press Ctrl+J you can then tweak it while the cursors are active.

Multiselect: Ctrl+Selection

Ctrl+Shift+V will paste but keep indentation, so you dont have to re-indent.

Ctrl+L select line

Ctrl+Shift+M will select everything between brackets (either {} or []) based on the current position of the cursor.

Ctrl+Shift+J same as above only selects based on curreent indentation.

Alt+Q wrap current paragraph to ruler.

F9 sort lines

Ctrl+M move cursor to ending brancket

Ctrl+U soft undo

If you forget one, see Selection and Edit in the menus. They're mostly all there, just covertly hidden.


Ctrl+Shift+P > "snippet"

Sublime comes with a few by default simply select and press enter.

Alternatively if you know what's called the "trigger" word and you start typing it you'll get a hint (similar to autocomplete) that when selected will auto-complete with the snippet.

Creating snippet: Tools / New Snippet

Make sure to decomment "tabTrigger" and save the file as your-trigger-word.sublime-snippet

You can manipulate the cursor via $0, or ${1: some stuff} or even nest them ${1: some stuff $2 etc}. Make sure to escape the $ via \$ and also escape closing } if they are a literal before a selection ends.


Find plugins here:

Plugins manager for easy install

Installing plugins: Ctrl+Shift+P > "install" > select "Package Control: Install Package"

You should now see a list of packages, just type the name and hit enter; at the bottom in the status bar you'll see progress and your new plugin will be installed. No copy pasting in random system folders etc. Super simple. If you know the name of a plugin you can install it with a few key presses. :)

  • emmet - zen coding text expantion
  • sidebarenhancements - sidebar rightclick goodies
  • syntax highlighting for sass - best sass/scss syntax highlighting
  • GitHub Flavored Markdown Preview - preview by pressing Ctrl+Shift+G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment