Reputation: 1296
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.
Upvotes: 21
Views: 44171
Reputation: 1296
UPDATE Jun/2023 Thanks to Andre Greeff for his comment:
quick 2023 update: the original "TODO Highlight" by Wayou has not seen any updates since 2019 and appears as though it may be abandoned. For anybody visiting this going forward, you should check out "TODO Highlight V2", maintained by Jonathan Clark.
All the instructions and keywords should work the same. I'll be testing them and if I find any changes I'll update this post accordingly.
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!🍻
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!🍻
Download and install TODO Highlight extension. After you download and installed the extension, make sure you restart your VS Code. 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 default 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 panel 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
Upvotes: 40
Reputation: 727
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
Upvotes: 3