In Neovim, when I type :%s/foo
then the current buffer changes to have all instances of foo
removed, basically giving a preview of the change. Coming from standard Vim, I find this confusing and it's also very slow for large files. How can I disable this behavior?
1 Answer
Set :h inccommand
to an empty string.
let &inccommand = ""
From :h inccommand
:
When nonempty,
inccommand
, shows the effects of:substitute
,:smagic
,:snomagic
and user commands with the:command-preview
flag as you type.
-
Great, thanks! I noticed another very related issue and thought you might have an idea (otherwise I'll start a new question)? When I type
/foo
it nicely highlights all matches and doesn't change the scroll position but when I do:%s/foo
then it scrolls to the first match even while I'm still typing. Is there a way to instead scroll to the next match (just like/foo
)?– danijarAug 15, 2022 at 8:26 -
1First: the reason any search (including substitute) command scrolls is because of
:h incsearch
. If you search for a word which is outside the current view of the window, it will scroll. Second: the reason%s/foo
scrolls differently from/foo
is because you are matching from the beginning of the file, not from current line downward. The behavior you're asking for can be achieved with:,,$s/foo
(see:h :range
). But that would of course only substitute from the current line to the last line; not the whole buffer. If you think about it, it makes sense.– 3N4NAug 15, 2022 at 8:45