I am coding in the terminal of VS Code. When I manage to make a line of code that I like, I would like to copy it and paste to the editor. How can I copy the current line from the terminal with keyboard only without using mouse?
Edit1: I am using windows
Press arrow up to get the line of code that you want. Then press CTRL+A to select it and CTRL+C to copy it into clipboard. Paste it with CTRL+V.
Allow users to do copy paste in the integrated terminal using ctrl+c, ctrl+v.
In addition to ctrl + shift + v you can use ctrl + shift + c to Merge-Copy. And ctrl + shift + x to Merge-Cut. Select clipboard to paste ( ctrl + alt + v ). Paste and cycle through clipboard items ( ctrl + shift + v ).
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.
I cannot find a way to comment and uncomment multiple lines of code in Visual Studio Code.
Is it possible to comment and uncomment multiple lines in Visual Studio Code using some shortcut? If yes, how to do it?
Windows: Shift+Alt+A
Linux: Shift+Ctrl+A
Here you can find all the keyboard shortcuts:
Windows VSCode Shortcuts
Linux VSCode Shortcuts
PS: I prefer Ctrl+Shift+/ for toggling block comments because Ctrl+/ is shortcut for toggling line comments so it's naturally easier to remember. To do so, just click on the settings icon in the bottom left of the screen and click 'Keyboard Shortcuts' and find "toggle block...". Then click and enter your desired combination.
First, select the lines you want to comment/uncomment (CTRL+L is convenient to select a few lines)
Then:
To toggle line comments, execute editor.action.commentLine (CTRL+/ on Windows)
or
To add line comments, execute editor.action.addCommentLine (CTRL+K CTRL+C)
To remove line comments, execute editor.action.removeCommentLine (CTRL+K CTRL+U)
or
To toggle a block comment, execute editor.action.blockComment (SHIFT-ALT-A)
See the official doc : Key Bindings for Visual Studio Code
How to comment out multiline / single line in VS Code:
MacOS:
Shift + Option + A:
/* multiline
comment */
CMD + /:
// single line comment
Windows:
Shift + Alt + A:
/* multiline
comment */
CTRL + /:
// single line comment
How to remap / change these shortcuts?
Windows: File > Preferences > Keyboard Shortcuts.
MacOS: Code > Preferences > Keyboard Shortcuts.
You can search through the list both by keybindings (key names) and command names.
Read: How to set shortcuts from another text editor (Sublime, Atom etc)?
Official docs: Key Bindings for Visual Studio Code
The keyboard shortcut to comment multiple in Windows is shift+alt+A.
In my case, Ubuntu, the shortcut is ctrl+shift+A.
You can see all available keybindings on the official documentation.
Here's the relevant bit for osx:
Key Command
⌘K ⌘C Add Line Comment
⌘K ⌘U Remove Line Comment
⌘/ Toggle Line Comment
⇧⌥A Toggle Block Comment
You will need to select the lines you want to comment first, then execute above shortcut, i.e. ⌘/ on osx Ctrl/ on Windows.
In MacOS comment out multi-lines in Visual Studio Code by keyboard shortcut:
Option + Shift + A
/*
...
...
*/
Or,
Select all lines and then press CTRL + /
Try option 1 first. If it doesn't work for you then try option 2 which is the actual shortcut for VS Code:
Option 1. Alt / Option + Shift + A
Option 2. While the text is selected hit Ctrl / Cmd+K and then Ctrl / Cmd+C.
As of now (version 1.16.3), you can check all available keyboard shortcuts by going into
File > Preferences > Keyboard shortcuts. Here you can search for shortcuts related to code comments.
For users who are coming from Sublime Text or likes to have Ctrl+Shift+/, you can make the change from the above mentioned settings panel or simply install the Sublime Text Keymap extension by Microsoft.
Update: As VS Code has become pretty much standard editor for almost everything these days, I would say picking option 1 is always helpful.
For my keyboard layout it's Ctrl + § for:
//
//
//
And Shift + Alt + A for:
/*
...
*/
For me to comment I use:
Ctrl + k, Ctrl + c
and to uncomment:
Ctrl + k, Ctrl + u
I am using ubuntu 18.0.4
To comment multiple line on visual code use
shift+alt+a
To comment single line use
ctrl + /
Select all line you want comments
CTRL + /
Win10 with French / English Keyboard CTRL + / , ctrl+k+u and ctrl+k+l don't work.
Here's how it works:
/* */ SHIFT + ALT + A
// CTRL + É
É key is next to right Shift.
All the key board shorcuts for VS code can be found in the link : Link
Add a Line comment Ctrl+K Ctrl+C
Remove a line comment Ctrl+K Ctrl+U
More shortcut Ctrl+/
On Windows 10 you can use CTRL + } to comment/uncomment on any line or block of code.
CTRL + SHIFT + A for CSS multiline
Ubuntu 16
VSCode Version 1.17.2
For multiline commenting in Python VSCode, all you have to do it just:
Ctrl + /
If you are using VSCode in a linux environment, then you can comment multiple lines by either:
Selecting a block of code => then, press Ctrl + Shift + A (Block commenting)
Or, selecting a block of code => then, press Ctrl + / (Single-line commenting applied to all selected lines)
Hope this helps.
In the new version of VSCODE ( version 1.26.1)
Go to File > preferences > Keyboard Shortcuts
Search for comment Double click the existing shortcut 'keybinding`
And press the new keyboard shortcut in my case ctrl + shfit + /
You can assign any shortcuts you want. Hope it helps.
You can find the shortcut in the Edit menu :
Edit > Toggle Block Comment => Shift-Alt-A
visual studio 2017 we do a: Comment Selection
Ctrl+K, Ctrl+C
press Ctrl+K to get shortcut. press Ctrl+C to confirm
http://visualstudioshortcuts.com/2017/
For doing on mac: CMD + Shift + 7
For me it was ctrl + ' (I am using a swedish layout for the keyboard). Hope that helps anyone.
Select lines which you want to Comment
Then press Ctrl + / to make selected lines comment
And to uncomment:
Select the commented lines you which want to uncomment
First press Ctrl + K then Ctrl + Uto make commented lines uncomment
In windows you need to press ctrl + / in mac you can do ⌘ + / to make multiple comment
// public function index()
// {
// $badgeIcon = BadgeIcon::all();
// return $this->showAll($badgeIcon);
// }
Then if you want to un-comment then select the lines again and then press ctrl + /(in windows) again ⌘ + /(in mac).
If your Ctrl+/ isn't working maybe you need to change it to Ctrl+NumPad_Divide.
1.Select the text, Press Cntl + K, C to comment (Ctr+E+C )
2.Move the cursor to the first line after the delimiter // and before the Code text.
3.Press Alt + Shift and use arrow keys to make selection. ...
4.Once the selection is done, press space bar to enter a single space.
Multi-Line Comment in VS Code
To comment the code select the lines and hit: Alt + Shift + A
To Uncomment select the commented code and hit: Alt + Shift + A
For windows, the default key for multi-line comment is Alt + Shift + A
For windows, the default key for single line comment is Ctrl + /
CTRL + SHIFT + A
For Red Hat,centos
Select item
then CTRL+SHIFT+A
Netbeans has a nice set of keyboard shortcuts, but unfortunately, I can't seem to get all of them to work. Specifically, there's a keyboard shortcut for converting selected text to lowercase: Ctrl+U L. However, no matter how many times I try this (or variations on it), nothing happens I just get a 'ding' sound (it used to be that nothing happened). I check the Keymap option on Netbeans, and it shows that this is still the shortcut mapped to Ctrl+U L:
What am I doing wrong? How can I use this keyboard shortcut?
Note that Ctrl+; or Ctrl+Shift+; works just fine, among many other shortcuts.
To activate this shortcut you have to hit Ctrl+U then release Ctrl and then hit L.
It's like saying Ortomala Lokni
to uppercase a selection, press Ctrl + U then U without Ctrl
Let me add also:
to lowercase a selection, press Ctrl + U then L without Ctrl
to reverse case in the selection, press Ctrl + U then S wthout Ctrl
if you are using mac use command instead of control
Command + U + L to lowercase
Command + U + U to uppercase
In vim, pressing * in command mode performs an automatic search of the word under the cursor. How can I obtain the same in Eclipse?
A combination of two keystrokes:
First, hit Ctrl + Shift + Right Arrow to invoke "Select Enclosing Element". This will select the word under your cursor.
Use Ctrl + K (Cmd + K on OS X) to "find next".
It appears it was not possible in 2004, and it's still not possible, apparently. I'm speechless...
I also need this functionality and created a small plug-in which adds commands for doing this. You can download it and find more details here: http://eclipselabs.org/p/eclipse-tweaks/
Windows 10, tested on Eclipse 2020-03:
Two Steps:
1. Alt + Shift + Up Arrow, to select the word under the cursor
2. Ctrl + K to find the selected word forward
(Ctrl + Shift + K to find the selected word backward)
NOTE:
If you are inside an XML tag, Alt + Shift + Up Arrow will select from the beginning of the tag to the end tag, including all enclosing elements. Try it!
BONUS:
Ctrl + Shift + Down/Up arrows to navigate methods, as sometimes the selected word is a method you want to go to.
Better still,
Ctrl + O - Go to a specific method, by searching (Just enter the first few letters of the method, and Enter)
Cheers
Press Ctrl + k on a Windows machine. On a Mac, Cmd + k should work (seen here).
Not exactly the same, but maybe helpfull if you work with java. In a .java file you can press
CTRL + SHIFT + u
to find occurences in the same source file.
You can also use Shift + Ctrl + K to search next backwards.