Some things beginners might not know about Sublime Text

I’m a big fan of Sublime Text. As with many Mac programmers, I started on TextMate and then migrated over once Sublime Text 2 was released. When I started, however, there were a lot of things that I didn’t know about ST, so I’ve compiled a list of basic things that are excellent time savers.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Search entire project files: To search the contents of an entire ST project, hold down Shift + Cmd + F (Shift + ctrl + F on Windows).
  6. 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.
  7. Quickly change settings: Shift + Cmd + P (Shift + ctrl + P on Windows) opens a quick search to allow you to modify Sublime Text preferences.

The following have been additions I’ve seen in the Hacker News comments:

  1. 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.” (Thanks hebejebelus)
  2. Move current line up/down:You can also move the curent line up and down the page using Ctrl + Cmd + Up/Down” (Thanks draftable)
  3. Sublime Package Control: “Useful for installing things like themes, syntax awareness, code linters, etc…” (Thanks po)
  4. 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.” (Thanks haasted)
  5. 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.” (Thanks toran1302)
  6. Select all instances: You can select all instances using cmd + ctrl + G (Thanks gryghostvisuals)
  7. Go to a specific line: You can jump to a line by using Ctrl + G and typing in the line # (thanks arkinex)
  8. Duplicate current line:Ctrl/Cmd+Shift+D duplicates line/selected text” (Thanks akinex)