Next: , Previous: Scrolling, Up: Display


19.7 Horizontal Scrolling

Horizontal scrolling means shifting all the lines sideways within a window—so that some of the text near the left margin is not displayed at all. When the text in a window is scrolled horizontally, text lines are truncated rather than continued (see Display Custom). Whenever a window shows truncated lines, Emacs automatically updates its horizontal scrolling whenever point moves off the left or right edge of the screen. You can also use these commands to do explicit horizontal scrolling.

C-x <
Scroll text in current window to the left (scroll-left).
C-x >
Scroll to the right (scroll-right).

The command C-x < (scroll-left) scrolls the selected window to the left by n columns with argument n. This moves part of the beginning of each line off the left edge of the window. With no argument, it scrolls by almost the full width of the window (two columns less, to be precise).

C-x > (scroll-right) scrolls similarly to the right. The window cannot be scrolled any farther to the right once it is displayed normally (with each line starting at the window's left margin); attempting to do so has no effect. This means that you don't have to calculate the argument precisely for C-x >; any sufficiently large argument will restore the normal display.

If you use those commands to scroll a window horizontally, that sets a lower bound for automatic horizontal scrolling. Automatic scrolling will continue to scroll the window, but never farther to the right than the amount you previously set by scroll-left.

The value of the variable hscroll-margin controls how close to the window's edges point is allowed to get before the window will be automatically scrolled. It is measured in columns. If the value is 5, then moving point within 5 columns of the edge causes horizontal scrolling away from that edge.

The variable hscroll-step determines how many columns to scroll the window when point gets too close to the edge. If it's zero, horizontal scrolling centers point horizontally within the window. If it's a positive integer, it specifies the number of columns to scroll by. If it's a floating-point number, it specifies the fraction of the window's width to scroll by. The default is zero.

To disable automatic horizontal scrolling, set the variable auto-hscroll-mode to nil.