909

What are the keyboard shortcuts for creating multiple cursors in VS Code?

13
  • 192
    Just hold down the Alt button and start clicking in different places. That's it.
    – username
    Commented Nov 11, 2015 at 7:14
  • 109
    CMD+Alt+Down arrow is what you want. stackoverflow.com/questions/30037808/… Commented Jun 27, 2017 at 16:19
  • 9
    If you're using a mac, SHIFT+CTRL+DOWN/UP is what you actually want as of 1.14.2.
    – Ben Creasy
    Commented Jul 22, 2017 at 2:06
  • 3
    Also, it looks like Cmd+Alt+Down is mapped by editor.action.goToDeclaration by default as of 1.14.2
    – Ben Creasy
    Commented Jul 22, 2017 at 2:39
  • 3
    If you're on Mint, you can just disable the Alt Click going to System Settings, Window, Behavior and then changing the "Special key to move and resize window".
    – ncesar
    Commented Mar 27, 2019 at 15:09

23 Answers 23

904

Press Alt and click. This works on Windows and Linux*, and it should work on Mac, too.

More multi-cursor features are now available in Visual Studio Code 0.2:

Multi cursor improvements

  • Ctrl+D (Cmd+D on Mac) selects next occurrence of word under cursor or of the current selection
  • Ctrl+K Ctrl+D moves last added cursor to next occurrence of word under cursor or of the current selection
    The commands use matchCase by default. If the find widget is open, then the find widget settings (matchCase / matchWholeWord) will be used for determining the next occurrence
  • Ctrl+U (Cmd+U on Mac) undoes the last cursor action, so if you added a cursor too many or made a mistake, you can press Ctrl+U (Cmd+U on Mac) to go back to the previous cursor state.
  • Adding cursor up or down (Ctrl+Alt+Up / Ctrl+Alt+Down) (Cmd+Alt+Up / Cmd+Alt+Down on Mac) now reveals the last added cursor to make it easier to work with multiple cursors on more than 1 viewport height at a time (i.e. select 300 lines and only 80 fit in the viewport).

This makes it a lot easier to introduce multiple cursors

Linux drag-window conflict:

  • Some distros (e.g. Ubuntu) assign window dragging to Alt+LeftMouse, which will conflict with VSCode.
  • So, recent versions of VSCode let you toggle between Alt+LeftMouse and Ctrl+LeftMouse under the Selection menu, as detailed in another answer.
  • Alternately, you could change your OS key bindings using gsettings as mentioned in another answer.
20
  • 13
    F2 or Ctrl+F2 may help. But haven't found something like Ctrl+D.
    – vilicvane
    Commented Apr 29, 2015 at 20:16
  • 19
    Alt+click doesn't seem to work on Linux. What did work for me was Ctrl+shift+left/right/up/down Commented Feb 7, 2017 at 12:22
  • 23
    alt + shift + click on mac (2017)
    – Hoff
    Commented May 13, 2017 at 11:53
  • 7
    hmmm, ctrl+alt+up or down rotates my screen (on win10) instead of multiple cursor
    – Reinsbrain
    Commented Sep 26, 2017 at 12:43
  • 4
    @Reinsbrain try disable that hot key provided by your GPU driver, maybe right click on desktop and checkout related menu items.
    – vilicvane
    Commented Sep 26, 2017 at 13:00
291

Multi-word (and multi-line) cursors/selection in VS Code

Multi-word:

Windows / OS X:

  • Ctrl+Shift+L / ⌘+Shift+L selects all instances of the current highlighted word
  • Ctrl+D / ⌘+D selects the next instance... and the one after that... etc.

Multi-line:

For multi-line selection, Ctrl+Alt+Down / ⌘+Alt+Shift+Down will extend your selection or cursor position to the next line. Ctrl+Right / ⌘+Right will move to the end of each line, no matter how long. To escape the multi-line selection, hit Esc.

See the VS Code keybindings (OS sensitive)

6
  • 39
    Ha ha on my machine the Intel video driver has a hot-key Ctrl-Alt-Down to make the screen go upside down. Caught me off guard :)_ Commented Oct 4, 2017 at 7:00
  • 7
    Why is not the same as SSMS (and presumably Visual Studio), which uses Shift-Alt-Down/Up, not Ctrl-Alt-Down??? Commented Oct 4, 2017 at 7:01
  • 8
    To disable the dumb Intel hotkey, you can just right click on desktop > Graphic options > Hotkeys > Disable
    – alxgb
    Commented Aug 23, 2019 at 17:16
  • 1
    ⌘+Shift+L works on my mac, but for some reason Ctrl+Shift+L doesn't work on my pc :(:( Commented Mar 31, 2023 at 12:21
  • 1
    EDIT: It was Ctrl+F2 instead Commented Mar 31, 2023 at 12:27
199

May 2017
As of version 1.13 Add multiple cursors with Ctrl / Cmd + Click

VSCode developers have introduced a new setting, editor.multiCursorModifier, to change the modifier key for applying multiple cursors to Cmd + Click on macOS and Ctrl + Click on Windows and Linux. This lets users coming from other editors such as Sublime Text or Atom continue to use the keyboard modifier they are familiar with.

The setting can be set to:

  • ctrl/Cmd - Maps to Ctrl on Windows and Cmd on macOS.
  • alt - The existing default Alt.

There's also a new menu item Use Ctrl + Click for Multi-Cursor in the Selection menu to quickly toggle this setting. enter image description here

The Go To Definition and Open Link gestures will also respect this setting and adapt such that they do not conflict. For example, when the setting is ctrl/Cmd, multiple cursors can be added with Ctrl / Cmd + Click, and opening links or going to definition can be invoked with Alt +Click.

With fixing Issue #2106, it is now possible to also remove a cursor by using the same gesture on top of an existing selection.

4
  • 2
    I was going nuts on why Ctrl+click wasn't working. Didn't know there was an option to toggle it. :-)
    – ankush981
    Commented Jul 15, 2017 at 6:28
  • 6
    Setting the editor.multiCursorModifier from alt to ctrlCmd worked great. Now all I have to do is ctrl + click and it will use multiple cursors :) Muchas gracias! Commented Jul 15, 2017 at 19:45
  • I can change to Ctrl + click, it works, but to go to definition of class or something is gone, how can I fix?
    – Vuong Tran
    Commented Jul 26, 2018 at 3:18
  • 1
    This is the most helpful answer. In most editors CTRL+click is used for multiple selection. There is no need to modify the OS behaviour to make an editor work. This option modifies the behaviour for multiple selection to the most commonly used pattern.
    – Ruby Racer
    Commented Feb 7, 2019 at 9:13
148

I had problem with ALT key, fix is to change alt+click as a Gnome hotkey which clobbers multi-cursor select in VSCode, to super+click by running:

gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "<Super>"   

Source: http://2buntu.com/articles/1529/visual-studio-code-comes-to-linux/

8
  • 7
    +1 this method works! Just verified it with Ubuntu 14.04.05.. Earlier I tried dconf-editor and CompizConfig to change "move window" plugin configurations and messed up and almost broke my Ubuntu.
    – Dimitry K
    Commented Aug 21, 2016 at 20:14
  • 2
    This works in Ubuntu! Commented Feb 25, 2017 at 3:56
  • 13
    Use gsettings set org.cinnamon.desktop.wm.preferences mouse-button-modifier "<Super>" for Linux Mint (Cinnamon).
    – vossad01
    Commented Jun 14, 2017 at 23:38
  • 2
    If you do not want to touch your system default settings, you may also use "Selection > Switch to CTRL+Click for Multi-Cursor". This works in Linux Mint, so it should work in Ubuntu too.
    – lsblsb
    Commented Mar 22, 2019 at 9:24
  • 2
    If you want to change the system setting in Linux Mint Cinnamon, you may also go to "System Settings > Preferences > Windows > Behavior" and change the "Special key to move and resize windows".
    – lsblsb
    Commented Mar 22, 2019 at 9:37
115

Try Ctrl+Alt+Shift+⬇ / ⬆, without mouse, or hold "alt" and click on all the lines you want.

Note: Tested on Windows.

6
  • 43
    CMD+OPTION+SHIFT+⬇ / ⬆ works for me on Mac with version 1.15.1. Commented Sep 11, 2017 at 1:25
  • 2
    On windows 10 I'm able to do it without the shift Commented Dec 7, 2017 at 14:15
  • 3
    You can also use page up/down to go faster!
    – Maxime
    Commented Apr 11, 2018 at 19:43
  • without SHIFT it wasn't working for me thx
    – BartusZak
    Commented Sep 25, 2019 at 16:31
  • 1
    I installed Smart Multi-cursor extension with some advanced features, with shortcut Cmd + Alt + (Up / Down) to create the multi-cursor.
    – Danny
    Commented Nov 23, 2019 at 16:46
62

Cmd+Option+Shift⬇ / ⬆ works for me on newest VSCode 1.29.1 and newest OSX High Sierra 10.13.6, Macbook Pro.

This adds a vertical line up/down on screen, like Option+Click/Vertical Drag does in Sublime Text.

To add multiple cursors at any points in your file, including multiple ones on the same line, do Cmd (or Option)+Click anywhere you want, shown in this video. You may also search for text (Cmd+F) that repeats multiple times, then press Option+Return to add cursors at end of EACH word.

40

As of Visual Studio Code version 0.10.9, you can now do a Create Multiple Cursors from Selected Lines by selecting multiple lines, and pressing Shift+Alt+I

Note: This is similar to Sublime Text's Ctrl+Shift+L functionality.

Source: https://code.visualstudio.com/updates/vJanuary#_thank-you
Relevant PR: https://github.com/Microsoft/vscode/pull/1479

2
  • 1
    This is exactly what I was looking for! Shift+Alt+I works like a charm!
    – myrs
    Commented Jul 26, 2021 at 14:13
  • FINALLY. You da man Commented Jun 12, 2024 at 15:12
34

On XFCE, go to Applications -> Settings -> Settings editor - > xfwm4 -> easy_click(disable value)

Now you can Insert Cursor with Alt + Click

I've also disabled L/R Workspace (ctrl + alt + L/R) settings in Settings -> Window manager -> Keyboard

6
  • 1
    ?? what is XFCE here? Commented Apr 30, 2018 at 19:32
  • 2
    @Martian2049, it's a Desktop Environment on Unix-like operating systems (Linux, BSD etc). If you don't know this yet, probably my answer won't be useful for you, go check other answers.
    – lava-lava
    Commented May 2, 2018 at 16:39
  • It's working after disabling easy_click for me, thanks you saved my day. Commented Sep 17, 2018 at 19:53
  • It's working for me. I changed in easy_click ALT to CTRL because ALT + click is for moving windows.
    – millonesj
    Commented Jul 20, 2019 at 15:14
  • Nice reply. It works for me @lava-lava.
    – abu abu
    Commented Nov 6, 2019 at 3:07
31

On Ubuntu, in order to enable multi-cursor clicking you will need to re-assign Alt+click first, by running the command below. This is because by default Ubuntu uses the shortcut itself and has it takes precedence.

> gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "<Super>"
0
19

Ctrl+Alt+⬇ / ⬆ add cursors above and below the current line. Still nowhere near as good as sublime or brackets though. I can't see anything equivalent to Ctrl+D in sublime in the keyboard shortcuts file.

6
  • 6
    For Mac it is: Alt + Command and up or down arrow. Commented May 11, 2016 at 21:23
  • On Ubuntu this is Ctrl+Shift+Up/Down
    – tobalr
    Commented May 1, 2018 at 17:53
  • 1
    In Windows that seems to default to "rotate screen".
    – BlaM
    Commented Sep 17, 2019 at 9:54
  • 2
    If it's rotating your screen, that's your graphics driver, not windows. You can disable that shortcut from the graphics settings.
    – Daniel
    Commented May 2, 2020 at 19:40
  • Works for me! :)
    – Phil
    Commented Jul 21, 2020 at 22:08
19

There is no binding for exactly what you want.

The only thing that comes close is Ctrl+F2 which will select all of them at once.

You can bind it to Ctrl+D doing the following:

  • Click on File > Preferences > Keyboard Shortcuts
    You should see a pane full of the current bindings and on the right a list of custom bindings
  • In the current bindings, search for Ctrl+F2 and copy that whole line and paste it into the right pane.
  • You might have to remove the comma at the end and then change Ctrl+F2 to Ctrl+D and then save the file.

It should look something like this:

// Place your key bindings in this file to overwrite the defaults
[
  {
    "key": "ctrl+d",
    "command": "editor.action.changeAll",
    "when": "editorTextFocus"
  }
]
3
  • 1
    Can i make it multicursor like, sublime does .. pressing the mousewheel?
    – Miguel Q
    Commented Sep 16, 2015 at 10:13
  • @MigueI haven't found a way to do that yet
    – intrepion
    Commented Sep 16, 2015 at 21:43
  • When you don't want to search and replace, this is the most efficient way if you have thousands of rows to edit at the same time ! THX !
    – Link
    Commented Sep 17, 2017 at 13:50
9

https://code.visualstudio.com/Updates

New version (Visual Studio 0.3.0) support more multi cursor feature.

Multi-cursor
Here's multi-cursor improvements that we've made.

⌘D selects the word at the cursor, or the next occurrence of the current selection.
⌘K ⌘D moves the last added cursor to next occurrence of the current selection.
The two actions pick up the matchCase and matchWholeWord settings of the find widget.
⌘U undoes the last cursor action, so if you added one cursor too many or made a mistake, press ⌘U to return to the previous cursor state.
Insert cursor above (⌥⌘↑) and insert cursor below (⌥⌘↓) now reveals the last added cursor, making it easier to work with multi-cursors spanning more than one screen height (i.e., working with 300 lines while only 80 fit in the screen).

And short cut of select multi cursor change into cmd + d(it's same as Sublime Text. lol)

We can expect that next version supports more convenient feature about multi cursor ;)

9

Alt+Click. It works in Windows.

Details: Visual Studio Code Documentation

0
8

In my XFCE (version 4.12), it's in Settings -> Window Manager Tweaks -> Accessibility.

There's a dropdown field Key used to grab and move windows:, set this to None.

Alt + Click works now in VS Code to add more cursor.

1
  • For Linux mint 20 Go to menu->type window->click on windows->choose behaviour tab and go down to moving and resizing windows Change special key to move and resize windows to something different from Alt
    – iamafasha
    Commented Mar 8, 2021 at 19:14
7

In Visual Studio without mouse: Alt+Shift+{ Arrow }.

1
  • 4
    Alt+Shift+{ Arrow }. will result in copying of the current line as of VS Code V1.18.0 Commented Nov 11, 2017 at 17:09
6

For xfce users, just go to settings>window manager tweaks>accessibility there change the key used to grab and move windows: to super as demonstrated in the image below.enter image description here

Now you can use super instead of alt. Wallah!! Go make multiple cursors by alt + click.

5

You can do the following per the Selection menu:

Screenshot of Selection menu in VS Code

Press/hold Alt+Ctrl+Up Arrow/Alt+Ctrl+Down Arrow as required to create sufficient cursors, then Ctrl+D can be used to expand the selections.

4

Same issue on Ubuntu-MATE, but here you resolve it by:

gsettings set org.mate.Marco.general mouse-button-modifier "<Super>"
2

Alt + Command + Shift will add a cursor to the next instance of what you've selected. E.g. a variable or function name

2

Easy VSCode multiline cursor guide for Windows and Mac. If you tried and noticed very confusing keyboard instructions and could not sort it out, I provide very easy and simple way:


Windows:

Starting from one line and selecting multiple lines manually: Keep Alt + Ctrl + Shift pressed and move to upper or lower lines with keyboard arrows.

To add anything to both - the beginning and end of all lines at the same time:

  1. Ctrl + A - select all
  2. Alt + Ctrl + Shift + Down arrow from the keyboard - You will see multiple line start and end cursors blinking
  3. Keep Alt + Ctrl + Shift pressed and use Right arrow to brings cursors to the right side end of words.
  4. Now what you write will be added to both sides. Very helpful if you are making a long list from words and need to add double quote, quote or any other symbols.

If you want to add one symbol to all lines:

  1. Ctrl + A - select all
  2. Keep Alt + Ctrl + Shift pressed and press the Down arrow from the keyboard once.
  3. Now you can use Left and Right arrows from the keyboard to move cursors to anywhere
  4. Add any symbol, letter from the keyboard.

Macbook MacOS:

Starting from one line and selecting multiple lines manually: Keep Alt + Command + Shift pressed and move to upper or lower lines with keyboard arrows.

To add anything both - to the beginning and end of all lines at the same time:

  1. Command + A - select all
  2. Alt + Command + Shift + Down arrow from the keyboard - You will see multiple line start and end cursors blinking
  3. Keep Alt + Command + Shift pressed and use Right arrow to brings cursors to the right side end of words.
  4. Now what you write will be added to both sides. Very helpful if you are making a long list from words and need to add double quote, quote or any other symbols.

If you want to add one symbol to all lines:

  1. Command + A - select all
  2. Keep Alt + Command + Shift pressed and press the Down arrow from the keyboard once.
  3. Now you can use Left and Right arrows from the keyboard to move cursors to anywhere
  4. Add any symbol, letter from the keyboard.
0

First go to "Keyboard Shortcuts", you can get there by hitting Cmd+k then Cmd+s, or for Windows Ctrl+k then Ctrl+s.

Once you're there, search for "Add Cursor Above" and "Add Cursor Below". You can even assign them your own key-bindings.

0

Multiple cursor on selected word
Use case - if you have a large document and want to modify some word or select a line containing that word.

I'll walk through with one example
Suppose you have a document (of any type) like

{
    x: xval1,
    y: yval1,
    z: zval1
},
{
    x: xval2,
    y: yval2,
    z: zval2
},
{
    x: xval3,
    y: yval3,
    z: zval3
}

You want to select all the values associated with x and expecting output like this \

x: xval1,
x: xval2,
x: xval3,

Steps to achieve this output using vscode only -

  1. find (command + f) with "x:"
  2. (option + enter) for multiple cursors on each occurrence of "x:".
  3. Move all cursors to the left of the lines using (command + left arrow)
  4. Now, select the whole line by (command + shift + right arrow)
  5. Copy (command + c) the content
  6. Paste (command + v) it anywhere you want

I want to emphasise on the second step how much strong this command can be.

0

For selecting same place on multiple lines just by keyboard and without using mouse (checked and worked on windows 10):
ctrl + alt + shift + ↓ (down arrow key)

enter image description here

1
  • this selects multiple lines for me, not multiple cursors.
    – majorgear
    Commented Jul 30, 2024 at 15:18

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.