Speeding Up Coding with Sublime Text

Posted by

In the book, The Pragmatic Programmer, a tip is presented stating “Use a Single Editor Well“. Using a single editor well is definitely good advice, but there are a lot of different editors out there that have vastly different features. You can have a plain text editor to a full blown integrated development environment (IDE) with syntax highlighting and autocomplete recommendations. Since there is such a wide variety, I have multiple text editors installed at any given time. That being said, my go to non-IDE text editor is usually Sublime Text.

While there are many great features about Sublime, the most used feature for me is the multi-line cursor. Sublime’s multi-line cursor allows you to quickly select every line and perform the same action on every line. For example, say I have a SQL data table that I want to create a C# object for that has five properties. I can look up the table definition and then use sublime to do this with effectively only typing out one property. After copy pasting the table’s property definition to sublime, you can select the lines you want or all of them with Ctrl+A, then get a cursor on each of those lines with Ctrl+Shift+L. Then each keystroke is performed on each cursor.

What makes this especially useful is to utilize keyboard navigation to move between words quickly with Ctrl+Arrow keys (which will again, move all cursors). Additionally, copies of cursors are localized (that is, if you highlight a different word with each cursor and Ctrl+C, when you paste each cursor will paste it’s respective copied text). You can even alter the letter casing on each cursor with Ctrl+K+U (upper case) and Ctrl+K+L (lower case). If I’m using a front-end language like AngularJS, I can take that same list of properties and write HTML for it just as easily.

Other personal favorite features in Sublime include recording macros (so you can replay multiple actions, like creating a C# object from a SQL definition, with one click), syntax formatting with the command panel (Ctrl+Shift+P), and community add-ons (such as json quick formatting).

I am not claiming Sublime is the best text editor by any means, but it does provide a lot of functionality that you can leverage to speed up your development. There is definitely a little bit of a learning curve in terms of remembering which shortcuts can let you do what, but once you get the hang of it and integrate it into your development, you can save some pretty serious time and effort.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.