Mark
Mark

Reputation: 29139

How do you select a range of lines in Visual Studio Code?

How do you select a range of lines (from a start line number to an end line number) in Visual Studio Code?

Upvotes: 47

Views: 58322

Answers (5)

slim
slim

Reputation: 1

Hi y'all I found a really fun way to do it. Ctrl-= will select to the last go back.

Upvotes: -1

Akshay Gaur
Akshay Gaur

Reputation: 2525

I had to delete lines starting from line number 17158 through 1644546 which was nearly impossible to do if I used scrolling. So I followed 4 simple steps:

  1. Go the line where you want to start deleting (17158 in my case).
  2. Using keyboard, press Ctrl+G which opens a box to enter the line number to go to.
  3. Enter the line number in the box (1644546 in my case). VS Code will take you to the line you wanted to go to.
  4. Hold the shift key and click on the line. Hopefully, this should select all the lines that you wanted to delete.

Upvotes: 74

AJ Meyghani
AJ Meyghani

Reputation: 4609

Since version 1.46 it seems like you can set an anchor and select from anchor to cursor: https://code.visualstudio.com/updates/v1_46#_accessibility

  • First set a selection anchor (default binding Ctrl+K Ctrl+B)
  • Then go to the line that you want, either by mouse or by Go To Line command
  • Then Select From Anchor to Cursor (default binding Ctrl+K Ctrl+K)

To cancel selection hit esc.

Upvotes: 60

Vishal Prajapati
Vishal Prajapati

Reputation: 598

Try this out... Type #region at the start of the line which you want to select and #endregion at the end of the line and collapse it using the side ruler available in VS code .Now since it will in a single region you can select the region easily

Upvotes: 6

RaviStrs
RaviStrs

Reputation: 634

Click at the first column of the first line. Then scroll down to the last line that you want to select, HOLD Shift key and click on the last line.

Upvotes: 38

Related Questions