When typing text I don't like the way the cursor slowly descends towards the bottom of the screen. Instead I would prefer if the cursor stayed in the same place and the text above the cursor moved up. I know about the 'scrolloff' option but I don't like it as it messes up H, L, and M commands and the 'zz' command is too much hassle.

Anyone know how to achieve this behaviour in vim?

link|improve this question
Welcome iorrus to SuperUser Please read the FAQs before posting questions. Please edit your question to include your operating system, and the program your typing into. – wizlog Nov 21 '11 at 17:52
@wizlog: vim.org – Ignacio Vazquez-Abrams Nov 21 '11 at 17:56
and the operating system on which its running? – wizlog Nov 21 '11 at 17:58
Doesn't matter in this case. vim performs the same on almost all of them, with the exception of a few keystrokes which aren't needed here. There is plenty of information to give an answer. – Ignacio Vazquez-Abrams Nov 21 '11 at 17:59
feedback

2 Answers

up vote 1 down vote accepted

You can set the 'scrolloff' option to a high number to keep the cursor in the middle of the display:

:set scrolloff=9999

To do this only in insert mode you will need to use autocmd:

:autocmd InsertEnter * :set scrolloff=9999
:autocmd InsertLeave * :set scrolloff=0

If you have line wrapping turned off, you can do the same with the 'sidescrolloff' option.

Place the command(s) in your ~/.vimrc (~/_vimrc for Windows) to make them permanent.

See:

:help 'scrolloff'
:help 'sidescrolloff'
:help autocmd.txt
link|improve this answer
feedback

As a cheap and cheesy way of doing it, you can use

:imap <CR> <ESC>zzo

to perform zz every time you press Enter in Insert mode.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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