838

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

Richard
  • 4,740
  • 4
  • 32
  • 39
Kiba
  • 10,155
  • 6
  • 27
  • 31
  • 183
    Just hold down the `Alt` button and start clicking in different places. That's it. – username Nov 11 '15 at 07:14
  • 92
    CMD+Alt+Down arrow is what you want. https://stackoverflow.com/questions/30037808/multiline-editing-in-vscode – Valentine Bondar Jun 27 '17 at 16:19
  • 7
    If you're using a mac, SHIFT+CTRL+DOWN/UP is what you actually want as of 1.14.2. – Ben Creasy Jul 22 '17 at 02:06
  • 2
    Also, it looks like Cmd+Alt+Down is mapped by editor.action.goToDeclaration by default as of 1.14.2 – Ben Creasy Jul 22 '17 at 02:39
  • As of now, we can use middle mouse button to select multiple columns. https://code.visualstudio.com/updates/v1_23#_column-selection-using-middle-mouse-button – Ahmad Ismail May 28 '18 at 03:07
  • 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 Mar 27 '19 at 15:09
  • On MacOS, you currently do it by holding down CMD while clicking. – Magnus Lind Oxlund May 16 '19 at 20:33
  • What about Linux ? Ctrl + click, Alt + click, Shift + click none is working. Thanks. – abu abu Sep 30 '19 at 09:43
  • 1
    Linux (tested on Ubuntu) `Ctrl`+`Shift` `⬆` or `⬇` does multi select - Also `alt` + `click` – Arash May 15 '20 at 10:16
  • 1
    `editor.action.selectHighlights` is most likely what you need. Cmd+Shift+p (Ctr+Shift+p) > type `keyboard shortcuts`, paste `editor.action.selectHighlights` and double-click to assign your own shortcut. – ccpizza Mar 13 '21 at 12:36
  • 1
    On Mac it is `Option` button so Just hold down the `⌥` aka `option` button and start clicking in different places. That's it. :) – Aakash Sep 02 '21 at 16:25
  • 1
    MacOS: The _keyboard_ shortcut is Shift + Alt/Option + Command + 'arrow key'. – Paul Jan 20 '22 at 22:40

23 Answers23

836

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.

Freddo
  • 523
  • 6
  • 16
vilicvane
  • 11,625
  • 3
  • 22
  • 27
  • 13
    F2 or Ctrl+F2 may help. But haven't found something like Ctrl+D. – vilicvane Apr 29 '15 at 20:16
  • I'm using version 0.5.0. It still doesn't work if the selection has punctuation in it. I cannot select all occurrences of 'http://' with Ctrl+F2 but Ctrl+D works ok... Problem reported [here](https://code.visualstudio.com/issues/detail/18227). – shamp00 Jul 28 '15 at 10:08
  • In the VS Code Intro Videos, there is [a video](https://code.visualstudio.com/docs/introvideos/codeediting) that gives this tip: put the cursor where you want it, hold down the option/alt key, then click anywhere else for an additional cursor. Simple. Works with `OSX 10.10.5`/`VS Code 1.8.1`. – 7stud Jan 14 '17 at 15:10
  • 18
    Alt+click doesn't seem to work on Linux. What did work for me was Ctrl+shift+left/right/up/down – Yonatan Simson Feb 07 '17 at 12:22
  • 23
    alt + shift + click on mac (2017) – Hoff May 13 '17 at 11:53
  • alt + shift + click works on Linux (Ubuntu), too. – Blacklight Jun 07 '17 at 12:22
  • (July 2017) Ctrl+D now works. It adds a cursor to the next text match you are currently editing (i.e same effect as sublime) – user3341332 Jul 02 '17 at 10:52
  • alt + shift + click not working on Linux (Ubuntu) – Ben Taliadoros Aug 03 '17 at 16:55
  • 7
    hmmm, ctrl+alt+up or down rotates my screen (on win10) instead of multiple cursor – Reinsbrain Sep 26 '17 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 Sep 26 '17 at 13:00
  • 2
    @vilicvane : found disable hot key option under systray icon for intel graphics - thanks :) – Reinsbrain Sep 26 '17 at 14:48
  • 1
    This is great, I would just add the following: alt + shift + I turns a multi-line selection in multiple cursors – atlas_scoffed Mar 02 '18 at 01:50
  • Why are there references to 'alt' on Mac? There is no 'alt' key on Mac. There is 'control', 'option', and 'command'. For Mac users, here is an answer which works: https://stackoverflow.com/questions/30037808/multiline-editing-in-vscode – mojave Sep 10 '18 at 22:36
  • For mac in 2019 with jetbrains keyboard settings, Cmd+click works for me. This doesn't make any sense, because https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_multi-cursor-selection says it should be alt click, and that's what it is in jetbrains, but cmd+click what's working for me in Feb 2019. – Myer Feb 26 '19 at 03:09
  • 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 Mar 27 '19 at 15:09
  • The comment from Hoff (May 13 '17 at 11:53) was the only one in this humongous Answer pile that works for me: ALT + SHIFT will let you freely select any code across multiple lines at any position. – Alex Aug 07 '19 at 08:19
  • `Press Alt and click. This works on Windows and Linux*, and it should work on Mac, too.` For mac is `⌘` + click on next line(s) as `Alt` doesn't exist. – Pablo Apr 14 '20 at 07:46
  • Jetbrains products have a shortcut where if I double tap and then hold ctrl, I can then use up and down arrows to add multiple cursors above and below. Seems to not be in vscode, i'm wondering if there's a way to do something similar (it's very hard to live without). – Joel M Dec 21 '22 at 16:52
  • This now seems to be `ctrl`+ click instead of `alt`+ click (on my Windows machine at least). – Monkey Supersonic Feb 27 '23 at 12:25
264

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)

fusion27
  • 2,396
  • 1
  • 25
  • 25
Dave Everitt
  • 17,193
  • 6
  • 67
  • 97
185

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.

Taras Yaremkiv
  • 3,440
  • 7
  • 32
  • 54
  • 2
    I was going nuts on why Ctrl+click wasn't working. Didn't know there was an option to toggle it. :-) – ankush981 Jul 15 '17 at 06: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! – protoEvangelion Jul 15 '17 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 Jul 26 '18 at 03: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 Feb 07 '19 at 09:13
145

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/

kashev
  • 382
  • 2
  • 15
Ivan Ermilov
  • 1,769
  • 1
  • 11
  • 10
  • 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 Aug 21 '16 at 20:14
  • 2
    This works in Ubuntu! – jonan.pineda Feb 25 '17 at 03:56
  • 13
    Use `gsettings set org.cinnamon.desktop.wm.preferences mouse-button-modifier ""` for Linux Mint (Cinnamon). – vossad01 Jun 14 '17 at 23:38
  • Awesome! Works on Ubuntu 16.04. – Bruno Gomes Jan 22 '19 at 13:49
  • 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 Mar 22 '19 at 09:24
  • 1
    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 Mar 22 '19 at 09:37
  • What if I don't want to change the system-wide shortcut (which I'm already used to)? The option "Selection > Switch to CTRL+Click for Multi-Cursor" does not really work, as it then automatically rebinds the "Go to definition" command from CTRL+Click to ALT+Click, which again conflicts with the system shortcut for dragging windows. – Daddy32 May 21 '19 at 16:43
  • In KDE Plasma change "Alt+Left click" setting from "Move" to "Do nothing" in "System Settings"->"Window Management"->"Window Behavior"->"Window Actions" – Igor Sukharev Jun 11 '20 at 03:42
111

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

Note: Tested on Windows.

01F0
  • 1,228
  • 2
  • 19
  • 32
Erivan
  • 1,139
  • 1
  • 7
  • 4
60

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.

Raymond Gan
  • 4,612
  • 3
  • 24
  • 19
34

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

Roberto Salome
  • 341
  • 3
  • 3
33

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

lava-lava
  • 989
  • 9
  • 20
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>"
18

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" }
]
zessx
  • 68,042
  • 28
  • 135
  • 158
intrepion
  • 38,099
  • 4
  • 24
  • 21
16

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.

zessx
  • 68,042
  • 28
  • 135
  • 158
mutex
  • 7,536
  • 8
  • 45
  • 66
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 ;)

HyoJin KIM
  • 402
  • 8
  • 17
9

Alt+Click. It works in Windows.

Details: Visual Studio Code Documentation

zessx
  • 68,042
  • 28
  • 135
  • 158
7

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

zessx
  • 68,042
  • 28
  • 135
  • 158
multiprogramm
  • 95
  • 1
  • 3
7

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.

Yahya
  • 198
  • 1
  • 5
  • 13
  • 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 Mar 08 '21 at 19:14
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.

David Metcalfe
  • 2,237
  • 1
  • 31
  • 44
3

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

gsettings set org.mate.Marco.general mouse-button-modifier "<Super>"
Naoe
  • 1,209
  • 8
  • 12
3

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.

2

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

Gruebes
  • 41
  • 5
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.

-1

On windows:
CTRL+Click if you are using vscode
CTRL+Alt+Click if you are using visual studio

-2

For Ubuntu Users

ALT + SHIFT + ⬇ / ⬆

Abdelrahman Shoman
  • 2,882
  • 7
  • 36
  • 61
-3

Alt + Click works in OSX. Code Version 1.14.2

lickybuay
  • 90
  • 1
  • 7