

The benefit of this (which I just learned in writing this) is that latter presses of cmd+d will only select full-matches of the initial word. Once you have your selections, you can start typing to replace it, or press left or right to start typing before/after.Īs an alternative to the initial selecting of the text, with your cursor beside (or inside) the word you want to select, you can press cmd+d to “expand the selection to the current word”. If you want to skip an instance you can press cmd+k, cmd+d. In the animation below I select the first instance (with alt+shift+left), then press cmd+d to select the next instance. Most commonly I use cmd+d to select the next instance of selected text. I very frequently need to select and change multiple instances of some text, for example renaming a variable, or changing a parameter on all references of a function. Here are a some examples of when this is useful. One of the most convenient features that (at least originally) set Sublime apart from other editors is the ability to edit multiple lines or places at the same time. This isn’t a comparison of IDEs as I have hardly used many others, but most of them have similar features and plugins, so this may still be relevant. While cleaning out some old records of the plugins and settings we commonly used, I decided to freshen them up and throw in some tips on keyboard shortcuts and multi-cursor editing. Once you get the hang of this method, you will wonder how you survived without it.Sublime Text is a clean and simple looking text editor, but it is powerful, and has plugins for almost everything. Now that you are armed with the basics, go ahead and give it a try. While you can use the regular find-and-replace dialog, but I find this much more convenient and intuitive. This will prevent you from starting allllllll over, which is especially helpful when you are selecting a lot of instances. Luckily, Command+u will undo the last multi-cursor operation.

You might end up selecting one or more too many instances of the desired word or phrase.

Then, you just type the replacement, and all instances are updated with each keystroke! Alternately, you can add a cursor to all occurrences of the current selection with Command+Shift+L. If you have a word highlighted, you can select the next occurrence of that word by pressing Command+d, then repeat until you have all instances of the word selected. It’s very handy for editing data files, such as CSV, and it’s also useful when extracting data from log files. This is very handy for aligning things in columns since you can skip over white space and words using Ctrl and/or Alt as you would with a single cursor. Just hold down Command+Alt and use the Up and/or Down arrows to add new cursors above or below, respectively. If you would like to edit a number of lines at the column position, you can add additional cursors above or below the initial cursor. I believe the middle mouse button can be configured so you don’t need to hold down the Alt key. Assuming you already have your first cursor placed, you just hold down the Alt key, click where you would like to add another cursor, and then repeat as many times as you’d like. The most intuitive way to start adding multiple cursors is with the mouse. Three Ways to Add Cursors The basic mousey way Once you have your cursors placed, you continue editing, and all operations will be applied to all cursors simultaneously.

While multi-cursor mode can be used for column-mode editing, it is much more powerful! It’s column-mode on steroids! Basically, you can place as many cursors in as many places as you want in a single editor view. Here are some tips for getting started! What Is Multi-Cursor Mode? Visual Studio Code has been gaining popularity and has replaced Sublime Text as my editor of choice, and it brought along many of my favorite features of Sublime, including its multiple cursor magic, which is especially great for refactoring.
