In vim, how do you scroll a buffer so the cursor location is centered in the screen?

后端 未结 5 433
半阙折子戏
半阙折子戏 2021-02-02 06:42

In vim, often I will jump to a mark I made, or a search result, and the cursor will be at the very bottom or very top of the screen. At this point, in order for the screen to b

5条回答
  •  不思量自难忘°
    2021-02-02 06:51

    This will center the current line

    zz
    

    Optionally you could set scrolloff to something large like 999 and the working line will always be in the center, except when you are towards the start or end of the file.

    :set scrolloff=999
    

提交回复
热议问题