983

Is it possible to enable multiline editing like in Sublime Text?

For example, press Ctrl to place additional cursor carets and being able to write/delete on multiple places in the document at one time.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
AfBu
  • 9,949
  • 3
  • 13
  • 7
  • 7
    In many mac apps (e.g. TextEdit) I can also Option-drag the mouse to select a box. Is this available in VS Code? – Simon Woodside Apr 05 '17 at 04:15
  • Related post [here](https://stackoverflow.com/q/29953479/465053). – RBT Oct 21 '17 at 03:00
  • 6
    From April 2018 (version 1.23), 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:19
  • 13
    For anyone looking for the name of this command in the keyboard shortcuts section, it's: `editor.action.insertCursorAtEndOfEachLineSelected` – enzoborgfrantz May 13 '19 at 10:54
  • 1
    @enzoborgfrantz +1 Exactly what I was looking for! The selected answer should have first mentioned the relevant editor commands because the keybindings can vary. – pius Aug 01 '19 at 07:25
  • Meanwhile here is a **Keyboard Shortcut Reference** for VS Code in Windows - https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf – Abhinav Kinagi Sep 20 '21 at 10:49
  • 3
    Mac: `OPTION + SHIFT + I` adds a cursor to the end of every line in the selected/highlighted text. Much faster than adding an individual cursor to every line if you have a lot of lines – Vinay Oct 14 '22 at 14:16

34 Answers34

1759

On Windows, you hold Ctrl+Alt while pressing the up or down arrow keys to add cursors.

Mac: ⌥ Opt+⌘ Cmd+/

Linux: Shift+Alt+/

Note that third-party software may interfere with these shortcuts, preventing them from working as intended (particularly Intel's HD Graphics software on Windows; see comments for more details).

If you experience this issue, you can either disable the Intel/other software hotkeys, or modify the VS Code shortcuts (described below).

Press Esc to reset to a single cursor.

Multiline cursors in Visual Studio Code

Or, as Isidor Nikolic points out, you can hold Alt and left click to place cursors arbitrarily.

Arbitrarily placed multiline cursors in Visual Studio Code

You can view and edit keyboard shortcuts via:

File → Preferences → Keyboard Shortcuts

Documentation:

https://code.visualstudio.com/docs/customization/keybindings

Official VS Code Keyboard shortcut cheat sheets:

https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf

Nacimota
  • 22,395
  • 6
  • 42
  • 44
  • 193
    On windows, the first option just flips my screen. :-/ – Kristoffer la Cour Apr 14 '16 at 07:20
  • I've seen videos of folks using this to search for items and edit. How would you search for some text that appears in several places and multiline edit to another value. I've tried using Ctrl+Alt and Ctrl-Alt-F3, but to no avail. – Ed Sinek Aug 12 '16 at 15:54
  • @KristofferlaCour Try using the alt on the other side of the keyboard, I was having the same flip issue when i used ctrl + alt together on the left side, but left ctrl and right alt along with left shift and up/down works. – Dan Oct 20 '16 at 08:58
  • 51
    This is not valid any more. Try `CTRL + SHIFT + UP/DOWN/CLICK` OR `ALT + SHIFT + UP/DOWN/CLICK` – Han Dec 07 '16 at 08:50
  • @Han what do you mean it "is not valid any more"; the shortcuts mentioned in the answer are still the same in the latest version of VSCode and you can see them listed in the official shortcut cheat-sheet for windows located here: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf – Nacimota Dec 07 '16 at 22:57
  • 1
    Don't know why. Mine is Linux version. I never change the keyboard setting. – Han Dec 09 '16 at 04:29
  • 64
    @Nacimota - on a windows 10 machine (just tested now) the combination CTRL+ALT+ARROW will flip the screen, CTRL+ALT+SHIFT+ARROW will create a new cursor. The published list of keyboard shortcuts PDF may be out of date. – Alex C Feb 24 '17 at 15:37
  • 24
    @AlexC the shortcuts are ***not*** out of date; download the latest build and look at the configuration yourself. If you're finding that the shortcuts listed are flipping your screen, I'd wager it's because you have an Intel GPU and are running the Intel software for it which intercepts these shortcuts by default. Open the HD Graphics software and disable or rebind hotkeys if it bothers you, but _do not edit my post to add incorrect information_. The shortcuts listed are accurate, and I am not going to list every piece of 3rd party software that may or may not interfere with them. – Nacimota Feb 25 '17 at 08:26
  • 10
    @Nacimota with all due respect, it was an honest mistake which represents reality for a significant portion of users. There are enough intel machines out there where this might be a default configuration that the additional information was valuable. We both have the goal of providing the best most up to date answer. An additional sentence to enumerate that difference would be helpful. – Alex C Feb 27 '17 at 03:49
  • 3
    @AlexC had same issue, it was the hotkeys for the Intel card causing the problem. – user692942 Mar 28 '17 at 12:03
  • This is so weird, that they decided to use some random shortcuts for column mode. It's been years as it works the same in many editors. Visual Studio or even Notepad++ work the same and it's always been Alt+Shift+Up/Down/Left/Right. In VSCode you cannot even do left/right to make a selection – Pavel P May 21 '17 at 16:09
  • 1
    I had the same screen flipping issue, but I don't think @Nacimota needs to modify the answer. However, to prevent people like me from having to stand on their heads until we find out how to correct the flip, can you please add to the answer that "some 3rd party software may interfere with these shortcuts, see comments"? Again, you don't have to do this, but lot of people will be thankful if you do. Have a +1 for your great answer. – sampathsris Nov 03 '17 at 12:04
  • 2
    On Windows 10 I use ALT + mouse click ==> to create a new insert cursor – Anis Tissaoui Jan 17 '18 at 13:30
  • I don't see a way to perform a multi line delete of all selected elements on mac, did i missed something? – Macilias Feb 19 '18 at 14:40
  • 1
    This has just blown my mind once I edited multiple lines at once! BTW CTRL + ALT + up/down arrows works on Win10. Verified today. Thanks! – iaforek Mar 07 '18 at 16:01
  • doing `CTRL` + `SHIFT` and an arrow key flips the screen on windows pc's, using `ALT` and left clicking where you want the other cursors does the trick – mast3rd3mon Mar 26 '18 at 15:57
  • @mast3rd3mon if you read the answer and previous comments you will learn that the screen flipping is due to third party software, not Windows. – Nacimota Mar 26 '18 at 16:58
  • @Nacimota the claim was that it was probably the intel graphics yet it also does it on amd gpu's and nvidea gpu's. I'm more inclined to say its a feature of windows as i have never known a windows machine _not_ flip the screen – mast3rd3mon Mar 27 '18 at 07:58
  • 2
    @mast3rd3mon well allow me to disprove your statement with a counterexample. I have systems with both AMD and Nvidia GPUs and this shortcut definitely does *not* flip the screen on any of them. Even if it did, I still assert that it would be third party software doing it even if it isn't Intel HD Graphics *specifically*; I simply pointed to the Intel software because it is by far the most common common cause, but not necessarily a unique one. I challenge you - or anyone else - to actually **prove** that this is a Windows feature, rather than just assuming it to be true. – Nacimota Mar 27 '18 at 17:42
  • My AMD cpu with nvidea graphics flipped the screen, my AMD cpu with AMD graphics flips the screen, another pc in my house with an intel cpu and AMD graphics also flips the screen. None use intel graphics and only 1 of the 3 pc configs use intel cpu's but all run Windows – mast3rd3mon Mar 27 '18 at 22:01
  • 2
    @mast3rd3mon, the fact that all those machines run Windows doesn't prove anything except... that they all run Windows. I've already given you examples that *don't* behave that way, so it's really bizarre to me that you still *insist* on saying that it's a Windows shortcut, with no **conclusive** evidence. How do you explain all the people with Windows machines whose screens do not flip, including the developers *from Microsoft* who chose the shortcut in the first place? Can you find the shortcut on this page: https://support.microsoft.com/en-au/help/12445/windows-keyboard-shortcuts ? – Nacimota Mar 28 '18 at 01:18
  • @Nacimota well i am still yet to come across a windows pc that cant flip the screen. So either every machine ive ever used has this "third party software" as you say, or its an underlying feature in windows – mast3rd3mon Mar 28 '18 at 08:03
  • @mast3rd3mon this conversation is going in circles now. If you have any proof *beyond your own personal anecdotes* that it's a Windows shortcut, I'd be happy to admit I'm wrong. In any case, it doesn't really matter because the shortcut is correct for VSCode on Windows which you can verify in both the documentation and default configuration files. There's also a notice about the shortcuts conflicting with other software for some people (whether it's Windows or something else), so there is really nothing in the answer that needs to be modified. – Nacimota Mar 28 '18 at 10:41
  • On Windows (instead of filliping your monitor): 1) upper left corner of desired selection: leftclick 2) lower right corner of desired selection: shift+alt+leftclick See the other answer on this question (https://stackoverflow.com/a/41703355/3100771) – Apriori Apr 08 '18 at 00:14
  • The answer should IMO present the alternative solution ctrl-alt-shift + arrows since it is a very common issue as evident from the comments. Another solution is simply to open the Intel Graphics control panel -> settings -> disable keyboard shortcuts. This also "proves" that Nacimota is right in that this is a Intel issue, not a windows issue. However as I said, I strongly support adding a line with the solution for Intel folks. @Nacimota would you be in favor of such a solution? Splitting the windows solution in two? Maybe also explain that the intel shortcuts can be removed? – Alex Telon Sep 05 '18 at 15:43
  • 1
    @AlexTelon I don't agree that the answer should display `ctrl`+`alt`+`shift` because that's not what the shortcut is and it's not a sensible workaround. The appropriate solution is to either A) disable the hotkeys in the Intel/other software if you don't use them; or B) rebind the shortcut to another sequence in vscode. I may update the answer to make this a little clearer but I'm not writing anything that someone might accidentally read as *"`ctrl`+`alt`+`shift` is the shortcut"* because that is evidently not the case, and it's not a problem that affects all (or even most, afaik) users. – Nacimota Sep 06 '18 at 01:25
  • @Nacimota I approve of your edit. The addition of shift would only "solve" the issue in the short-term. The real solution should be to disable the intel shortcuts if one never uses them anyways or change shortcuts in visual studio. – Alex Telon Sep 06 '18 at 08:16
  • Can you do something like that in VS Community? Multi cursors keeping pressed `Alt` etc.? – Cirelli94 Oct 04 '18 at 07:59
  • On Mac, the most useful option for me is to select the first occurrence of what I want to change, then hit ⌘ Cmd + D to add cursors to the matches below. All of the shortcuts are provided in the Selection Menu. – Stephen Buck Jan 11 '19 at 13:57
  • You can disable the screen rotation on Windows 7 with a right click on the desktop. Select Graphics Options -> Hotkeys -> Disable – Moritz Roessler May 18 '19 at 14:12
  • ctl-alt- up arrow flips my screen – Love and peace - Joe Codeswell Dec 02 '19 at 20:20
  • @Loveandpeace-JoeCodeswell I'm assuming that's why you downvoted, even though your issue is addressed in both the answer and the comments? – Nacimota Dec 03 '19 at 03:41
  • `ctrl`+ `shift`+`alt` + `arrow keys up or down` now does the trick – Ebrahim Karam Feb 07 '20 at 14:24
  • @EbrahimKaram unless you have an official source that the default keybindings have changed, I direct you back to the answer and comments that have already addressed this. – Nacimota Feb 07 '20 at 15:26
  • 2
    click + dragging with middle mouse button also works – Girardi Jul 15 '20 at 17:25
  • This solution won't work if matching words are at different positions over multiple lines, instead @user8202629 solution works in all scenarios – vikramvi Aug 10 '21 at 10:41
255

Solved using just two steps!

  1. Ctrl + F

  2. Alt + Enter

It's equal to Sublime Text's Alt + F3.


Note: For macOS, + F followed by + Enter is equivalent to Sublime Text's + + G.

Enter image description here

mrienstra
  • 508
  • 5
  • 7
119

You can just Alt + click for additional cursors. And as already mentioned, Ctrl + Alt + or .

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Isidor Nikolic
  • 2,659
  • 2
  • 13
  • 11
  • 19
    And you can use Alt+Shift+click to select two lines and every line in between. – Steven Liekens Sep 30 '16 at 13:56
  • 8
    Question is, how to edit its Key Binding (What is `Alt + Click` 's name?) – David Refoua May 15 '17 at 22:06
  • Alt + click automatically defines the word, or moves to the left of the word and does not work for me. – jbodily Oct 14 '19 at 23:07
  • 4
    Found [the answer](https://stackoverflow.com/a/44450888/1454514) to my question, it can either be **Alt** (which is _default_, or **Ctrl / ⌘**. This option can be modified with the `"editor.multiCursorModifier": "ctrlCmd"` key in `settings.json`. – David Refoua May 07 '20 at 07:20
  • If you open the UI settings and search for "multi cursor" the options for this should pop right up – Matt Sanders May 08 '23 at 18:55
97

Box Selecting

Windows: shift + alt + Mouse Left Button

macOS: shift + option + Click

This is contrary to what is mentioned in an answer to Does Visual Studio Code have box select/multi-line edit?.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • I'm not a fan of Shift+Alt+Click (although it works). So to make it work (on Windows) just like in VS, I did this: go to Selection menu, and select Switch to Alt+Click for Multi-Cursor. Now Alt+Click does box selecting. – Kon Jan 07 '20 at 20:37
71

I wanted to select multiple lines and hit "something" to have a cursor for each select lines (similar to Ctrl + Shift + L in Sublime Text). This action in Visual Studio Code is called "Add Cursors to Line Ends".

This was tested in Visual Studio Code 1.77.0 (April 2023) and works on both Windows and Mac.

Here is the way:

  1. Select the lines you want to have multiple cursors.
  2. Simply hit Alt + Shift-I.

You now have one cursor per selected line.

Maxime
  • 8,645
  • 5
  • 50
  • 53
  • 13
    @Manza In VS Code, you it's `ALT-SHIFT-I` (like `i` not `L`). The font doesn't help to see correctly. I use this command multiple times per day on both Mac and Windows and just tested once again with the latest version of VS Code : 1.24.1 and I assure you it works. Maybe you have a plugin causing conflict ? – Maxime Jun 21 '18 at 12:37
  • wow yeah, that do the trick, thank you so much, i was still flipping between sublime becuase of this feature, is the soooo handy – Manza Jun 22 '18 at 01:32
  • for me it's CTRL-SHIFT-L (windows) – specimen Jan 03 '19 at 14:04
  • This is what I was looking for, you can modify it in vs studio settings looking for the "add cursors to line ends" keybindings. – Ivan-San Nov 19 '21 at 17:49
47

Use Ctrl + D to use multi word edit of same words in Windows and Linux.

Use CMD + D for Mac.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • As @Krishnaraj said, Ctrl + D work. Actually both VSCode and Sublime support this. Make sure apply Ctrl + D on all later occurrence without releasing ctrl. Yeah, you still need manually select, it just help you free your mouse. MacOS Command + D – ychz Apr 24 '19 at 02:39
  • And note: Ctrl + D only works for 'Next selection', 'Previous selection' is only accessible via Ctrl + P and then typying: '>Add Selection To Previous Find Match' (of a part of that text!) – gkephorus Aug 11 '21 at 06:24
32

In the latest release of Visual Studio Code, you can now drag the cursor while holding Option (Alt on Windows) to select the same column on multiple rows.

To enable this, make sure you change your editor.multiCursorModifier to look like this:

"editor.multiCursorModifier": "ctrlCmd"

From the Visual Studio Code release notes 1.32.0:

In the following video, the selection begins as a regular selection and then Alt is pressed and held until the mouse button is released:

Example of improved column selection:

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tyler Becks
  • 488
  • 4
  • 9
  • 1
    Thank you, this works. It's funny though how "alt" does not work, by contrast "ctrlCmd" actually makes it work with the ALT-key. *head explodes* – bvdb Jul 10 '20 at 12:53
  • 1
    @tyler-becks how did you make this GIF? – cyrf Nov 21 '20 at 12:30
  • @bvdb I think what's happening is that having Alt as the multi cursor modifier is preventing it working with a drag to do a box select – TheEvilPenguin Nov 26 '20 at 21:26
  • how to open settings JSON in VSC to complete the answer: https://stackoverflow.com/questions/65908987/how-can-i-open-visual-studio-codes-settings-json-file#answer-65909052 – Mahmoud Magdy May 17 '23 at 03:59
28

From the version 1.13 (May 2017) you can finally change the default modifier key for creating multiple cursors (add to settings):

"editor.multiCursorModifier": "ctrlCmd"

P.S.: The modifier "follow link" from this moment will be Alt.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex
  • 59,571
  • 22
  • 137
  • 126
24

Step 1:

Select the word to be replaced.


Step 2:

Use Ctrl + F to select its multiple occurrences.


Step 3:

Use Alt + Enter to set cursor at all the found occurrences.


Step 4:

Just start typing the new word.


Alternatively on Mac:

⌥ Opt + Click to set cursor on the click location.

Shivang Kakkar
  • 421
  • 3
  • 15
Viraj Singh
  • 1,951
  • 1
  • 17
  • 27
21

On Mac it is:

Option + Command while pressing the up or down arrow keys.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kiewic
  • 15,852
  • 13
  • 78
  • 101
20

I am using the vscodevim extension, so I'm not sure if this is a common problem. But, I was having the issue where Ctrl + Alt + UpArrow flipped my screen upside down.

Looking at the Visual Studio Code Basics (I don't know if they changed this in a recent update), it says to use:

Ctrl + Alt + Shift + (Up/down)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrew
  • 300
  • 2
  • 5
  • 2
    Ctrl + Alt + [Arrow Key] is a common keyboard shortcut for screen rotation, certainly with Intel graphics drivers and / or associated software. I imagine it is being intercepted by this before VSCode gets a look in. Recently (and annoyingly, since I used to use it) rotation seems to have been discontinued in an update to the Intel software and is now only available through long-winded menus in Windows. The keyboard shortcut should therefore work in VSCode with more recent drivers. – Bob Sammers Sep 22 '17 at 10:09
16

Working solution for me was first selecting the required text to edit and then using CTRL + F2 to select all matching data in the page. You may also use CTRL+Shift+L as suggested by @lesterCovax

Please Note: The above solution uses the inherent ability of VSCode editor to select similar text across the entire page, and therefore, be careful.

For me the above solution of Ctrl + ALT + Arrowkeys did not work as it caused the screen to change its display orientation against selecting the lines in VSCode.

enter image description here

RICHARD ABRAHAM
  • 2,218
  • 20
  • 26
15

(Windows 10 pro x64) Here have some ways!

  1. Alt + click

  2. Alt + Ctrl + up/down

  3. Keybindings: Ctrl + click (??? it doesn't work!)

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
xgqfrms
  • 10,077
  • 1
  • 69
  • 68
  • http://meta.stackexchange.com/questions/1777/what-html-tags-are-allowed-on-stack-exchange-sites?newreg=f91a052d54e149c28ae5de0372a58ab4 – xgqfrms Dec 04 '16 at 22:29
13
  • To add multiple cursors at any text position This is done by using Ctrl+Click. Firstly you have to enable Multiple-Cursor Modifier. Simply type this option on Command Palette by Ctrl+Shift+P to enable it.

  • To remove a cursor form multiple text position. Do Ctrl+Click on the cursor.

Vega
  • 27,856
  • 27
  • 95
  • 103
ganiular
  • 331
  • 2
  • 8
11

version 1.43 (February 2020)

You can now toggle column selection mode, which changes mouse gestures and arrow keys, via:

  • Menu Bar > Selection > Column Selection Mode
  • Ctrl+Shift+P (Show All Commands) > Toggle Column Selection Mode
  • Bind your key for command "editor.action.toggleColumnSelection"

enter image description here

Note: There is a "Column Selection" panel in the status bar after activation, which you can press to disable it again.

Community
  • 1
  • 1
ford04
  • 66,267
  • 20
  • 199
  • 171
10

As of April 2018 (version 1.23) you can now also use the middle mouse button to multiline select / box select.

Gama11
  • 31,714
  • 9
  • 78
  • 100
JemWritesCode
  • 502
  • 6
  • 17
  • Thanks for that, it is a time save are there an option for key board? like highlight and then ctrl + l in sublime? – Manza Jun 20 '18 at 23:32
  • That's a slightly different feature, but you're probably looking for ctrl+ i. https://code.visualstudio.com/docs/getstarted/keybindings – JemWritesCode Jun 21 '18 at 20:56
8

According to VS Code 1.55.2 version(2021) under User > Commonly Used section there is an option as Multi Cursor Modifier. See below image. enter image description here

for multi cursor default key is alt if you want it can change to Ctrl. Moreover, for suitable places, you can hold the Middle Mouse button and move to down.

Supun Sandaruwan
  • 1,814
  • 19
  • 19
7

In Windows, the below combinations work for me:

  • Ctrl + Shift + Alt + down arrow
  • Ctrl + Shift + Alt + up arrow
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dnyneshwar
  • 728
  • 8
  • 10
7

In addition to all of the answers, there is one more way. Select the lines you want and then press:

  • Windows: Shift + Alt + i
  • Mac: shift + option + i

This puts a cursor in every row in the selection.

Pulkit Agarwal
  • 336
  • 2
  • 7
5

I think it depends on your Visual Studio Code version.

Mine is Linux version Visual Studio Code 1.7.2.

{ "key": "ctrl+shift+up",         "command": "editor.action.insertCursorAbove",
                                     "when": "editorTextFocus" },
{ "key": "shift+alt+up",          "command": "editor.action.insertCursorAbove",
                                     "when": "editorTextFocus" },
{ "key": "ctrl+shift+down",       "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" },
{ "key": "shift+alt+down",        "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" }

The point is the shortcuts are not same in all machines, so you should check your configuration. Go to menu:

Menu FilePreferencesKeyboard Shortcuts

Search for editor.action.insertCursorAbove and editor.action.insertCursorBelow and see your current configurations. You may change them if they conflict with operating system's shortcut keys.

Han
  • 3,272
  • 3
  • 24
  • 39
5

In Visual Studio Code just press Alt and place your cursor to the edit place(where you want to edit) and right click to select.

Robin
  • 4,902
  • 2
  • 27
  • 43
5

(NO MOUSE) For macOS, I found this to be very quick!

  1. CMD + f To search the (word) you want to change.
  2. Option + Enter To select all word you search for.

Just update the first word and it will update all the selected.

Ajay Mahar
  • 81
  • 1
  • 4
3

If you're using Linux, there's a possibility of a conflict with Alt + click, which is the default for "moving a window".

You can go to menu SettingsWindow BehaviorWindow BehaviorActions tab

Just remove Alt + left (hold) and it will work.

This is the best way, because you don't need to hold two + keys to do such a simple task.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Marcelo Agimóvel
  • 1,668
  • 2
  • 20
  • 25
3

I am using the latest version of VS code i.e., 1.46.1 (May 2020) in Windows 10. Just press Alt+mouse left click on the lines you want to select. This will let you select multiple lines at once and let you edit them. Also Press Esc to exit from it. This is really helpful if you're coming from sublime text.

ishan
  • 47
  • 3
  • 10
3

Well, I used the Alt key to select the lines where I wanted to edit, and that's it. Alternatively, we can use the Ctrl + Alt + UP/DOWN arrow if the things to be edited are above or below.

prakhar newatia
  • 169
  • 2
  • 3
2

I am using the Sublime Text keymap and the keybinding provided by the top answer did not seem to work :( Could be some conflicts between Visual Studio Code and sublime keymaps.

The keybinding recommended by @Han works for me (much appreciated!):

  • Enter multiline cursor mode with Ctrl + Shift + Up/Down
  • Exit with Esc

(Sidenote) Below is a small example of using Emmet together with the multiline cursor (enabled and disabled with these key bindings listed above):

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shan Dou
  • 3,088
  • 1
  • 20
  • 18
2

Just Opt + click works for me on Mac

newbie
  • 112
  • 2
2

My settings: Windows 8.1 64 bits, Visual Studio Code version 1.33.1.

Problem: Conflict with keyboard shortcuts of Intel HD Graphics 4000

I had a problem when I was using the default shortcuts of the Visual Studio Code (Ctrl + Alt + UP, Ctrl + Alt + DOWN). In my case, these commands were turning my screen in 0º and 180º respectively. It's happening, because there is the Graphic Intel application installed on my computer. Then, I just disable the shortcuts of this application.

Here is an tutorial to help someone.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rui M.
  • 31
  • 3
2

On windows, you can create additional cursor on the next/previous lines by pressing:

Ctrl + Alt + Shift +Down/Up

Missing the Shift will flip your screen.

Creating additional cursors will allow you to edit multiple lines at once.

Mohammed Noureldin
  • 14,913
  • 17
  • 70
  • 99
1

The solution from @maxime of using SHIFT + ALT + i worked for me, when I needed to quickly edit ~20k lines in a file. Most of the other keyboard shortcuts mentioned are only useful for a limited number of line. SHIFT selecting the area you want to column edit, then pressing SHIFT + ALT + i is the most efficient way to handle this.

What I accidentally discovered though, (and hasn't been mentioned here yet) is that there is a limit of 10k lines in "cursor edit mode" (there's an open Github feature request to increase it). This means that for extremely large files, it may be better to script your edits, rather than doing it manually.

For those like @specimen that had to use shortcuts like CTRL + SHIFT + L (default binding is Select all occurrences of current selection) to accomplish this, you should check that you don't have a keymap extension installed. You can check by searching for @recommended:keymaps in the extensions pane, going to File > Preferences > Keymaps (CTRL+K CTRL+M).

The default [Windows] keymap can be found in PDF form HERE, or you can go to File > Preferences > Keyboard Shortcuts to find/modify the current bindings. There is also more in-depth key bindings documentation HERE.

1

For me Alt + Middle Click (scroll wheel) worked fine You have to click on Alt then long click on Middle Click then scroll Up or down

anouar es-sayid
  • 355
  • 5
  • 11
1

On Windows..

  1. Select one line you want to change everywhere. (with the mouse cursor)
  2. Press CTRL + F2 and you will start editing all lines at once.
Radim Šafrán
  • 463
  • 7
  • 16
1

Simple Answer:

  1. Install Multi Line tricks extension for Visual Studio Code
  2. Select the lines and press Alt+Shift+L (Windows/Linux) or Option+Shift+L (Mac)
Akif
  • 6,018
  • 3
  • 41
  • 44
0

On Linux Fedora (I tried with Fedora 31) with KDE, go to:

  1. System Settings
  2. Window Management
  3. Window Behavior
  4. Window Actions
  5. Inner Window, Titlebar and Frame Actions
  6. Click Left Click Box
  7. Pick Do nothing (replacing move/drag)

Now you can select multiple lines with Alt + Left Click!

kintsukuroi
  • 1,332
  • 16
  • 15