Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make vim highlight matched pattern in substitute command [duplicate]

Tags:

regex

vim

When I use search in vim with / command, while typing in characters, I am able to see first occurrence of searched regular expression pattern via highlighting in text area of vim. However, while using :s command, I want to be able to see first occurrence highlighted as I type pattern for what-to-substitute block, but I see no highlighting, as I understand, it is because of command-mode, which is give no highlighting even for search via / in it.

For example, as I type :s/foo/bar, if there's any fo sequence in text, I want it to be highlighted after I typed in :s/fo, but it is not.

Does anybody knows any workaround for this? thx.

like image 895
sandric Avatar asked Dec 20 '22 04:12

sandric


1 Answers

You can't: :s is a : command, not a search command, and highlighting can only be done on search commands.

But despair not!

/foo highlights stuff, then :s//bar replaces stuff using the last search string.

like image 159
Amadan Avatar answered May 21 '23 07:05

Amadan