How can you create multiple cursors in Visual Studio Code - visual-studio-code

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

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.

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)

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.
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.

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/

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

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.

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

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

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>"

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" }
]

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.

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 ;)

Alt+Click. It works in Windows.
Details: Visual Studio Code Documentation

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.

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

You can do the following per the Selection menu:
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.

Same issue on Ubuntu-MATE, but here you resolve it by:
gsettings set org.mate.Marco.general mouse-button-modifier "<Super>"

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

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.
Now you can use super instead of alt. Wallah!! Go make multiple cursors by alt + click.

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.

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

For Ubuntu Users
ALT + SHIFT + ⬇ / ⬆

Alt + Click works in OSX. Code Version 1.14.2

Related

Is there any keyboard shortcut to select/copy the auto highlighted text in VS Code?

When I place my cursor at any position inside a text like the string in this photo, vs code automatically mildly highlights the entire string. Is there any shortcut key for selecting and copying this entire text highlighted by vs code?
Example: String being mildly highlighted by vs code How to select/copy this with a keyboard shortcut?
Update:
Added gif to show the highlighting - gif showing the highlighting
There's not a single, builtin keyboard shortcut for the behavior you described, but you can use a combination of two to achieve the result you want:
The first is called "Expand Selection" in the VS Code app, and the online keybindings documentation describes it as "Expand AST Selection" (editor.action.smartSelect.expand). The default platform keybindings for this are:
linux: shift + alt + right
mac: shift + ctrl + cmd + right
win: shift + alt + right
If the highlighted string is one word, it will require one use, and if the string is multi-word, it will require two uses.
After that, the selection will be complete, and you can simply copy (cmd/ctrl + c).
Demo:
If in a string, triggering the command editor.action.smartSelect.grow a couple of times should select that entire string. And then you can copy the normal way Ctrl+C.
That command is unbound by default. You can assign a keybinding to it in the Keyboard Shortcuts editor by searching for smartSelect and click on the little pencil icon next to the command.

Select all occurrences of selected word in VSCode

Are there any trick or extension to select all instances of selected word in visual studio code, to facilitate editing or deleting those instances without search and replace, like ِAlt+F3 in sublime text
Select All Occurrences of Find Match editor.action.selectHighlights.
Ctrl+Shift+L
Cmd+Shift+L or Cmd+Ctrl+G on Mac
According to Key Bindings for Visual Studio Code there's:
Ctrl+Shift+L to select all occurrences of current selection
and
Ctrl+F2 to select all occurrences of current word
You can view the currently active keyboard shortcuts in VS Code in the Command Palette (View -> Command Palette) or in the Keyboard Shortcuts editor (File > Preferences > Keyboard Shortcuts).
What if you want to select just a few?
No problem, first:
Ctrl+F find the letters by typing them
ESC to quit searching
(you need to do this even when using
Ctrl+Shift+L
to select all occurences)
OR
just select those letters with your mouse or keyboard
(Shift+arrows)
Now that the mouse cursor is blinking on your first selection,
using a few more Key Bindings (thanks for the ref j08691)
you may:
Ctrl+D select (add) the next occurrence
Ctrl+K+Ctrl+D skip
the current/latest occurrence and add the next occurrence
Ctrl+U undo the latest cursor operation
on Mac:
select all matches: Command + Shift + L
but if you just want to select another match up coming next: Command + D
If you want to do one by one then this is what you can do:
Select a word
Press ctrl + d (in windows).
This will help to select words one by one.
On Ubuntu:
Ctrl + F2 will select all occurrences immediately.
Ctrl + D will select occurrences one by one.
In my MacOS case for some reason Cmd+Shift+L is not working while pressing the short cut on the keyboard (although it work just fine while clicking on this option in menu: Selection -> Select All Occurences). So for me pressing Cmd+FN+F2 did the trick (FN is for enabling "F2" obviously).
Btw, if you forget this shortcut just do right-click on the selection and see "Change All Occurrences" option
Ctrl+Shift+L to select all occurrences of current selection.
Several options have been listed, but a couple are missing. Its possible to use the rename and refactoring tools, for not just selecting all, but making specific changes, after everything has been selected. I am going to try and bundle all answers I feel are relevant together, and add two more that, not only get the job done, but are really great tools for making single changes over multiple occurrences of the same code.
1. Select All Matches
To use multiple cursors to select all matches, you can use 1 of 2 keybindings. Both keybindings preform the same functionality, so in other words, 2 keybindings, 1 vscode command. The keybindings are as follows.
1. CTRL + F2
2. CTRL + SHIFT + L
Default Keybinding
{
"key": "ctrl+f2",
"command": "editor.action.changeAll",
"when": "editorTextFocus && !editorReadonly"
}
// You can view/customize VSCode keybindings by pressing F1 and typing Keybindings
2. Select Next Match
You can Select Next Match by using the keybinding below. This is good for selecting all occurrences within a specific vicinity.
CTRL + D
Default Keybinding
{
"key": "ctrl+d",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
}
SIDE NOTE
If you press the keybinding CTRL + K before pressing CTRL + D, instead of selecting the next instance, it will move you to the next instance, and target it with your cursor.
Default Keybinding
3. Rename
This one hasn't been mentioned yet, but this one is what you would except when doing a refactor in a traditional IDE, like Visual Studio 2022, or JetBrains: IntelliJ.
When you use this keybinding, it attempts to solve some of the problems that are incurred when using the other options listed above. The other options are overly greedy sometimes, and select parts of words that you didn't want to select, and if your not careful, you can delete quite a bit of code, resulting in messy situation. If you didn't notice that you screwed up right away, you end up saving, or working for a long while before having to reset everything, and you end up loosing a lot of work & time.
F2 attempts to solve this problem by implementing logic under the hood (IDK if its an algorithm or what it is) but it feels very much like refactor in Visual Studio. It only selects specific cases that you would want to target. So if a varable is named foo, is won't select foo from a var named fooFoo. It also won't select foo from a comment.
F2
{
"key": "f2",
"command": "editor.action.rename",
"when": "editorHasRenameProvider && editorTextFocus && !editorReadonly"
}
4. Find
This one I will keep short and sweet, but find will iterate through ever occurrence of a pattern that you type into the editor-widget.
Press CTRL + F then type what you want to select. Keep pressing ENTER until you find it.
5. The Best For Last
There is not one method for selecting all occurrences that is the best every time, that's why there are several different methods for doing it, however, there are some methods that are generally more useful than others. This feature, as far as I know, is unique to VS Code, and I use it all the time when working with large JSON files, and Large Code Bases (like an Open Source PR).
VS Code has its own search editor, its a special editor. You can open the search editor by pressing on the Magnifying Glass Icon on the Activity-bar. Type into the search editors side bar text-input what it is you want to select, then press ENTER. It will return all the results in the sidebar. You can use the lower text input, to replace all of the results with what ever you like. You can also click OPEN IN THE EDITOR (it looks like a link) and it will reproduce everything you searched for in a new document, that is opened to the side. From there you can manipulate it, and add it back to the document. I've already written enough for one answer, so I am not going to go to deep into every thing it can do, but this not only selects everything, it also extracts it, replaces it, lets you nit-pick exactly what it means to select "all" of a specific occurrence. It's a great tool for making a single change in a recursive fashion.
This seems an old question, but it worth an answer.
There is - besides the accepted answer - a fancy shortcut to do this, just select the desired word and press Ctrl + D as many times as desired, each press will select an exact occurrence in the editor, after all occurrences are selected, just type the replacement and all the occurrences will be replaced as you type.
Ctrl + F2 works for me in Windows 10.
Ctrl + Shift + L starts performance logging
I needed to extract all the matched search lines (using regex) in a file
Ctrl+F Open find. Select regex icon and enter search pattern
(optional) Enable select highlights by opening settings and search for selectHighlights (Ctrl+,, selectHighlights)
Ctrl+L Select all search items
Ctrl+C Copy all selected lines
Ctrl+N Open new document
Ctrl+V Paste all searched lines.
I had another application, called Loom, running in the background on my Mac which was taking over my keyboard bindings.
Cmd+Shift+L
It was just random that I figured out it was preventing the keyboard bindings from reaching VS Code. I tried to turn off applications that I had open one by one. Not the best approach, but it worked.
Additionally to unselect use
Cntrl + U

How to select current word in Visual Studio Code (VS Code)?

How to select the current word, that is where the caret is at.
Note: I am looking for the shortcut for Visual Studio Code(VS Code), the text editor, and not Visual Studio IDE.
On Mac OS: Cmd+D
On Windows & Linux: Ctrl+D
Above solved the purpose for me.
But ⌘D is defined as "editor.action.addSelectionToNextFindMatch", so if you press it more than once, it will try to search and select same word in the file which then can be used to do "multi word editing".
You are looking for Shrink/Expand Selection.
Trigger it with Shift+ Alt+Left and Shift + Alt+Right
Update:
This is now called Smart select API.
This feature uses semantic knowledge to intelligently expand selections for expressions, types, statements, classes, and imports.
It is Ctrl + D that works for me in latest Visual Studio Code on Windows.
Go to File -> Preferences -> Keyboard shortcuts, you will find this:
If you want to ctrl+w to behave the same as in Idea just go keyboard settings
Search for Expand selection. Set new shortcut cmd+w or ctrl+w depending on your OS.
Also re-bind other commands that use ctrl+w to use another shortcut that you want, for example cmd+f4
You can edit keybindings.json to avoid using UI.
Shift + Alt+Right Arrow if the word is in camelCase then you will have to click Right Arrow again to select the whole camelCase. Every time you press Right Arrow again while still holding Shift + Alt down you will select a further part of the code.
so:
first the word.
then if it's part of a camelCase then the camelCase.
then if it is in a string the whole string.
... (many other posibilities)
the whole line.
everything inside the parentheses code block
the whole file
at any given time you can go back to the last selection by clicking Left Arrow instead of Right Arrow
I don't know about CTRL + w in the old Visual Studio Code but in the JetBrains IDE's this is the equivalent to CTRL + w by holding down CTRL and clicking w to select more and holding down CTRL + Shift and clicking w to unselect.
Another possibility which helps to avoid selecting only one word in camelCase is CTRL + d this will just select the whole camelCase. This will however have the side-effect of also changing the current "find" criteria.
thanks Chandan Nayak for this extra shortcut.
An unpopular opinion: you can now have Resharper keybindings, if you come from Jetbrain's camp.
The Ctrl+W expansion grow and shrinks is different from expansion selection.
On "File/Preferences/Keyboard Shortcuts" I deleted the shortcut "Ctrl + W" to close the current tab action, because for this "Ctrl+F4" works for me.
Update (14 days later): Yesterday I installed VSCode 1.34.0 - I think since then the functionality is "Ctrl + D". I was very suprised.
For any editor, you can use the below shortcuts. These shortcuts work for every text area also.
Ctrl + Shift + LeftArrow/RightArrow - this will select text word by word
Shift + UpArrow/DownArrow - this will select text line by line
Ctrl + BackSpace - this will delete text word by word
Additional
in intellijIdea
Ctrl + w - use for the select current word, after giving second Ctrl + W it will select the second word also. Like that you can select the whole line.
Ctrl + d - you can duplicate current line.

Multiline editing in Visual Studio Code

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.
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.
Or, as Isidor Nikolic points out, you can hold Alt and left click to place cursors arbitrarily.
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
Solved using just two steps!
Ctrl + F
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.
You can just Alt + click for additional cursors. And as already mentioned, Ctrl + Alt + ↑ or ↓.
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?.
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.51.1 and works on both Windows and Mac.
Here is the way:
Select the lines you want to have multiple cursors.
Simply hit Alt + Shift-I.
You now have one cursor per selected line.
Use Ctrl + D to use multi word edit of same words in Windows and Linux.
Use CMD + D for Mac.
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:
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.
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.
On Mac it is:
Option + Command while pressing the up ↑ or down ↓ arrow keys.
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)
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.
(Windows 10 pro x64) Here have some ways!
Alt + click
Alt + Ctrl + up/down
Keybindings: Ctrl + click (??? it doesn't work!)
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.
As of April 2018 (version 1.23) you can now also use the middle mouse button to multiline select / box select.
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"
Note: There is a "Column Selection" panel in the status bar after activation, which you can press to disable it again.
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.
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.
In Windows, the below combinations work for me:
Ctrl + Shift + Alt + down arrow
Ctrl + Shift + Alt + up arrow
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.
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.
(NO MOUSE) For macOS, I found this to be very quick!
CMD + f To search the (word) you want to change.
Option + Enter To select all word you search for.
Just update the first word and it will update all the selected.
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 File → Preferences → Keyboard 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.
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 Settings → Window Behavior → Window Behavior → Actions 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.
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.
Just Opt + click works for me on Mac
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.
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):
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.
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.
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.

How to navigate to the last cursor position in Eclipse?

Recently, I switched from Visual Studio to Eclipse. Now I am missing the shortcut for navigating to the last cursor position in Eclipse. In Visual Studio, the same can be done with the help of the Ctrl + - shortcut.
How do I do this in Eclipse?
Go to Preferences / General / Keys. You'll be able to see or edit the bindings for:
Backward History: default is Alt←
Forward History: default is Alt→
You may also use those shortcuts (and see the key bindings) in the toolbar:
There is Altleft arrow and Altright arrow to navigate to previous/next cursor positions, and CtrlQ to go to the last edited position.
I'm adding an answer, because I'm not allowed to comment yet. Though the dystroy's answer contains information about useful shortcuts, I'm not satisfied with it, because the mentioned Alt+left shortcut doesn't always navigate to the last cursor position (e.g. in the same file). I'm not sure how it works in Visual Studio, but in IntelliJ a similar shortcut always moved the cursor to the last cursor position, even in the same file. I would like to have such functionality also in Eclipse. For example: I move the cursor using the keyboard's down arrow key successively on lines 10, 20, 30. Now I am on line 30 and when I press Alt+left I would like the cursor to go to the line 20. After pressing Alt+left again I would like the cursor to go to line 10.
In Eclipse, when the cursor was in file A and I opened file B and moved the cursor down a few lines in file B, then Alt+left will move the cursor to the file A, instead of moving it to a previous cursor position in file B.
I created a separate question for this problem:
How to navigate to the last cursor position in Eclipse if it is in the same file and was not edited?
In Mac (OSX), the commands are ⌘[ and ⌘]. They are very convenient navigation commands when coding.