Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight enclosing bracket in Visual Studio Code

Is there a way to highlight brackets when the cursor is anywhere within the enclosing brackets? Default settings highlight it only when I place the cursor near the brackets.

like image 303
rmist Avatar asked Jul 19 '17 06:07

rmist


People also ask

How do you highlight braces in Visual Studio?

To specify the color to highlight matching delimiters, go to Visual Studio options (Tools | Options), open the Environment | Fonts and Colors page, and select the desired colors for the ReSharper Brace Outline and/or ReSharper Matched Brace items.

How do I get to the closing bracket in VS Code?

There are multiple right answers for achieveing what was required. Here are my two cents anyway. The operation to quickly jump to the opening or the closing bracket has to be instant. The Ctrl + Shift + \ is pretty verbose if you ask me.


2 Answers

Yes, there is now a way by default, in VSCode 1.40 (October 2019):

Improvements to bracket matching

Previously, VS Code would only highlight matching brackets when the cursor was next to a bracket character.
Now VS Code will always highlight enclosing brackets if they exist.

Image showing highlighted enclosing brackets

We have also adjusted our Go to Bracket and Select to Bracket actions to use enclosing brackets.

It is improved and supported natively with VSCode 1.60 (Aug. 2021):

Bracket pair colorization can be enabled by setting "editor.bracketPairColorization.enabled": true.
All colors are themeable and up to six colors can be configured.

https://code.visualstudio.com/assets/updates/1_60/bracket-pair-colorization-checker_ts.gif

like image 67
VonC Avatar answered Sep 18 '22 15:09

VonC


VS Code only supports bracket matching when the cursor is near the opening or closing bracket. Maybe an extension would help highlight the enclosing brackets wherever you are in the code but I haven't been able to find one.

If you just want to quickly find matching brackets, braces, parens, etc. you could try Bracket Pair Colorizer or Rainbow Brackets.

like image 33
nick Avatar answered Sep 19 '22 15:09

nick