You can keep the cursor line in the middle of the screen and then have the text scroll underneath it by setting the scrolloff to a very large number. Ex:
:let &scrolloff = 999
To read more about how this works:
:help scrolloff
I love this feature and use it all the time but I would like the ability to keep the cursor at other locations other than the middle of the screen. For instance I would like the ability to keep the cursor at the top of the window and have the file scroll underneath it. I am pretty sure there is nothing natively available in vim to do this so I was wondering if anyone had come up with a light wieght vim script snippet to do this (or can someone come up with such a script)?
Here is my little .vimrc helper code to swich the position of the cursor quickly:
" SCROLLFIX SHORTCUTS
function! ToggleMyScrollFix()
if ( g:scrollfix == 5 )
let g:scrollfix = 50
elseif ( g:scrollfix == 50 )
let g:scrollfix = 95
elseif ( g:scrollfix == 95 )
let g:scrollfix = 5
else
let g:scrollfix = 50
endif
endfunction
nnoremap <silent> zz :call ToggleMyScrollFix()<CR>lh