Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto 'zz' in vim after a jump

Tags:

command

vim

After I make a jump to anywhere in the world, whether in the current file or a different file, is it possible to make vim automatically run zz (re-center on current line)?

I want this after things like search, ctrl-o and ctrl-i ... and pretty much any movement other than hjkl.

Thanks.

like image 284
anon Avatar asked Mar 03 '10 15:03

anon


People also ask

What does ZZ do Vim?

Exit Vim Using a Shortcut Key To save a file in Vim and exit, press Esc > Shift + ZZ. To exit Vim without saving, press Esc > Shift + ZX.

How do I go back to vim?

Remember, yo undo a change in Vim / Vi use the command u , and to redo a change which was undone use Ctrl-R .


1 Answers

Voila:

" Center screen on next/previous selection.
nnoremap n nzz
nnoremap N Nzz
" Last and next jump should center too.
nnoremap <C-o> <C-o>zz
nnoremap <C-i> <C-i>zz
like image 146
Mosh Avatar answered Oct 05 '22 01:10

Mosh