Sunday, June 14, 2020

Re: persistent highlight between marks ?


Hi,

M Kelly schrieb am 13.06.2020 um 14:21:

Anyone know of a way to set a start mark and then an end mark and then highlight all text between them ?
So that is stays highlighted, even if I move the cursor away or scroll etc. 
Sort of like a visual mode selection that remains after you move away.

you can use the "/%'m" atom in a search or in the pattern of a :match command, e.g.,

  /%'a\_.*%'b/

or

  :match ErrorMsg /%'a\_.*%'b/

This will highlight everything from mark 'a up to, but not including mark 'b. If you want to include the position where you have put mark 'b, add a dot at the end of the pattern, i.e.,

  /%'a\_.*%'b./

If you change one of the marks after that, you might need to press Ctrl-L to refresh the display.

Regards,
Jürgen

No comments:

Post a Comment