tags:

views:

132

answers:

2

When I do a search with vim or gvim, the resulting positioning of the cursor within the window is somewhat random, all too frequently landing on the last (or first) line in the window. Search highlighting helps, but it's still cumbersome to have to look all around on the screen to find the cursor ... and a bit ironic, that after vim locates the next result in some megabytes-long log file, I have to use the ol' neocortex to isolate it from the last 4K or so.

I can manually get the effect I want by hitting 'zz' after every search, but would prefer to doctor up my _vimrc to make this happen automatically.

+4  A: 

Will this work for you ?

:nmap n nzz  
:nmap p pzz
ldigas
figured it was probably about that easy. that's awesome. thanks!
JustJeff
+1  A: 

I use this trick with other commands too:

nnoremap n nzz
nnoremap N Nzz
nnoremap <C-o> <C-o>zz
nnoremap <C-i> <C-i>zz
Mosh