Using Microsoft\'s Visual Studio Code, how do I select a single line of code? (equivalent to Atom\'s or other IDE\'s Cmd+L on Mac)
And what wo
I googled the same question but with the need to delete an entire line in a single keystroke. If you are in the same boat, the shortcut to delete the current line is Ctrl+Shift+k
It's Cmd+I by default in VS Code versions prior to 1.32.
Starting from version 1.32 it's Cmd+L.
You could change it in Keyboard Shortcuts by searching for expandLineSelection
.
As for me, I noticed that what was causing the issue was that there were similar keyboard shortcuts. As a result, what fixed it was deleting the similar keys.
So when I tried to use ⌘ + L I noticed that there was this thing in the left corner.
Picture that says it is awaiting an actual command:
So what I did was simply delete the commands in the keyboard shortcut (i.e. ⌘ + K ⌘ + S) that were similar. They ended up being shortcuts for the live server extension.
You can see which ones are similar by typing cmd + L in the search bar for the keyboard shortcut. Any command that starts with ⌘ + L will take precedence over the single one that just uses ⌘ + L hence the reason it didn't work for me.
Keyboard shortcut search of cmd + l:
Hope this helps anyone that may need clarification on this!
For VS Code 1.36 release, use CTRL-L to select the whole line, then, press TAB key to increase indent, or SHIFT-TAB to decrease indent.
There are options to select an entire line or just the contents of a line as follows (Mac mappings):
Select Entire Line:Command+L
Select Contents of Line: Place Cursor in line content then Shift+Ctrl+Command+→ (press right arrow twice)
If you want to assign your own keyboard shortcuts, in your shortcut preferences look for:
Entire Line: expandLineSelection
Select Contents of Line: editor.action.smartSelect.expand
(You can get to your Keyboard shortcuts by pressing Command+k, Command+s)
As a bonus there's also a command to Shrink the Selection:
Go to Preferences → Keyboard Shortcuts
Search for "expandLineSelection
"
Change Keybinding to any key you wish.
If you want to use command+L as default, just change it back.