Reputation: 31546
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.
Upvotes: 23
Views: 12953
Reputation: 6092
As of the latest version of Visual Studio Code, CtrlShift\ toggles between both the opening and closing brackets 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"
},
Upvotes: 30
Reputation: 6075
Visual Studio Code now has a UI for keyboard shortcut mappings.
The default way to get there by keystroke is:
Ctrl+K, Ctrl+S
To get there via the UI:
To get there via the vscode command menu, search for Keyboard Shortcuts
Upvotes: 1