For example if I have a line at the beginning of the screen and in the opened file there are other lines above it so the screen is not at the beginning of the file (it is scrolled down), if I go to that line and use a command I should see that line in the middle of the screen or as close as possible to the middle of the screen.


2 Answers 2


Is zz not what you're looking for?


In the page to which I offered a link in the old answer below I just had to look harder to find the zz command which does exactly the same thing.

Old answer:

I ended up using a solution inspired from this page by putting these lines in my .vimrc:

" Use <F5> to scroll the current line to the middle of the screen
inoremap <F5> <Esc>:set so=999<CR>:set so=0<CR>i
nnoremap <F5> :set so=999<CR>:set so=0<CR>

Not the answer you're looking for? Browse other questions tagged or ask your own question.