Gergő Horváth
Gergő Horváth

Reputation: 3705

VSCode shortcut to select the block of code between two brackets/parentheses?

I'm looking for a keyboard shortcut which selects the block of code between two parentheses or brackets or squarebrackets compared to the cursor position.

Example:

const object = {
  ifTheCursorIs: 'anywhere between the bracket above',
  andTheBracketBelow: 'it should select all everything between them',
}

//so if I press the shortcut, then press backspace,
const object = {}
//should remain

Upvotes: 1

Views: 4272

Answers (2)

Shahriar Ahmed
Shahriar Ahmed

Reputation: 625

You can use vim plugin in vscode. Then you can use vi(, vi{, vi[ to select the content in encapsulating first, second and third bracket accordingly. You can also use yi(, yi{, yi[ to copy and ci(, ci{, ci[ to cut the content in encapsulating first, second and third bracket accordingly.

Upvotes: 1

Emma
Emma

Reputation: 834

I think this post is what you're looking for: https://stackoverflow.com/a/50036560/7351272

For mac users, the short answer is:

Use ctrl + shift + to expand selection between braces or tags,

Use ctrl + shift + to shrink selection between braces or tags.

Upvotes: 4

Related Questions