Skip to content

Instantly share code, notes, and snippets.

@lenciel
Forked from lucasfais/gist:1207002
Last active October 9, 2015 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenciel/3462897 to your computer and use it in GitHub Desktop.
Save lenciel/3462897 to your computer and use it in GitHub Desktop.
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
⌃ ` python console
⌘⇧N new window (useful for new project)

Editing

⌘L select line (repeat select next lines)
⌘D select word (repeat select others occurrences in context for multiple editing)
⌃⇧M select content into brackets
⌘⇧↩ insert line before
⌘↩ inter line after
⌃⇧K delete line
⌘KK delete from cursor to end of line
⌘K⌫ delete from cursor to start of line
⌘⇧D duplicate line(s)
⌘J join lines
⌘KU upper case
⌘KL lower case
⌘ / comment
⌘⌥ / block comment
⌘Y redo or repeat
⌘⇧V past and ident
⌃ space autocomplete (repeat to select next suggestion)
⌃M jump to matching brackets
⌘U soft undo (movement undo)
⌘⇧U soft redo (movement redo)

XML/HTML

⌘⇧A select content into tag
⌘⌥ . close tag

Find/Replace

⌘F find
⌘⌥F replace
⌘⌥G find next occurrence of current word
⌘⌃G select all occurrences of current word for multiple editing
⌘⇧F find in files

Splits/Tabs

⌘⌥1 single column
⌘⌥2 two columns
⌘⌥5 grid (4 groups)
⌃[1,2,3,4] focus group
⌃⇧[1,2,3,4] move file to group
⌘[1,2,3…] select tab

Bookmarks

⌘F2 toggle bookmark
F2 next bookmark
⇧F2 previous bookmark
⌘⇧F2 clear bookmarks

Marks

⌘K space set mark // ⌘K; for me
⌘KW delete from cursor to mark
⌘KA select from cursor to mark
⌘KG clear mark

Others

Multiple cursors: You can edit multiple lines of code simultaneously very easily by holding down Cmd (ctrl for Windows) and then clicking different lines with your mouse.

Reopening closed tabs: Just as with Chrome, if you accidentally close a file that you’d like to reopen, just press Shift +Cmd + T (or Shift + ctrl + T on Windows). If you keep pressing that key combo, ST will continue opening tabs in the order that you closed them.

Quick file opening: This is perhaps my favorite ST feature. Hold down Cmd + T (or ctrl + T on Windows) to open a textfield that lets you search for files within a project to open. You’ll rarely ever have to use the file tree again.

Jumping to symbols: To quickly jump to specific symbols, hold down Cmd + P (or ctrl + P on Windows) to open up a search field. Type in your symbol and press enter.

Search entire project files: To search the contents of an entire ST project, hold down Shift + Cmd + F (Shift + ctrl + F on Windows).

Jumping between words/lines: This is more of an operating system feature, but I discovered it while using ST. On Macs, if you hold down Alt while using the arrow keys, you jump between words rather than characters. Similarly, if you hold down Cmd while using arrow keys, you jump from the opposite end of a line. Very useful for quickly navigating code without your mouse.

Quickly change settings: Shift + Cmd + P (Shift + ctrl + P on Windows) opens a quick search to allow you to modify Sublime Text preferences.

Jumping between word segments: ”If you hold down control, you move by word segment – this is camel-case (and underscore) aware. So, if I am at the front of the word “cakeParty”, I can move to between ‘e’ and ‘P’ by holding control and pressing the right arrow key.”

Move current line up/down: “You can also move the curent line up and down the page using Ctrl + Cmd + Up/Down”

Sublime Package Control: “Useful for installing things like themes, syntax awareness, code linters, etc…”

Quick word editing: “Cmd + d selects the current word. Subsequent Cmd + d presses will select the following instance of the word for editing. Makes it easy to do things such as renaming a local variable or changing both the opening and closing element of a HTML tag.”

Fine-grained find+replace/modify: “Another one i’ve found useful is CMD+D / CMD+K+D. CMD+D finds the next instance of the current selection and creates another cursor there (and selects it as well). CMD+K+D skips the current selection and finds the next one.”

Select all instances: You can select all instances using cmd + ctrl + G

Go to a specific line: You can jump to a line by using Ctrl + G and typing in the line

Duplicate current line: “Ctrl/Cmd+Shift+D duplicates line/selected text”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment