10 keyboard shortcuts to become a true Sublime Text ninja

In September I published a post about 10 Sublime Text shortcuts that every web developer should know. This month I want to get a bit deeper into the topic and introduce 10 shortcuts that some people may not be familiar with which will speed up your coding workflow towards ninja standards. Let’s dive right in…

Bookmarking

An essential part of coding is going back and forth between particular parts of your code. But remembering all the line numbers by hard is a big pain. Luckily, you don’t have to with the help of bookmarks. Use CMD+F2 to set as many bookmarks as you want. Then use F2 and SHIFT+F2 to jump back and forth between them.

Command + F2, Shift + F2

Joining and swapping lines

Although the operating system already offers pretty good editing techniques such as jumping to the beginning or end of a line, Sublime Text provides a few more to speed up the most common tweaks: If you want to join the following line with the current one without having to go through all the whitespace in between, just use CMD+J. If you want to swap these lines, use CMD+CTRL+ARROW KEY. Yay!

Command + J, Command + Ctrl + Arrow Keys

Multiple cursors

Have you ever had to do the same modification in multiple lines of code? Could you not imagine a more elegant way of doing this than going through each of the lines one by one? Multiple cursors to the rescue! CTRL+SHIFT+ARROW KEY will add another caret to the line above or below the current position. All subsequent commands will now be carried out simultaneously by all the cursors that you have created. This is going to save you so much time that from now on you can go home a bit earlier each day.

CTRL + SHIFT + ARROW KEYS

Add all occurrences of the selected text to the selection

Sometimes you want to partly modify a variable name or class name globally, but using the search & replace mode with a complicated regular expression seems too much work. The command CTRL+CMD+G is like an interactive advanced search & replace: It creates a new caret at each occurrence of the search string and lets you edit them all at once, like a little ninja army carrying out your instructions. In order to get rid of all the cursors, simply use “escape”.

CTRL + COMMAND + G

Closing current HTML tag

This one is especially useful for frontend developers writing tons of HTML each day. Unless you have something like the Tag package installed, you may have wondered how to close the HTML tag you are currently in. CMD+ALT+. will do just that, saving you a few seconds per day that you can now dedicate to become a super ninja at HTML coding by learning Emmet.

Command + Alt + Dot

Jump to matching brackets

When you’re writing code in a programming language like PHP or JavaScript you happen to be inside of loops, conditions, functions or other programming constructs all the time. And the probability with which you’ll find its corresponding opening and closing bracket with your naked eye is usually proportional to how deep your current line is nested in the code. By using CTRL+M however, you can move your cursor instantly there, and hitting it twice will take you to its opening/closing counterpart. Doesn’t that just blow you over?

CTRL + M

Keyboard scrolling

There are times when your mouse or touch device may be out of reach and you just want to scroll up or down a few lines without loosing the current cursor position. To accomplish this, use the arrow keys as usual, but in combination with CTRL+ALT+ARROWS. Congrats, you’re now scrolling like a ninja without taking your hands off the nunchuk, ehh… keyboard.

CTRL + ALT + ARROWS

Creating row layouts

In part one of this mini-series you learned how to create column layouts (CMD+ALT+2). Now let’s move on to a more advanced ninja move to see how good you can bend your fingers. In order to split your current window into two rows use this: CMD+ALT+SHIFT+2. Once you have mastered this move, try to guess how to get back to the 1-column-1-row layout?!

Command + Alt + Shift + 2

Open user settings

Sublime Text is extremely flexible, even to such an extent that it might scare away some users. In the next part of this mini-series we’ll go over the most common settings that people tend to customize in order to improve their workflow. In the meantime, you may want to go ahead and experiment a bit with your user settings (which override the default settings found under Preferences > Settings - Default. Here’s the last shortcut for today, CMD+,, which will take you there with no detour.

Command + Comma

Wrapping up

Becoming a real Sublime Text ninja takes a lot of time, patience and most importantly, practice. And that’s why you shouldn’t get discouraged when you can’t recall that mind-blowing key stroke the first time you wanna show off your newly acquired skills in front of a co-worker.

You have to internalize that stuff by repeating it every day, or pin a cheat sheet (see additional resource) on your office wall for a few weeks so they’re always within easy reach. While in the beginning it may be hard to resist the urge to use your mouse, it’s a lot more effective to not take your hands off the keyboard for every single action.

After a while, you won’t miss it anymore and perform everything directly with a few key strokes, something which is not only a great way to impress others (especially non-programmers), but also to save you a lot of time each day and to feel more confident in what you’re doing.

Additional resources

Discussions — 15 Responses

  • Dan November 29, 2013 on 5:58 am

    Any hope for windows equivalents?

    Reply
  • Douglas Mak November 29, 2013 on 7:29 am

    Lovely post. I didn’t know about the bookmarking one and I found that to be really helpful. What are your thoughts on an IDE?

    Also, I really like the graphics that you have for each post. Do you make all of those yourself?

    Reply
    • marcelkalveram Douglas Mak November 29, 2013 on 8:53 am

      Hi Douglas, and thanks for the nice words! If with IDE you’re referring to tools like as Eclipse, Netbeans, I have tried plenty of them, but they felt sort of heavy in comparison to ST2. I prefer a lightweight editor that can be extended according to my needs instead of a full-featured programming environment that comes with everything by default.

      For the graphics I usually look for some suitable illustrations on stock photo sites and then adjust them to my needs.

      Reply
  • prasanth December 7, 2013 on 3:06 am

    I especially like the symbols for the keys uses in this post. Did you use a tool to make them ? Or just edited images of symbols?

    Reply
    • marcelkalveram prasanth December 7, 2013 on 9:36 am

      Thanks, as you’ve already figured out, they’re just images of symbols. I’m copying them over from a layout of Mac keys I found on the internet and replace the specific keys with the font tool. A tool would be great to speed this up a bit :)

      Reply
      • Prasanth marcelkalveram December 7, 2013 on 6:09 pm

        Yeah, sounds like a good idea for a tool

        Reply
  • Jonah February 8, 2014 on 4:11 pm

    Thanks for the link in additional resources Marcel, great post and blog!

    Reply
  • Damian May 10, 2014 on 4:07 pm

    Great Tips! Something that get me crazy and Im not sure how to do is to jump from search to the cursor to start editing straight aways without having to click with the mouse. Is that even possible?

    Reply
    • Michael Damian May 31, 2014 on 4:50 am

      Yes, just press Esc.

      Reply
  • Johng415 May 26, 2014 on 10:02 pm

    Hey very nice site!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds alsoI am happy to find a lot of useful info here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . . ddefkeadbkke

    Reply
  • Crick Waters July 10, 2014 on 2:41 pm

    Thanks Marcel. I like the big-button graphics. Helps cement the key-combos in my visual learning mind.

    Reply
  • Bing.com September 20, 2014 on 9:08 pm

    Thanks for another excellent article. The place else may just anyone get that type of information in such a perfect means of
    writing? I have a presentation subsequent week, and I’m on the look for such info.

    Reply
  • Barrett Cox October 20, 2014 on 7:20 pm

    I was unaware of most of these shortcuts in Sublime, so thanks for sharing! Quick question: Did you ever get around to writing a blog post about the settings customization?:

    “In the next part of this mini-series we’ll go over the most common settings that people tend to customize in order to improve their workflow.”

    If so, I would be interesting in reading it. Thanks!

    Reply