Sometimes I use substitute with confirmation because I only want to replace some instances of a search, depending on the context. However, it's difficult to tell sometimes because as Vim is cycling through the search, the search term will be at the very bottom of my terminal. So, I can't see anything after the thing I searched for - I can't see the relevant context. Do I want to replace this one or not? I can't tell, because I can't see any subsequent lines.

How can I make the substitute with confirmation command show more context?

  • 2
    :help :s_c gives <C-e> and <C-y>
    – D. Ben Knoble
    Nov 22, 2021 at 22:34
  • 1
    I wonder if setting 'scrolloff' to something larger than 0 would also help here, by always showing at least that many lines of context after/before the line of the substitution. Of course, that option doesn't affect a s/.../.../c command only, it will always prevent the line of the cursor from being the last one in the window... Still, maybe it might be what you're looking for?
    – filbranden
    Nov 24, 2021 at 20:37
  • 1
    Maybe zz (or zt) would help you, too. Both command scroll the window so that the cursor position is in the middle (or at the top resp) of the screen.
    – Rolf
    Nov 26, 2021 at 7:27

1 Answer 1


Looking at the help for the confirmation flag (:help :s_c), we find (among other options) the following key-bindings:

        CTRL-E  to scroll the screen up
        CTRL-Y  to scroll the screen down

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.