Why I love Sublime Text
For a long time now, my editor of choice has been Sublime Text 2. However, it’s best features are not obvious out of the box, and some need installing as packages.
If you’re using Sublime Text then you shouldn’t miss out all all this goodness. You might find your own favorites, but these are my suggestions:
Keyboard Shortcuts
First, some built-in keyboard short-cuts. You can get much bigger lists elsewhere or just by browsing menus in the app, but these are my favorites:
⌘ + D
The ⌘ + D
key combination first selects the current
word at the cursor and then sequentially multi-selects subsequent
occurences of that word. This is really useful for editing the same
text in multiple places without having to do a search-and-replace
of the whole document.
But I use this even more frequently to jump through a document to find the same text elsewhere, such as a method call.
⌘ + L
Simply use ⌘ + L
to select a whole line,
usually to copy or delete it.
Often I remove a bunch of console.log or print lines by
selecting them with ⌘ + D
and ⌘ + L
and then Delete
.
⌘ + /
This is for commenting-out the selected lines. The same
⌘ + /
works on many different file types E.g. Python
JavaScript, HTML, CSS adding the correct comment syntax to each. Very handy.
⌘ + [ or ]
This will indent selected text to the left or right by a ‘Tab’ E.g. 4 spaces.
⌘ + F
Quickly “Find” words in your current document. Or use Shift + ⌘ + F
to perform a “Global Find” of all files in your Project.
⌘ + P
You can use ⌘ + P
to launch the quick-search prompt for
finding files in your Project. I used to spend a lot of time browsing
the file hierarchy but now I always just search and jump straight to the file.
Shift + ⌘ + P
The Shift + ⌘ + P
key combination launches the command prompt.
You can use a ‘fuzzy search’ here to find and run any menu item.
We’ll be using this in a bunch of places below.
Package Control
All the packages are installed via Package Control, but even this doesn’t come built-in. Follow these install instructions to get started with Package Control.
After a restart, you can use Shift + ⌘ + P
to launch the menu shortcut dialog
and type ‘Install’. Select “Package Control: Install Package” and wait a moment for the
list of available packages to load. Then you can filter and select to install…
Git
The git package has a bunch of
commands, but the one I use most is ‘Git Diff Current’ which will show the diff
of the file you’re editing. Quickly launch the command prompt
with Shift + ⌘ + P
then with fuzzy search 'g d c'
is enough
to find it:
Git Gutter
This is one of the packages that I couldn’t live without. Git Gutter shows your code modifications in the gutter as you’re editing. It’s really useful to see which parts of a file you’re currently working on, and for removing unwanted changes before committing. You can see Git Gutter in all the animations above.
Sublime Linter
Sublime Linter will give you warnings of syntax errors when you save (or when editing) instead of during run-time. It works for multiple languages out of the box, including JavaScript and Python.
Conclusion
That may seem like a lot to remember, but you don’t have to learn them all at once! Just pick the ones you find most useful to start with and go from there.
Happy editing!