Is there in VS Code a shortcut available which selects all code between matching brackets? E.g. in Atom, this shortcut is ctrl+alt+m
.
Ctrl+D selects the word at the cursor, or the next occurrence of the current selection. Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.
Alt+Enter --> Select all matches. Left arrow --> Ajust cursors.
Put your cursor before or after the brace (your choice) and then press CTRL + ] . It works with parentheses ( ), brackets [ ] and braces { }. From now on you don't need to play Where's Waldo? to find that brace. With the above shortcut, you can also hold SHIFT to select.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With