![vs code multiple cursors vs code multiple cursors](https://semicolon.dev/static/vscode-keyboard-shortcut-x-create-multiple-selection-anywhere.gif)
Fortunately, we can use good old “Find” to select all the areas we’re interested in and drop cursors on them.įor example, consider a file with several interfaces and classes. They could be in different parts of the file. The lines we’re interested in won’t always be on top of one another. Notice how after step 2, the cursors are vertically offset, but they’re all in the same position relative to the variables. Move to right of variable name ( Right, 2 times).Insert cursors on lines below ( Ctrl+Alt+Down, 4 times).Instead, let’s take advantage of other navigation shortcuts. What if we need them offset? We could use Alt+Click to place each cursor individually, but that would take a while if you had lots of lines. It was easy to place cursors using Ctrl+Alt+Up because we needed cursors at the same position on each line (i.e. You can imagine how much this would speed things up if you had a longer list. Bring all names into one line ( Backspace).Insert cursors on lines 4, 3, and 2 ( Ctrl+Alt+Up, 3 times).Move to beginning of last line ( Ctrl+Left).You could manually bring them into one line and add commas between. (Bonus points if you know why I chose those names.) And you wanted to put them into a comma-separated string. Say you copied a list of names from somewhere: To illustrate, here are a few cases I’ve come across where I’ve used multiple cursors extensively. Shift+: Select from previous position to new position.Of course, your lines won’t always align so nicely, so you may have to use a clever combination of other navigation shortcuts to achieve your goal. Once you have your cursors in place, you can type as usual and your changes will apply to each cursor location. Ctrl+Alt+Up: Add a new cursor above your current one.Ctrl+Alt+Down: Add a new cursor below your current one.Alt+Click: Place a new cursor where you click.Here are the important shortcuts in Visual Studio Code (on Windows): Visual Studio Code is my go-to editor nowadays, and it comes with multiple cursor support out of the box. It sounds like more trouble than it’s worth, but once you learn the shortcuts, it becomes natural. Multiple cursors is exactly what it sounds like: it lets you place more than one cursor in your editor so you can edit multiple locations at the same time. Now I use it every day, and I keep finding new ways to speed up otherwise tedious tasks. I had seen it before when digging through editor settings, but I had never bothered to actually try it until recently. Programming using multiple cursors had always been a mystery to me.