Highlight text ranges in Vim

vi, vim

Solution

I believe the Txtfmt plugin is what you're looking for...

Txtfmt (The Vim Highlighter)

Txtfmt provides a sort of "rich text" capability for plain text in Vim. The highlighting is accomplished via hidden marker characters inserted directly into the buffer, so the highlighting is made persistent without the need to store metadata apart from the file.

Txtfmt is highly configurable. The default settings support 8 (configurable) foreground colors, 8 (configurable) background colors, and all combinations of bold, underline and italic attributes (e.g., bold, bold-italic, bold-underline, etc...). A non-default configuration supports the following additional attributes: standout, reverse and undercurl.

There is a very extensive help file, and the author is more than happy to answer usage questions...

Problem

Is it possible to mark a range of text in Vim and change the highlight color of it (to red) than select another range of text and change that color (to green) keeping the previous highlight and so on?

Original source