Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep cursor line vertically centered in vim

Tags:

vim

I want the cursor to be constantly in the middle of my screen in vim.
I am not very comfortable looking constantly down to the end of the file.
What commands in the config will you advise to solve the problem?

like image 661
nakem Avatar asked Jan 21 '26 04:01

nakem


1 Answers

Besides :set so=999, I also tried these 2 commands to map the normal k and j to "scroll up/down one line and place that line at the center of the window":

:nnoremap k kzz
:nnoremap j jzz

A little different from setting so, when moving cursor down to the end of the file, it still remains at the center. However it doesn't affect the behavior of shift+g.

like image 98
Light Avatar answered Jan 23 '26 20:01

Light