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

28 views
Skip to first unread message

Igor Forca

unread,
Sep 27, 2017, 9:02:28 AM9/27/17
to vim_use
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

Ben Fritz

unread,
Oct 3, 2017, 10:20:35 PM10/3/17
to vim_use

You could anchor the match to begin in the visual selection, using \%V

Reply all
Reply to author
Forward
0 new messages