how to put the current line under edit on the top of the screen in vim
It is very inconvenient when the line I'm editing is at the bottom of the screen . Because you can't see any following l开发者_开发问答ines and that prevent you from take any "eye refernce" to the content of the file following the current line .
so my question is there a vim command can refresh the display and put the current line under edit to on the top of the screen ? thanks in advance.
See this reference.
z<return>
:h scroll-cursor
Jonathan's answer is valid, however I prefer zt
(as "top") that keeps the cursor where it was. In the same idea, there is zb
(as "bottom") and zz
(not as "middle", but that puts the current line at the center of the window).
There is also an option to make vim always show context around the current line:
:set scrolloff=5
(or, :se so=5
) will show +/−5 lines around your current line. From vim's help about 'scrolloff':
Minimal number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. If you set it to a very large value (999) the cursor line will always be in the middle of the window (except at the start or end of the file or when long lines wrap).
精彩评论