Thursday, December 16, 2010

Make (next) found match to appear in the screen's center

Turned out to be easier than expected:

nnoremap n nzz
nnoremap N Nzz


Simply adds the zz (see :h z.) to n and N commands.

P.S. Original question and answer as SO.

Edit1 Problem with the solution is that the message search hit BOTTOM, continuing at TOP, due to the zz command, now doesn't appear on the screen anymore. Trying now to use the other tip: set scrolloff=5. Will see how that works.

Edit2 Yep, the set scrolloff=5 works for me much better than the nzz.