On 2014-04-16, Ven Tadipatri wrote:
> In Vim, you can do a search and replace with :%s, with a confirm option. But if
> the text you want to replace is the last line in the current window, then you
> can't really see any context for it. Is there a way to do a reverse search and
> replace? Or when a match is found, can you have vim show a few lines below it?
I don't know of a way to do exactly what you want, but you could use
'scrolloff' to keep the cursor line a few lines away from the top
and bottom of the screen, e.g.,
:set scrolloff=2
I don't use :%s with the confirm flag. Instead I use n to find the
next match and . to repeat the substitution, but I experience the
same frustration of not being able to see the context of the change
I'm about to make. I don't like the solution I proposed above
because it always scrolls the display to keep the cursor out of the
top and bottom rows and when I'm editing I often want the cursor at
the very top or bottom.
My work-around has been to map n, N and a few other jump commands to
include a call to a function that repositions the cursor away from
the top and bottom of the screen. It works pretty well, but I don't
know of any hooks to make it work for your case.
Regards,
Gary
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment