'Custom brace highlighting in Visual Studio Code

Is it possible to customize the brace highlighting in Visual Studio Code? It seems just about everything else is customizable through user and workspace settings, as well as textmate themes. Regardless of the syntax highlighting you employ, the braces always have the same light gray outline/rectangle around them. I don't see an existing user/workspace setting or a textmate scope that addresses this specific feature.

Ultimately I'd like to have a solid color highlight of matching braces, similar to what you would get with the default dark theme in Visual Studio 2013 and 2015.



Solution 1:[1]

For future reference, vscode now has the option to change the color of bracket highlighting by adding this to settings.json:

"workbench.colorCustomizations" : {
        "editorBracketMatch.background": "#f008",
        "editorBracketMatch.border": "#f00"
}

Formats supported are #RGB, #RGBA, #RRGGBB, #RRGGBBAA. The rgba(255,255,255,1) format that seems to work in other places in the settings file appears to not work here.

Only feature that is still missing regarding this subject is bracket highlighting when the cursor is between brackets. They only highlight when one of the brackets is selected. I did not find a current solution searching trough the Settings or workbench.colorCustomizations.

Update 2018.04.21 There is now a plugin called Bracket Pair Colorizer that does shows the current brackets besides the line number no matter where the cursor is placed within the brakes. But on slower hardware (3nd generation i5 laptop) i encountered slowdowns with it when editing large files (3000+ line php file). And alternate plugin that performs well on the same file and highlights the current indentation is Guides.

Update 2019.11.10 VSCode 1.40 now highlights the brackets enclosing the cursor.

Update 2021.08.09 as @desilicius mentioned in the comments Bracket Pair colorizer is no longer maintained by the author. He offers as an alternative Blockman - Highlight Nested Code Blocks which has the same functionality but has a totally different look and Highlight Matching Tag which is a great plugin but only works on html (and jsx) tags as the name implies.

Update 2021.08.13 The VSCode team decided to add bracket pair colorization as a built in feature. It is worked on right now with improvements of 10k x the speed of BPC2. The discussion can be found here

Solution 2:[2]

You can try Bracket Pair Colorizer 2 Extension.

Solution 3:[3]

Highlighting and changing colors of brackets in VS Code is now possible.

You can try this extension Subtle Brackets by modifying the following the default values in the .json settings of VS Code:

I changed it like this:

"subtleBrackets.bracketPairs": [
    "{}",
    "[]",
    "()",
    "<>"
],
"subtleBrackets.styles": {
    "global": {
        "color": "yellow",
        "borderWidth": "1px",
        "borderStyle": "none none solid none"
    }
}

Don't forget to set to "false" the value of .matchbrackets of VS Code.

"editor.matchBrackets": false

Solution 4:[4]

Update September 2021: The "Bracket pair colorization" feature is now available in VS Code as of the August 2021 (version 1.60) update.

Add this to your settings.json file:

 "editor.bracketPairColorization.enabled": true

After saving the file, brackets should instantly be colorized.

Solution 5:[5]

Also maybe you will like VSCode extension "Blockman", it highlights nested code blocks. (I am the author of Blockman).

The VSCode extension "Blockman" is a new approach of dealing with brackets, well, it does not highlight brackets themselves, but it renders blocks based on the brackets (curly/square/round brackets/braces), and I think it is a better visual helper for our eyes to perceive code structure more easily, to understand code structure more quickly and more comfortably.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Rubel Miah
Solution 3 loretogutierrezjr
Solution 4 Employee
Solution 5