Elias Zamaria
Elias Zamaria

Reputation: 101183

How to select whole line in VSCode

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

Answers (10)

pathrik3e
pathrik3e

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

Qui-Gon Jinn
Qui-Gon Jinn

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

Armando Kun
Armando Kun

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

Mahmoud Kadoum
Mahmoud Kadoum

Reputation: 219

  1. Triple click at any point on the line
  2. Click once on number of the line
  3. Press Command + L

Upvotes: 21

electricalbah
electricalbah

Reputation: 2297

Tripple click at any point on the line

Upvotes: 1

Elias Zamaria
Elias Zamaria

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

Alex Quast
Alex Quast

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

Kipruto
Kipruto

Reputation: 857

just triple click the end of the line it will select the entire line

Upvotes: 18

Thinh NV
Thinh NV

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

jabacchetta
jabacchetta

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

Related Questions