As a developer, you have the choice between many different code editors: Vim, Emacs, Coda, Espresso, Eclipse, Php Storm, to just name a few…
Since I have been using it for quite a while now I thought it was time to write a little summary about the best performance enhancing techniques I have learned during my journey. There are certainly a lot more things to discover, and I’m gonna make a post with more advanced stuff. But let’s start with the basics…
1. Jump to symbol
Probably the most important and time-saving shortcut when working inside of a file and jumping from one method, HTML tag or CSS style to another is the command
CMD+R which opens a dialog that allows you to browse through all these symbols in your current file. It also filters them when typing the first letters of your search term.
2. Jump to files
CMD+P) to save you the time of manually browsing through them. By typing the first letters it also automatically jumps to the currently selected search result.
3. Mark current word
Double-clicking with your mouse is a very common way to select a variable or function name. But you can do it even faster without having to touch your mouse anymore.
CMD+D selects the string where the cursor is currently positioned,
CMD+L expands the selection to the entire line.
4. Split screen
This feature is particularly useful if you work on two files that interact with each other, like an HTML and its corresponding CSS file, or a model and its corresponding controller. With
CMD+ALT+2 you can split your screen into two. Replacing 2 by any other number can split it into even more.
5. Find in files
Sometimes we have to change the name of a method in many different places, or look for the existence of a variable in the whole file tree. This is where the
SHIFT+CMD+ALT+F comes in handy. It opens a new windows showing the occurence of your search term in the entire working directory.
6. Go to line
Whenever your program exceeds 100 lines you probably have to scroll in order to get from one end to the other. This can be very tiring. With
CTRL+G however, you just have to enter the desired line number (usually provided by your debugging or developer tools) and whoops – you’re there.
If you’re concerned about readable, well organized code you’re probably aware of how useful proper indentation is. One very neat feature of Sublime is that if you have multiple lines selected and press
CMD+CTRL+A you can indent them altogether, just as if you moved to each line separately and moved them to the same column.
8. Expand selection to tag
If you’re writing a lot of HTML, you may be familiar with the situation when you have your cursor between the opening and closing tag of an element and want to select the content. Pressing
CMD+SHIFT+A will expand the selection accordingly. Pressing it another time will go up one level and select everything within the parent element and so on.
9. Distraction free mode
There maybe times when other applications like Skype, Twitter or Mail are interrupting your workflow. If the circumstances don’t allow you to switch off these programs entirely, you can still go to Sublime’s distraction free mode by pressing
CMD+CTRL+SHIFT+F. No sidebar, no toolbar, just you and your code. Beautiful!
10. Switch file
I’m probably not the only one that is working with a bunch of open tabs all of the time. There is nothing more time-consuming than switching between tabs using your mouse (just like my father would do). Instead, use the key combination
ALT+CMD+LEFT/RIGHT ARROW to hop between them instantly. If you can guess the order of your tabs, you can even go further and choose the desired tab using
Today we have covered some of the basics for a better Sublime Text workflow by talking about what are probably the most common keyboard shortcuts. In a future post, we will go a bit more into detail to learn some of the more advanced techniques of this code editor. Let me know in the comments if you have further recommendations or ideas on how to increase your productivity when writing code. Thanks a lot for reading!