Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
710 views
in Technique[技术] by (71.8m points)

editor - Automatically scroll screen in vim when near top/bottom?

I would like to have smarter screen scrolling when I'm editing. When I reach within X number of lines from the top/bottom of the screen, I would like it to scroll the screen as I continue moving the cursor (so I can always see, at minimum, X lines below or above).

I know ctrl-y and ctrl-e will scroll, but is there a way I can have vim detect when I hit j or k how far I am from the top/bottom of the screen so it can move the screen as needed? I also know zz will center on the current cursor location, but I'd like there to be an area where it doesn't scroll.

Thanks.

question from:https://stackoverflow.com/questions/982195/automatically-scroll-screen-in-vim-when-near-top-bottom

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From my .vimrc:

set scrolloff=3 " Keep 3 lines below and above the cursor

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...