persistent highlight between marks ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

persistent highlight between marks ?

M Kelly
Hi,

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.

thx for all things vim,
-m

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/133c1d7b-8b75-4d63-9299-3c2ecf745ec1o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: persistent highlight between marks ?

Jürgen Krämer-4

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

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/1d11742b-d990-78d0-cb62-5aebe6e0c973%40googlemail.com.
Reply | Threaded
Open this post in threaded view
|

Re: persistent highlight between marks ?

Charles Campbell-2
In reply to this post by M Kelly
M Kelly wrote:
> Hi,
>
> 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.

Regards,
Chip Campbell

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/597b10a8-de2e-dc57-2e5f-a5bd14df43b8%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: persistent highlight between marks ?

Tim Chase
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200629140801.3b1d35eb%40bigbox.attlocal.net.