问题
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 would be the command I'm looking for? (e.g. editor.action.copyLinesDownAction
)
It's quite confusing, since other selection shortucts like Cmd+A and Cmd+D are the same as in my previous IDE's.
回答1:
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
.
回答2:
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
回答3:
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.
回答4:
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.
回答5:
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:
- Shrink Selection: Shift+Ctrl+Command+← (left arrow)
来源:https://stackoverflow.com/questions/50406964/how-do-i-select-a-single-line-within-visual-studio-code