Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting block of code in Visual Studio Code

Is there a keyboard shortcut or an extension that would allow me to select a block of code?

I'd like to select everything between curly braces, between HTML tags, etc.

like image 638
Devin Avatar asked Jul 06 '17 18:07

Devin


People also ask

How do you select a section of code?

Double-click on Select to Bracket and press a Keyboard shortcut you like, for example Command + Shift + H . Now, whenever you want to select code in a block, put your cursor inside the block and press your shortcut.


2 Answers

Use Alt + Shift + to expand the selection between braces or tags.

Use Alt + Shift + to shrink the selection between braces or tags.

Here is the Microsoft Visual C++ shortcuts cheatsheet that might help you.

Update 2019/3: this inner functionality of Visual Studio is not working very well after some updates. Alt + Shift + now selects things including braces (which annoys me).

It is not like its behavior before. It selected things between curly braces, when I first posted this answer. I'm using Mark's answer now.

If anyone has a better solution (without an extension) now, please leave a comment.

like image 161
SkuraZZ Avatar answered Sep 28 '22 22:09

SkuraZZ


On Mac Ctrl + Shift + to expand the selection. Press multiple times to expand to the block.

like image 37
Anh Tran Avatar answered Sep 28 '22 22:09

Anh Tran