I know there is a shortcut for cmd + shift + \
to go to matching bracket
this is also documented here https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
But this only works when the cursor is at the opening bracket and you want to jump at closing bracket. So its not really matching...its actually closing.
But if you have a class like
object Foo {
....
}
and you take the cursor to the closing bracket and now you press cmd + shift + \
then vscode does nothing.
So it only works from opening to closing .... but how to go from closing to opening?
Similarly, when you take the cursor to the opening bracket, visual studio code will highlight the closing bracket. but if you take the cursor to the closing bracket, vscode will do nothing. now it will not highlight the opening bracket.
How can I have it both ways.
Go to matching brace in Visual Studio with Ctrl+} shortcut To move the caret to the matching brace of the one it's currently on press Ctrl+}. This is very handy for navigating code which might have multiple levels of if/else block nesting, although do try and avoid this kind of code by using guard clauses if you can.
The feature can be enabled by adding the setting "editor. bracketPairColorization. enabled": true .
I'm not sure what the situation was at the time of this question, but as of the latest version of Visual Studio Code, CtrlShift\ toggles between both the opening and closing bracket of a code block.
I personally find the default key binding a bit awkward, so I remapped it to CtrlAlt\ by going to File > Preferences > Settings
, clicking the curly braces icon to edit the settings.json
file directly, and adding the following code inside of the square brackets:
{
"key": "ctrl+alt+oem_5",
"command": "editor.action.jumpToBracket",
"when": "editorTextFocus"
},
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