The Mug of Sublime Text

A tribute to the Mug of VI

Sublime Text is at its most sublime when you can remember its most useful and delightful keyboard shortcuts. Thus, I created this reference focused on keyboard shortcuts that are part of ST's default installation. (A few keymap customizations are too awesome to be ignored; I have included the keymap customizations in the repo for these cases.)

This project doesn't include keyboard commands that are fairly standard to the operating system; such as Ctrl Shift t to re-open the most recently closed tab.

Commands have been tested in Windows and OSX (sorry Linux folks). For OSX, use Command in place of Ctrl, unless otherwise noted.

Selecting

Ctrl Shift a
Select contents of tag. Again to select the tag. (Cmd Shift a on OSX.)
Ctrl Shift m
Select contents of brackets; again to select the brackets too.
Ctrl Shift Space
Select attribute value (plus quotes); again to select tag. (Cmd Shift Space on OSX).
Ctrl l
Select the current line. (Subsequent presses of l while holding Ctrl will select lines further down.)
Ctrl Shift l
Change highlighted block into a multi-selection.
F3
Go to next occurence of searched-for text. (Cmd g on OSX.) Add shift to go backwards.
Alt F3
Select all occurrences of the highlighted text. (Ctrl Cmd g on OSX.)
Ctrl d
Add next occurrence of selection as a multi-selection.
Ctrl Shift [
Fold highlighted text out of view. Ctrl Shift ] to unfold. (Option Command [ and Option Command ] to fold and unfold on OSX.)
Ctrl Alt DownArrow
Add line below as multi-selection (UpArrow for line above).
Shift Right Click
Select columns of text. (Or middle click.) Option click on OSX.
Ctrl c
Copy selected text. When nothing is selected, ST will copy/cut the current line of text. (Ctrl x to cut currently selected line.) You can disable this by adding "copy_with_empty_selection": false to your Preferences.sublime-settings file.)

Editing Text

Ctrl /
Comment the highlighted text (or current line); again to un-comment.
Alt Shift w
Wrap selection with tag. (Ctrl Shift w on OSX).
Ctrl Shift k
Delete current line(s).
Ctrl Shift d (Cmd Shift d on OSX.)
Duplicate line(s).
Ctrl j
Join line below cursor to current line of text.
Ctrl Shift j
Join all highlighted lines into a single line.
Ctrl Shift UpArrow/DownArrow (Ctrl Cmd UpArrow/DownArrow on OSX)
Swap current line (or selected block) with the line above or below.
Ctrl Backspace
Delete word in front of cursor.
Ctrl Del
Delete word behind cursor.
Ctrl k u
Delete from cursor to beginning of line. (Cmd Delete on OSX.)
Ctrl k k
Delete from cursor to end of line. (Cmd k k on OSX.)
Ctrl k u
Uppercase selected text.
Ctrl k l
Lowercase selected text.
Ctrl ]
Indent selected text one level. Ctrl [ to un-indent one level.
Ctrl m
Move cursor to opening or closing backet. Use Ctrl Alt j for HTML tags with Emmet.
Ctrl F2
Add / remove bookmark. (Command Fn F2 on OSX.)
F2
Move cursor to next bookmark. Shift F2 to move to previous bookmark. (Fn F2 / Shift Fn F2 on OSX.)
Alt F2
Select all bookmarks.
Ctrl Shift F2
Remove all bookmarks.
Ctrl g
Move cursor to line number (using Goto Anything palette).
Ctrl r
Move cursor to "symbol". Examples: function, class, header, or code block.
Ctrl Home/End
Move cursor to beginning / end of file. (Cmd UpArrow/DownArrow in OSX.)

Environment / View

Alt Shift 1
Switch to single column layout. (Option Cmd 1 on OSX.)
Alt Shift 2
Switch to 2 column layout. (Option Cmd 2 on OSX.)
Ctrl +
Increase text size.
Ctrl -
Decrease text size.
Ctrl k t
Fold all tag attributes.
Ctrl k 2
Fold all code deeper than 2 tags, except cursor's current location.
Ctrl k j
Unfold all folded code.

With Customized Keymap

Ctrl Shift r
Tidy Selected HTML (Edit > Line > Reindent).
Ctrl v
Newly pasted text will use existing indentation; Ctrl Shift v for standard paste.
Ctrl Shift w
Close all open files.
Alt w
Toggle word wrap on or off. (Fn w on OSX.)
Ctrl k i
Titlecase selected text.

Wicked Cool Stuff

Command Palette

Ctrl Shift p to open the Command Palette, then select one of the below from the list.

HTML: Encode Special Characters
Encode ampersands, less than signs and even accented letters within highlighted text.

Emmet.io

Ctrl ,
Select tag contents (if cursor in contents) or tag (if cursor in tag).
Ctrl Shift .
Select item; (attribute or tag). Ctrl Shift , to select previous. Buggy (Shift Command .) in OSX.
Ctrl u
Insert dimensions into an image.
Ctrl '
Encode image as Base 64.
Ctrl Alt j
Move cursor to open tag; again to move cursor to closing tag.
Shift Ctrl ;
Delete parent start and end tag from cursor position.
Ctrl UpArrow/DownArrow
Increase/Decrease Value by 1; add Alt to increment by 10.
Ctrl e
Change highlighted text into open and close XML tags.

See http://docs.emmet.io/cheat-sheet/ for more super powerful snippets / expansions provided by Emmet.io.

Sorting

F9
Sort selected lines. Ctrl F9 for case-sensitive sort. See also Edit > Permute Lines and Selection (multi-selection).

Notes

  1. "Current" means where the cursor is, or a selected block.
  2. Don't put "+" in a command unless the user has to actually hit the plus key.
  3. Upper case indicates special keys like Space and Shift. On standard letters, upper case is only used if required.

Tips