Select everything between matching brackets in VS Code

Place the cursor inside the bracket (not directly next to a bracket) and execute editor.action.smartSelect.grow until everything inside the bracket is selected. The default shortcut is Shift+Alt+Right (or Ctrl+Shift+Right on Mac).

You can shrink the selection with editor.action.smartSelect.shrink which has the default shortcut Shift+Alt+Left (or Ctrl+Shift+Left on Mac).


I still think the expand region extension is the way to go on this. But vscode 1.20 did add the "Select to Bracket" command (see command palette). It has no default keybinding but the command is

editor.action.selectToBracket

so you can assign your own binding. But it is not as handy as the extension. The smartSelect options mentioned above give me unexpected/unwanted results.

---------- Update ---------------

editor.action.smartSelect.expand command was added at some point after the answers here.

Bound to Shift+Alt+RightArrow. Will progressively expand the selection including to within and not including the brackets, parentheses if you wish. You will need to keep triggering the RightArrow to get to where you want. Will not select only within the brackets if you start right next to a bracket - start anywhere else and it will.


I suggest to remap those keys to another key, this key combination is popular, sometimes it doesn't work because of the conflict with other apps.

Open the key binding setting, type the smartselect to find this setting, grow is expand the selection from the cursor current position to the nearest bracket, press multiple times if you want to expand or shrink to the next bracket.

enter image description here

enter image description here