Last updated: Apr 6, 2024
Reading time·6 min
To jump to a closing bracket or parenthesis:
Ctrl
+ Shift
+ \
.Cmd
+ Shift
+ \
.The command enables you to go to the matching (opening or closing) square bracket, curly brace or parenthesis.
The keyboard shortcut might not work if your keyboard isn't English.
For example, on Windows:
Ctrl
+ Shift
+ |
.Ctrl
+ Shift
+ ^
.The easiest way for you to find the keyboard shortcut is to:
Place your cursor on the bracket.
Press:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.For example, the screenshot shows that the short is Ctrl
+ Shift
+ \
in my
case.
You can also run the command using the Command Palette:
Place your cursor on the bracket.
Press:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Note: if you need to go to a matching tag in an HTML or a JSX file, type go to matching pair and select Emmet: Go to Matching Pair instead.
If you need to set a custom keyboard shortcut for the "Go to bracket" command:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Enter
.For example, you can you something like Ctrl
+ Shift
+ 4
or Cmd
+
Shift
+ 4
on macOS.
To jump to a closing tag in VS Code:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Here is a short clip that demonstrates the process:
The command can be used to jump to a matching tag in an HTML or JSX file.
VIM
, use the Shift
+ 5
key combination to jump to a matching tag.If you encounter issues when using Emmet, check out my other article: Emmet not working in Visual Studio Code issue [Solved].
By default, the Emmet: Go to Matching pair command doesn't have a keyboard shortcut.
If you need to set a custom keyboard shortcut for the command:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also select the row and click on the plus icon to add a keyboard shortcut.
Enter
.For example, I use Ctrl
+ Shift
+ 3
.
Now you can use the key combination to go to the matching tag.
If your cursor isn't positioned on a specific tag, VS Code finds the nearest tag.
If you need to select everything between brackets:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Here is a short clip that demonstrates the process.
By default, the Select to Bracket action doesn't have a keyboard shortcut set.
If you need to set a keyboard shortcut:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also add a keyboard shortcut by left-clicking the row and clicking on the plus icon.
Enter
.I'll use a keyboard shortcut of Ctrl
+ Shift
+ 3
for the example.
Now you can use the keyboard shortcut to select the code between the brackets or parentheses (depending on where your cursor is placed).
You can also use the expand and shrink selection commands to select everything between brackets or quotes.
On Windows and Linux, the keyboard shortcuts are:
Shift
+ Alt
+ Right
arrow key to expand the selection.Shift
+ Alt
+ Left
arrow key to shrink the selection.On macOS, the keyboard shortcuts are:
Ctrl
+ Shift
+ Right
arrow key to expand the selection.Ctrl
+ Shift
+ Left
arrow key to shrink the selection.If you need to find the keyboard shortcuts for the command or run them manually:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.If you need to set custom keyboard shortcuts for the expand and shrink selection commands:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Double-click on the row, specify your preferred key combination and press
Enter
.
Search for shrink selection and double-click on the option.
Enter
.I've also written an article on how to wrap text with tags in VS Code.
You can learn more about the related topics by checking out the following tutorials: