Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 929
Mark Avatar asked Aug 08 '16 13:08

Mark


4 Answers

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.
like image 61
Akshay Gaur Avatar answered Oct 16 '22 19:10

Akshay Gaur


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.

like image 40
RaviStrs Avatar answered Oct 16 '22 17:10

RaviStrs


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.

like image 25
AJ Meyghani Avatar answered Oct 16 '22 19:10

AJ Meyghani


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

like image 5
Vishal Prajapati Avatar answered Oct 16 '22 18:10

Vishal Prajapati