VsCode has Block select ? (similar SQL Studio Alt + Shift + ArrowDown) - visual-studio-code

In VsCode I can not find the keys to create vertical selection (or block selection), like SQL Studio has when press Alt+Shift+ArrowDown.
I would like to use the Alt+Shift+ArrowDown in VsCode Editor.

Related

Is there shortcut in DBeaver to cut line without selecting it like that of SQL management studio with ctrl+x indide query editor?

Is there shortcut in DBeaver to cut line without selecting it like that of SQL management studio with ctrl+x.
I mean if we want to cut whole line without selecting than how we can achieve it in DBeaver. in SQL management studio we do it with ctrl + x pressing in query editor.
Use the ctrl + space in and it will work somehow similar to ctrl + x in MSSQL.
more shortcuts you can check here
https://defkey.com/dbeaver-shortcuts

Visual Studio Code: duplicate a line shortcut

I am new to Visual Studio Code. I want to know how to duplicate a line using a keyboard shortcut.
Please help.
Thanks
In Visual Studio Code you can perform the "Copy line down/up" action. The keyboard shortcut varies depending on your operating system.
The defaults for each os are as follows.
Windows
Shift + Alt + Up/Down
Macos
Shift + Option + Up/Down
Linux
Ctrl + Alt + Shift + Up/Down
Note: This shortcut will also copy multi-line selections up and down as in Sublime but when a subset of a line is selected the entire line is copied.

How to Move a Line Up or Down in Visual Studio Code for Mac

I'm familiar with how to move a line up or down in other editors, like Atom and Sublime.
How is this done in Visual Studio Code for Mac?
In Visual Studio Code for Mac...
To move a line UP: ⌥+↑ (alt + up arrow key)
To move a line DOWN: ⌥+↓ (alt + down arrow key)
See here for a reference on Basic Editing Key Bindings in Visual Studio Code.
For Windows:
To move a line UP: Alt + ↑ (alt + up arrow key)
To move a line DOWN: Alt + ↓ (alt + down arrow key)
In Visual Studio Code for Mac for me it is:
To move a line UP: ⌥+shift+↑ (alt + shift + up arrow keys)
To move a line DOWN: ⌥+shift+↓ (alt + shift + arrow down keys)
I do have IntelliJ IDEA Keybindings installed.
You can find the corresponding commands in the Selection menu (Move Line Up and Move Line Down) together with currently set short-cuts.
Additionally, if you launch the command palette (View/ Command Palette) while you have an open document you also find them there (type "move" or "line").
If you are looking for Visual Studio (2019) on Windows and found yourself here, the default keyboard shortcut is the same as for Visual Studio Code as shown by #tapu74.
Move line up = Alt + Up
Move line down = Alt + Down
To change the shortcuts, say to match Notepad++ where the shortcut is Ctrl + Shift + Arrow:
Tools > Options > Environment > Keyboard
In Show commands containing enter Edit.MoveSelected
Change Edit.MoveSelectedLinesUp or Edit.MoveSelectedLinesDown as required
FOR VS CODE MAC:
opt + UP, opt + DOWN
I was trying to move the selected lines down but couldn't move it. I can easily move the line up. Then I realised that I needed to create more lines downwards as I was trying to move the code to undefined area. First create some lines by pressing enter.

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.