Reputation: 101183
I am using VSCode on a Mac.
Does anyone know how to select the entire line that the cursor is on? I know about Command+I, but that only selects what appears to be the whole line, which is not always the whole line if I have word wrap enabled.
I am looking for something like Sublime Text's "Expand Selection to Line" command.
Upvotes: 23
Views: 74134
Reputation: 1
I know its old but for anyone seeking, you can press Alt + arrow up/down to duplicate your cursor to other lines and then without selecting anything copy and paste multiple lines.
Upvotes: 0
Reputation: 4408
Ctrl + L
on Windows or Command + L
on Mac to select the whole line in VS Code.
You can use your mouse to select the whole line by triple-clicking on the line
but the better way is to click on the line number
to select the whole line or multiple lines.
Upvotes: 7
Reputation: 11
In case you're wondering why Cmd+L is not working, there might be a chance that there are duplicate shortcuts. You can find out by opening Keyboard Shortcuts in VSC and remove the one that's not needed.
Upvotes: 1
Reputation: 219
Upvotes: 21
Reputation: 101183
Now, when I press Command+I, the whole line is selected. I am guessing this was caused by an update to VS Code, but I am not sure.
Upvotes: 2
Reputation: 41
An alternative to what people have posted is, when your cursor is at the start/end of the line, you can hit shift + end/home respectively.
I find this useful for wrapping a line in curly braces/quotes/etc. whereas the other answers include spaces in the select so whatever you're wrapping it in will be wrapped around that whitespace.
Upvotes: 4
Reputation: 857
just triple click the end of the line it will select the entire line
Upvotes: 18
Reputation: 3862
All you need to do is put the cursor anywhere on the line, do not make any selection at all and then do the desired command (Cut, copy, or paste).
When no text selected, VS Code will automatically select the entire line.
Upvotes: 55
Reputation: 50238
Install the MetaGo extension and use the "metaGo: selectLineDown" command, which will come installed already overriding the "expandLineSelection" command.
This extension has many additional commands that you'll likely find useful as well, including moving up/down over code blocks, centering the active line, and going to any character on the screen.
Upvotes: 2