I know that the incsearch setting controls how search in vim highlights as you type. I would like to have the same incremental search and highlight when using the replace command (:%s/foo/bar/ )
I know that the incsearch setting controls how search in vim highlights as you
Share
The easiest way to do that is to do a search like normal, using
'incsearch'to help ensure the pattern is matching what you want. Once you’ve got that nailed down, you can either:%s//bar/. When there’s no specified search pattern, the current value of the/register is used, which will be the search you just did.:scommand using Ctrl+r/ (see:help c_ctrl-r) or Ctrl+rCtrl+o/ (if the search contains control characters, like^H). This is useful if you want to make some final tweaks to the pattern or if you want to have it in your command history so you can reuse it even after performing another search.