colorful, ephemeral or semi-permanent
Adding arbitrary highlights for text fragments can be done via
:help :match (and
:3match, generically with
matchadd()). These built-in commands provide the basic functionality, but for a great user experience, more stuff is needed (like helpful mappings that mirror the build-in
:autocmds that apply the highlightings not just in the current window, maybe persistence across settings. For that, a plugin is needed.
My Mark plugin is one of those. (The plugin page has links to alternative plugins.) The highlighting (patterns and colors) won't be part of the buffer; best you could do is storing these as annotations in a modeline-like comment.
If you instead really want complete permanency:
- For a few keywords, a syntax extension could work. Many syntaxes already have a common highlighting of
FIXME, and similar keywords.
- There are many "enriched text" formats; Markdown is very famous (and also used here on Stack Overflow); some languages already allow embedding inside comments or other blocks; for others this could be grafted on via my SyntaxRange plugin. You'd be limited to a few common formatting styles (like bold and italic), though, or have to insert big ugly markup (like