Jump to closing bracket in Visual Studio Code

2019-01-30 09:40发布

问题:

In VSCode when I type a bracket, e.g '(', it automatically creates the ending bracket: ')'. Are there any shortcuts to jump to the closing bracket or parenthesis, without pressing the 'End' key?

I found a way to do in Sublime Text 2 that did exactly that, using a Regex in the User's Key Bindings, but couldn't find a way to do it in VSCode.

Thank you.

回答1:

Mac Cmd+Shift+\

Windows Ctrl+Shift+\

As well you can do:

Ctrl+Shift+p

And select

Preferences: Open Keyboard Shortcuts

There you will be able to see all the shortcuts, and create your own.



回答2:

The out-of-the-box way to do it is

Ctrl + Shift + |


回答3:

You can learn commands from the command palette (Ctrl/Cmd+Shift+P). Look for "Go to Bracket". The keybinding is also shown there.



回答4:

Command "editor.action.jumpToBracket" jumps between opening and closing brackets.

Here is the command's default key binding as seen in window Default Keyboard Shortcuts accessed from File | Preferences | Keyboard Shortcuts:

{ "key": "ctrl+shift+\\", "command": "editor.action.jumpToBracket",
                             "when": "editorTextFocus" }

If you're fond of quickly configuring keyboard shortcuts and VS Code settings, there are commands "workbench.action.openGlobalKeybindings" and "workbench.action.openGlobalSettings":

~/.config/Code/User/keybindings.json:

{ "key": "ctrl+numpad4", "command": "workbench.action.openGlobalKeybindings" }
{ "key": "ctrl+numpad1", "command": "workbench.action.openGlobalSettings" }


回答5:

For those with a non-US keyboard:

File > Preferences > Keyboard Shortcuts. 
(Code > Preferences > Keyboard Shortcuts on Mac)

shows the current key bindings. See also here: https://code.visualstudio.com/docs/getstarted/keybindings



回答6:

In Spanish keyboard it's Ctrl+Shift+º

It seems to change from one keyboard layout to another, so better look for it with Cmd+Shift+P and type "go to bracket" as others suggested.



回答7:

The shortcut is:

Windows/English Ctrl+Shift+\

Windows/German Ctrl+Shift+^



回答8:

Press Ctrl+k+s

or

Open up File --> Preferences ---> Keyboard Shortcuts

Here, type editor.action.jumpToBracket will show you what is the current setting. You can keep it as is or change it to your combination.



回答9:

In german VS-Environments(here 2015): Optionen/Umgebung/Tastatur. (english: options/environment/keyboard). Show Commands With "GeheZuKlammer" (english: "GoToBracket"). Set your own Shortcut.



回答10:

(For anybody looking how to do it in Visual Studio!)



回答11:

Please use Control + ] by placing your cursor on start or end



回答12:

I've found the easiest way to get to line end is by hitting the following

Mac: ctrl+E