Saturday, July 16, 2016

Re: how to map the n to nzz just in the jump in search result ?

On Sat, Jul 16, 2016 at 4:52 AM, Tim Chase <vim@tim.thechases.com> wrote:
On 2016-07-15 21:30, 李哲 wrote:
> as you know when you search `abc` in the text, you press `n` to go
> to the next match,
>
> now I want to map n here to nzz, what should I do?
>
> nmap n nzz obvious wrong here.

By using "nmap" rather than "nnoremap", you end up with a recursive
macro that does an "n" that does an "n" that does an "n", to infinity.

Should be able to just change it to

  :nnoremap n nzz

and you're good to go.


As it appears that the intent here is to re-center the searched line, another approach is to set a high 'scrolloff' lines, like

  :set scrolloff=999

That way, even backward search (or any other jump for that matter) would also re-center the screen.

--Arun 

--
--
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