Is there a way to make vim display "virtual characters" before/after regular patterns in the buffer?

Posted by Laurence Gonsalves on Stack Overflow See other posts from Stack Overflow or by Laurence Gonsalves
Published on 2014-08-18T22:17:42Z Indexed on 2014/08/18 22:19 UTC
Read the original article Hit count: 298

Filed under:
|

Vim has list and listchars options that make vim display "virtual characters" (by which I mean characters that aren't actually in the buffer) in certain situations. For example, you can make trailing spaces look like something else, or add a visible character to represent the newline character.

I'd like to be able to enable the display of certain characters either before or after certain regular patterns ((perhaps syntax items). Sort of like syntax highlighting, but instead of just changing the color/styling of characters that are in the buffer, I'd like to display extra characters that aren't in the buffer.

For example, I'd like to display a virtual : (colon) after all occurrences of the word "where" that appear at the end of a line.

Is this possible, and if so, what is the necessary vimscript to do it?

© Stack Overflow or respective owner

Related posts about vim

Related posts about vimscript