问题
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.
回答1:
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.
On windows hold down Ctrl + Shift and on mac Command + Shift, thenthe key press p.
a command line opens up.
On the command line type "open settings" and click on "Preferences: open settings".
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
in the "search settings" type "todohighlight.keywords"
you will see
"todohighlight.keywords": []
.Hover over it with your mouse
a little pen will show up on its left side
click on it
you'll see a drop-down select menu opens.
click on "Replace in settings".
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": "NOTE:",
"color": "#000000",
"backgroundColor": "#ff00dc",
"overviewRulerColor": "grey"
},
{
"text": "your choice of keyword",
"color": "your choice of color",
"backgroundColor": "your choice of color",
"overviewRulerColor": "your choice of color"
}
]
Iif 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
来源:https://stackoverflow.com/questions/58174681/how-to-highlight-user-specified-words-in-vscode