This might be a general vsCode question, but I'm trying to make it work in the Microsoft Python plugin for vsCode.
I tried all the textMate definitions that show as intellisense suggestions when editing the settings file but none worked.
I want to either colorize the parentheses, braces & brackets or any other token in order to make a visual difference between the preceding identifier (function name or collection name) and what goes inside the delimiters (function arguments or collection indices)
function(arg1, arg2)
collection[index]
To configure these settings, open Settings in VS Code. First search for "bracket pair colorizer" or "bracket pair colorization". There will be a couple of options returned from the search. The setting we want is called Bracket Pair Colorization, highlighted by the red square in the image above.
You can go on performing in the “Find and Replace” box by clicking “Format” tab and choose “Font”. In “Find Font” box, choose a font color and click “OK”. Then the font color in brackets shall be changed. Or you can press “Ctrl+ D” to open the “Font” box and set a font color there.
In Visual Studio Code, you can customize a lot of syntax colors to your individual needs.
Let's say we want to change syntax color of a specific comma - for example the one used to seperate function parameters - you'll need to know what identifier that token has. To find out this just hit ctrl+shift+P
and type in Developer: Inspect TM Scopes
.
Then click anywhere inside an opened script and select the desired character or keyword you want to know more about. As you can see below the identifier for commas between function parameters in Python is punctuation.separator.parameters.python
(btw. there is also a token named punctuation.separator.arguments.python
, so you could even use a different color for the commas between arguments):
Now that you have the required identifier for that token, you can add the following to your settings.json
:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "punctuation.separator.parameters.python",
"settings": {
"foreground": "#ff8800",
"fontStyle": "bold"
}
}
]
}
As you can see you're not only able to change the color, you're also able to change font style if you want and you can place as many scopes within "textMateRules"
as you want.
This works for parentheses, brackets and curly brackets as well as for colons, any kind of operators, keywords like class
, def
, etc.
In this way you can adjust syntax coloring without having to change the whole theme. And of course you can do this with nearly every language available in VSCode.
Note: The code above applies changes only to Python language and will display the selected colors only in Python scripts. For other programming languages you'll first have to inspect the code of the desired language (like described above) to find out the identifiers of the tokens (unfortunately I've not yet found a list of all available tokens to choose from, so, if somebody knows from where or how to get it, feel free to add a comment - thx).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With