Monday, June 29, 2020

Re: persistent highlight between marks ?

On 2020-06-29 14:17, Charles Campbell wrote:
> M Kelly wrote:
>> 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.
>
> See :help matchadd for a general solution.

You can do something like

:match Error /\%'<\|\%'>\|\%>'<\%<'>/

to keep the visually-selected range highlighted. If you visually
select something else, use control+L or :redraw to repaint the range.

If you have marks x and y, you can do the same thing (though this
requires that mark x preceeds mark y in the file, otherwise you just
get the endpoints highlighted):

:match Error /\%'x\|\%'y\|\%>'x\%<'y/

Adust "Error" to your favorite highlight group.

That breaks down as matching one of three things (separated by "\|"):

\%'x " the first mark
\%'y " the second mark
\%>'x\%<'y " stuff after 'x but before 'y

-tim




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200629140801.3b1d35eb%40bigbox.attlocal.net.

No comments: