XXX in C ++ comments

In vim, when I add a comment like this

int somevar = 100; //XXX Some Comment Here

Part of my comment "XXX" is automatically highlighted. Similarly, β€œTODO” is also added to the comment. I used them myself quite extensively to mark todos / get attention, but I never bothered to find out what makes "XXX" and "TODO" special. What makes these two words special?

Are there any other special words in the comments that automatically stand out?

+7
comments vim highlight
source share
2 answers

These are special syntax files that Vim relies on to style various elements in the source code.

For example, on my machine, the following default syntax file for C (which is also obtained by the C ++ syntax file) contains the line

file: /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/c.vim

 syn keyword cTodo contained TODO FIXME XXX 

Color and style for cTodo , if the search is defined in the c.vim file.

For C ++, the name of the cpp.vim file whose sources (including) c.vim

Why are these keywords?
We will not understand much, but programmers began to draw attention to the prefixes of their comments so that they (or someone else) could come to this area of ​​the code later (for some reason, as indicated in the comment). Editors like Vim have noticed this and added syntax highlighting for these prefixes to make them clearer.

In this regard, most editors today have editable (or custom) syntax highlighting. You can add your own keywords that you want to highlight in the comments! (for other keywords and tokens too).

+5
source share
  • TODO to indicate planned improvements.
  • XXX to alert other programmers of problem or erroneous code.

Source

+5
source share

All Articles