3

I am using an interactive substitution that spans multiple lines. In order to determine whether each particular occurrence should be replaced, I need to see all lines that are included in the search criteria, but vim only displays the first line.

I know you can scroll the window with zz, zt and zb, but this doesn't appear to work in interactive substitute mode. Is there an alternative approach?

Here is an example command, which replaces three newlines with two:

:1,$s/\n\n\n/^M^M/gce
1
  • First run /\n\n\n and then do :%s//\r\r/gce?
    – muru
    Mar 17, 2017 at 2:45

1 Answer 1

4

To answer my own question (and if I read the documentation on the [c] flag properly), I would have known that using CTRL-E and CTRL-Y scroll the screen up and down, respectively.

[c] Confirm each substitution. Vim highlights the matching string with...

CTRL-E to scroll the screen up {not in Vi, not available when compiled without the |+insert_expand| feature}

CTRL-Y to scroll the screen down {not in Vi, not available when compiled without the |+insert_expand| feature}

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.