Wednesday, November 11, 2009

Window Scrolling

Hit ctrl-e to scroll the current window down. Hit ctrl-y to scroll the current window up. An advantage of using these commands is that the cursor stays in the current location. Try it!

8 comments:

Anonymous said...

You can do this in insert mode also by prefixing C-e and C-y with C-x e.g. C-x C-e

It's useful if you want to refer to something that is outside of the screen without living the insert mode.

mariuss said...

Is there a way to center the cursor vertically in the window, while staying on the same line?

Bill Odom said...

mariuss: In Normal mode, zz will place the current line in the middle of the window without changing the cursor position within the line.

Travis Whitton said...

@mariuss

Bill probably already answered your question but just in case you're asking how to put the cursor in the middle of the current line, just hit gm in normal mode.

Seth said...

This is good, I've definitely been missing this. is there a way to scroll a half-page or so at a time, w/o changing cursor position?

Bill Odom said...

Seth: Check out :help scroll-cursor for some ideas. I think zt and zb are probably what you want.

Bill Odom said...

...although now that I re-read your comment, maybe not. I suggest skimming :help scroll.txt for lots of scrolling techniques.

mariuss said...

A bit late, but thanks for the tip, yes, zz is what I was looking for :-)

And gm looks useful as well.