I need to have my vscode highlight specific words so I can leave different notes in the code and easily see them when I need to, for example: Note: with the color green and DEBUG with color red and so on.
I need to have my vscode highlight specific words so I can leave different notes in the code and easily see them when I need to, for example: Note: with the color green and DEBUG with color red and so on.
Download and install TODO Highlight extension. After you download and install the extension, make sure you restart your VSCode. Now please follow the following steps in order to add custom keyword highlighting in your code.
a command line opens up.
Settings window will open.
under the "search setting" input on the right handside look for the three dots "..." and click on it.
Click on "Open settings.json".
"User Settings" tab will open. It contains a split screen window. on the left side you see the defualt settings and on the right side you see the user settings
you will see "todohighlight.keywords": [].
a little pen will show up on its left side
you'll see a drop-down select menu opens.
you can now see "todohighlight.keywords": [] in the right pannel window (USER SETTINGS).
This is an array that contains json objects such as following:
"todohighlight.keywords": [
{
"text": "todo:",
"color": "#000000",
"backgroundColor": "DarkKhaki",
"overviewRulerColor": "DarkKhaki",
"border": "1px solid DarkKhaki",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "note:",
"color": "#000000",
"backgroundColor": "#72824E",
"overviewRulerColor": "#72824E",
"border": "1px solid #72824E",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "System.debug",
"color": "#000000",
"backgroundColor": "STEELBLUE",
"overviewRulerColor": "STEELBLUE",
"border": "1px solid STEELBLUE",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "system.debug",
"color": "#000000",
"backgroundColor": "STEELBLUE",
"overviewRulerColor": "STEELBLUE",
"border": "1px solid STEELBLUE",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "console.log",
"color": "#000000",
"backgroundColor": "STEELBLUE",
"overviewRulerColor": "STEELBLUE",
"border": "1px solid STEELBLUE",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "|DEBUG|",
"color": "#000000",
"backgroundColor": "#72848A",
"overviewRulerColor": "#72848A",
"border": "1px solid #72848A",
"borderRadius": "3px",
"isWholeLine": true
},
{
"text": "attention:",
"color": "white",
"backgroundColor": "red",
"border": "1px solid red",
"borderRadius": "3px",
"isWholeLine": false
},
{
"text": "debug:",
"color": "white",
"backgroundColor": "red",
"border": "1px solid red",
"borderRadius": "3px",
"isWholeLine": false
}
],
"todohighlight.include": [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx",
"**/*.html",
"**/*.php",
"**/*.css",
"**/*.scss"
],
"todohighlight.exclude": [
"**/node_modules/**",
"**/bower_components/**",
"**/dist/**",
"**/build/**",
"**/.vscode/**",
"**/.github/**",
"**/_output/**",
"**/*.min.*",
"**/*.map",
"**/.next/**"
]
If you're not familiar with json notation copy the content of "todohighligh.keywords" from the sample above and past it to your "user settings" window in between the two [] brackets. you can change the values on the left side of : colon in between "" double quotes. if you would like to add more than two keywords simply add a comma after the last closing curly bracket } in your "user settings" and copy/past one json object (which is from one { open bracket to the first closing } bracket) and then change its content. you can add as many keywords as you'd like to.
MAKE SURE YOU SAVE THE FILE by holding down Ctrl(windows) / command(mac) and press the key "s" or from the menu bar go to File -> Save
Edit Jun/2021 It's been a while since I published this post. I've updated the sample for more detailed highlighting. Post your comments down below if you need clarifications. Cheers!
Edit Jun/2022 I've added both "todohighlight.include" and "todohighlight.exclude" keys with some sample values for, files/file name patterns, to include and exclude on the highlighting. Cheers!
My answer may not apply your scene, but if someone wants to highlight any word,I prefer this plugin:
The following options can be configured
highlightwords.colors: this is an array of light/dark pairs for respective theme types, you can have as few or as many as you like
highlightwords.box: show highlights as a box around the selections if true, set highlight as background color if false
highlightwords.defaultMode: the initial mode when initialized. 0=default, 1=whole word, 2=ignore case, 3=whole word and ignore case
highlightwords.showSidebar provides a view in the explorer window for searching, changing options and removing highlights