How to set highlight search to be displayed in only lines affected by substitute c-confirm flag?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set highlight search to be displayed in only lines affected by substitute c-confirm flag?

Igor Forca
Hi,
1. create text file with the following three lines:
aa
ab
ac

2. turn on search highlight with:
:set hls

3. now jump to third row:
:3

4. visually select whole line:
V

5. Now do the substitute with "c" flag (confirm):
:s/a/x/gc

Now highlight search marks letter a in whole file, despite only line 3 was selected with visual selection and it is obvious substitute will only be affected on line 3. Is is possible to set that highlight search marks only affected (by visual mode selection) lines? Like in example letter "a" in line 3 only.

Thanks

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to set highlight search to be displayed in only lines affected by substitute c-confirm flag?

Ben Fritz
On Wednesday, September 27, 2017 at 8:02:28 AM UTC-5, Igor Forca wrote:

> Hi,
> 1. create text file with the following three lines:
> aa
> ab
> ac
>
> 2. turn on search highlight with:
> :set hls
>
> 3. now jump to third row:
> :3
>
> 4. visually select whole line:
> V
>
> 5. Now do the substitute with "c" flag (confirm):
> :s/a/x/gc
>
> Now highlight search marks letter a in whole file, despite only line 3 was selected with visual selection and it is obvious substitute will only be affected on line 3. Is is possible to set that highlight search marks only affected (by visual mode selection) lines? Like in example letter "a" in line 3 only.
>
> Thanks
You could anchor the match to begin in the visual selection, using \%V

--
--
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].
For more options, visit https://groups.google.com/d/optout.