Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cursor on multiple lines in VS code

I often use Alt + Shift + arrow to have the cursor on multiple lines in SSMS and e.g. ISE for PowerShell. But when I do this in Visual Studio Code or Azure Data Studio the functionality is different and the line gets duplicated.

How can I have this multiple cursors in Visual Studio Code?

like image 667
xhr489 Avatar asked Nov 17 '25 03:11

xhr489


2 Answers

The following ways are available:

  • Click on a place with Alt/Cmd pressed to add a cursor there.
  • Type Ctrl+Alt+Up/Down to place a cursor in the same spot in the previous/next line.
  • Select multiple areas at once by dragging while pressing with the middle button (pressing down the scrolling wheel)

In most other IDEs the same shortcuts are available with Ctrl/Cmd instead of Alt. You can change it by adding "editor.multiCursorModifier": "ctrlCmd" to your settings.

The shortcut you are attempting is actually used for line manupulation, also very handy:

  • Alt+Up/Down to move the current line up or down. This is very useful for sorting lines.
  • Shift+Alt+Up/Down will copy the current line up or down, and move your cursor with it. Also very useful when combined with comment toggle, in case you want to comment a line and modify a copy of it.

As a general advice, you can open the command palette and just type what you are trying to do, it will show the shortcut at its right. For instance, opening it (with Shift+Ctrl/Cmd+P) and typing shortcut reference will offer you the option to open the list of all available shortcuts.

like image 52
Juan C. Roldán Avatar answered Nov 18 '25 19:11

Juan C. Roldán


Both of the below will work, which one I use depends on the use case.

Alt + Click

Ctrl + Alt + Arrow

Additionally a helpful list of default hotkeys for vsc

like image 45
Liam Sampson Avatar answered Nov 18 '25 21:11

Liam Sampson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!