Skip to main content
Ben Nadel at the jQuery Conference 2010 (Boston, MA) with: Ben Alman
Ben Nadel at the jQuery Conference 2010 (Boston, MA) with: Ben Alman ( @cowboy )

Exploring The Power Of Multiple Cursors And Selections In Sublime Text 3

By on
Tags:

For the past few years, I've been using - and loving - the Sublime Text (ST3) editor. In fact, I find it so enjoyable, that I've never even looked at any of the new editors that seem to be gaining popularity. One of the Sublime Text features that I couldn't live without is the ability to use multiple cursors and mutate multiple selections at the same time. I know this isn't a proprietary feature of Sublime Text; but, I find that it gives me a massive productivity boost in my day-to-day software development. As such, I thought it would be fun to explore the multi-cursor / multi-selection features more in-depth.

Most of this post is codified in the above video; however, I will outline the key-commands that I am using in the video below:

  • CMD+SHIFT+L - Breaks a multi-line selection into multiple selections, one per line.

  • ESC - Goes from using multiple cursors back to one cursor.

  • ALT+Drag - Inserts a new cursor on each line that is touched during the drag operation.

  • CMD+Click - Inserts a new cursor at each click location.

  • CMD+U - Undoes a cursor or selection change.

  • CMD+SHIFT+U - Redoes a cursor or selection change.

  • CMD+Drag - Adds a new selection and cursor.

  • CMD+SHIFT+Drag - Removes a selection and cursor.

  • CMD+D - Adds the next match as an additional selection and cursor.

  • CMD+K,CMD+D - Removes the current match from the selection and adds the next match as an additional selection and cursor.

  • CTRL+CMD+G - Adds every match as a new selection and cursor.

  • CTRL+SHIFT+Up/Down - Adds a new cursor on the next/following line, respectively.

  • TAB / SHIFT+TAB - Indents and dedents a multi-line selection, respectively.

  • CMD+] / CMD+[ - Indents and dedents each individual line that has a cursor.

  • Find All - This isn't a "key command"; but, the Find All feature will allow you to add a new selection and cursor to every matching piece of text. This is particularly powerful when combined with Regular Expressions.

  • Copy/Paste - Multiple selections can be copied and pasted at individual cursors.

On their own, these features are helpful; but, the real power comes into play when you start using them in combination to accomplish fairly complex tasks. To see what I mean, watch the last few minutes of the video where we use multiple cursors and multiple selections to transform a CSV (Comma-Separated Values) file into a JSON (JavaScript Object Notation) file.

Whether you use Sublime Text or some other editor, I cannot overemphasize the power of multiple cursors! It super-charges your productivity! I highly recommend you take the time to get comfortable with how your IDE implements this feature. And, if your IDE doesn't implement it, I suggest checking out Sublime Text - it's been my tried-and-true companion for years.

Reader Comments

15,688 Comments

@All,

To be clear, I am not intending to say that Sublime Text is the best editor; nor, am I saying it is better than your editor of choice. Just the opposite, I have to assume that all modern IDEs have this kind of functionality built into them. And, I would even guess that many of the key-combinations are the same.

My only hope here is to showcase the awesome power of multiple cursors. And to inspire you to leverage them in your IDE of choice!

57 Comments

I try a lot of editors but always come back to Sublime. It's fast and CFML is very well supported (thanks jcberquist). Recently started exploring using some Vim shortcuts in it using NeoVintageous. Steep learning curve but I think it'll pay off in the end. :)

11 Comments

I remember when Sublime was the universal unchallenged champion. Today it depends on your stack. If you use only CFML it's a strong champion. These days we do much more on the front ends that we used to do inside CFML; Angular, React and Vue for instance. When we move to those realms and want the same tool... does Sublime still offer leading competition?

15,688 Comments

@John,

I personally use Sublime Text for everything including ColdFusion, AngularJS, Angular, and React. And, I haven't felt any points of friction. That said, I'm not really a "plug-in" person. I install plug-ins that do the color-coding for different syntaxes; but, other than that, I basically just jam-out in the code. I don't feel any strong urge to have inline Git info whatever else people are using these days. As such, I can't really speak to that level of support. But, for the most part, Sublime Text gives me everything that I want at fast speeds.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel