Next: Auto Scrolling, Up: Display
If a buffer contains text that is too large to fit entirely within a window that is displaying the buffer, Emacs shows a contiguous portion of the text. The portion shown always contains point.
Scrolling means moving text up or down in the window so that different parts of the text are visible. Scrolling “forward” or “up” means that text moves up, and new text appears at the bottom. Scrolling “backward” or “down” moves text down, and new text appears at the top.
Scrolling happens automatically if you move point past the bottom or top of the window. You can also scroll explicitly with these commands:
recenter-top-bottom).
scroll-up).
scroll-down).
reposition-window).
C-l (recenter-top-bottom) is a basic scrolling command.
It recenters the selected window, scrolling it so that the
current screen line is exactly in the center of the window, or as
close to the center as possible.
Typing C-l twice in a row (C-l C-l) scrolls the window so that point is on the topmost screen line. Typing a third C-l scrolls the window so that point is on the bottom-most screen line. Each successive C-l cycles through these three screen positions.
You can change the cycling order by customizing the list variable
recenter-positions. Each list element should be the symbol
top, middle, or bottom, or a number; an integer
number means to move the line to the specified screen line, while a
floating-point number between 0.0 and 1.0 specifies a percentage of
the screen space from the top. The default, (middle top
bottom), is the cycling order described above. Furthermore, if you
change the variable scroll-margin to a non-zero value n,
Emacs always leaves n screen lines between point and the top or
bottom of the window (see Auto Scrolling).
You can also supply C-l with a prefix argument. With a plain prefix argument, C-u C-l, Emacs simply recenters point. With a positive argument n, it scrolls to place point n lines down from the top of the window. An argument of zero puts point on the topmost line. A negative argument -n puts point n lines from the bottom of the window. For example, C-u - 1 C-l puts point on the bottom line, and C-u - 5 C-l puts it five lines from the bottom. When given an argument, C-l does not clear the screen or cycle through different screen positions.
The more primitive command recenter behaves like
recenter-top-bottom, but does not cycle among screen positions.
Prior to Emacs 23, C-l was bound to recenter.
If the variable recenter-redisplay has a non-nil
value, Emacs clears and redisplays the screen each time C-l
recenters the window; the special value tty (the default) says
to do this on text-terminal frames only. Redisplaying is useful in
case the screen becomes garbled for any reason (see Screen Garbled).
To read the buffer a windowful at a time, type C-v
(scroll-up). This scrolls forward by nearly the whole window
height. The effect is to take the two lines at the bottom of the
window and put them at the top, followed by lines that were not
previously visible. If point was in the text that scrolled off the
top, it ends up at the new top of the window.
M-v (scroll-down) scrolls backward in a similar way.
The variable next-screen-context-lines controls the number of
lines of overlap left by C-v or M-v; by default, it is 2.
The function keys <next> and <prior>, or <PageDown> and
<PageUp>, are equivalent to C-v and M-v respectively.
You can supply C-v or M-v with a numeric prefix argument n. This scrolls the window by n lines, while attempting to leave point unchanged (so that the text and point move up or down together). C-v with a negative argument is like M-v and vice versa.
The names of scroll commands are based on the direction that the
text moves in the window. Thus, the command to scroll forward is
called scroll-up because it moves the text upward on the
screen. The keys <PageUp> and <PageDown> derive their names
and customary meanings from a different convention that developed
elsewhere; hence the strange result that <PageDown> runs
scroll-up.
Some users like the full-screen scroll commands to keep point at the
same screen position. To enable this behavior, set the variable
scroll-preserve-screen-position to a non-nil value.
Then, whenever a command scrolls the text around point offscreen (or
within scroll-margin lines of the edge), Emacs moves point to
keep it at the same vertical and horizontal position within the
window. This mode is convenient for browsing through a file by
scrolling by screenfuls; if you come back to the screen where you
started, point goes back to the line where it started.
The C-M-l command (reposition-window) scrolls the current
window heuristically in a way designed to get useful information onto
the screen. For example, in a Lisp file, this command tries to get the
entire current defun onto the screen if possible.