1 *scroll.txt* For Vim version 5.8. Last change: 2000 Jun 14
4 VIM REFERENCE MANUAL by Bram Moolenaar
9 These commands move the contents of the window. If the cursor position is
10 moved off of the window, the cursor is moved onto the window (with
11 'scrolloff' screen lines around it). A page is the number of lines in the
12 window minus two. The mnemonics for these commands may be a bit confusing.
13 Remember that the commands refer to moving the window (the part of the buffer
14 that you see) upwards or downwards in the buffer. When the window moves
15 upwards in the buffer, the text in the window moves downwards on your screen.
17 1. Scrolling downwards |scroll-down|
18 2. Scrolling upwards |scroll-up|
19 3. Scrolling relative to cursor |scroll-cursor|
20 4. Scrolling horizontally |scroll-horizontal|
21 5. Scrolling synchronously |scroll-binding|
22 6. Scrolling with a mouse wheel |scroll-mouse-wheel|
24 ==============================================================================
25 1. Scrolling downwards *scroll-down*
27 The following commands move the edit window (the part of the buffer that you
28 see) downwards (this means that more lines downwards in the text buffer can be
32 CTRL-E Scroll window [count] lines downwards in the buffer.
33 Mnemonic: Extra lines.
36 CTRL-D Scroll window Downwards in the buffer. The number of
37 lines comes from the 'scroll' option (default: half a
38 screen). If [count] given, first set 'scroll' option
39 to [count]. The cursor is moved the same number of
40 lines down in the file (if possible; when lines wrap
41 and when hitting the end of the file there may be a
42 difference). When the cursor is on the last line of
43 the buffer nothing happens and a beep is produced.
44 See also 'startofline' option.
45 {difference from vi: Vim scrolls 'scroll' screen
46 lines, instead of file lines; makes a difference when
49 <S-Down> or *<S-Down>* *<kPageDown>*
50 <PageDown> or *<PageDown>* *CTRL-F*
51 CTRL-F Scroll window [count] pages Forwards (downwards) in
52 the buffer. See also 'startofline' option.
55 z+ Without [count]: Redraw with the line just below the
56 window at the top of the window. Put the cursor in
57 that line, at the first non-blank in the line.
58 With [count]: just like "z<CR>".
60 ==============================================================================
61 2. Scrolling upwards *scroll-up*
63 The following commands move the edit window (the part of the buffer that you
64 see) upwards (this means that more lines upwards in the text buffer can be
68 CTRL-Y Scroll window [count] lines upwards in the buffer.
71 CTRL-U Scroll window Upwards in the buffer. The number of
72 lines comes from the 'scroll' option (default: half a
73 screen). If [count] given, first set the 'scroll'
74 option to [count]. The cursor is moved the same
75 number of lines up in the file (if possible; when
76 lines wrap and when hitting the end of the file there
77 may be a difference). When the cursor is on the first
78 line of the buffer nothing happens and a beep is
79 produced. See also 'startofline' option.
80 {difference from vi: Vim scrolls 'scroll' screen
81 lines, instead of file lines; makes a difference when
84 <S-Up> or *<S-Up>* *<kPageUp>*
85 <PageUp> or *<PageUp>* *CTRL-B*
86 CTRL-B Scroll window [count] pages Backwards (upwards) in the
87 buffer. See also 'startofline' option.
90 z^ Without [count]: Redraw with the line just above the
91 window at the bottom of the window. Put the cursor in
92 that line, at the first non-blank in the line.
93 With [count]: First scroll the text to put the [count]
94 line at the bottom of the window, then redraw with the
95 line which is now at the top of the window at the
96 bottom of the window. Put the cursor in that line, at
97 the first non-blank in the line.
99 ==============================================================================
100 3. Scrolling relative to cursor *scroll-cursor*
102 The following commands reposition the edit window (the part of the buffer that
103 you see) while keeping the cursor on the same line:
106 z<CR> Redraw, line [count] at top of window (default
107 cursor line). Put cursor at first non-blank in the
111 zt Like "z<CR>", but leave the cursor in the same
115 z{height}<CR> Redraw, make window {height} lines tall. This is
116 useful to make the number of lines small when screen
117 updating is very slow. Cannot make the height more
118 than the physical screen height.
121 z. Redraw, line [count] at center of window (default
122 cursor line). Put cursor at first non-blank in the
126 zz Like "z.", but leave the cursor in the same column.
127 Careful: If caps-lock is on, this commands becomes
128 "ZZ": write buffer and exit! {not in Vi}
131 z- Redraw, line [count] at bottom of window (default
132 cursor line). Put cursor at first non-blank in the
136 zb Like "z-", but leave the cursor in the same column.
139 ==============================================================================
140 4. Scrolling horizontally *scroll-horizontal*
142 For the following four commands the cursor follows the screen. If the
143 character that the cursor is on is moved off the screen, the cursor is moved
144 to the closest character that is on the screen. The value of 'sidescroll' is
147 z<Right> or *zl* *z<Right>*
148 zl Scroll the screen [count] characters to the left.
149 This only works when 'wrap' is off. {not in Vi}
151 z<Left> or *zh* *z<Left>*
152 zh Scroll the screen [count] characters to the right.
153 This only works when 'wrap' is off. {not in Vi}
156 zL Scroll the screen half a screenwidth to the left.
157 This only works when 'wrap' is off. {not in Vi}
160 zH Scroll the screen half a screenwith to the right.
161 This only works when 'wrap' is off. {not in Vi}
163 For the following two commands the cursor is not moved in the text, only the
164 text scrolls on the screen.
167 zs Scroll the screen horizontally to position the cursor
168 at the start (left side) of the screen. This only
169 works when 'wrap' is off. {not in Vi}
172 ze Scroll the screen horizontally to position the cursor
173 at the end (right side) of the screen. This only
174 works when 'wrap' is off. {not in Vi}
176 ==============================================================================
177 5. Scrolling synchronously *scroll-binding*
179 Occasionally, it is desirable to bind two or more windows together such that
180 when one window is scrolled, the other windows are scrolled also. In Vim,
181 windows can be given this behavior by setting the (window-specific)
182 'scrollbind' option. When a window that has 'scrollbind' set is scrolled, all
183 other 'scrollbind' windows are scrolled the same amount, if possible. The
184 behavior of 'scrollbind' can be modified by the 'scrollopt' option.
186 *scrollbind-relative*
187 Each 'scrollbind' window keeps track of its "relative offset," which can be
188 thought of as the difference between the current window's vertical scroll
189 position and the other window's vertical scroll position. When one of the
190 'scrollbind' windows is asked to vertically scroll past the beginning or end
191 limit of its text, the window no longer scrolls, but remembers how far past
192 the limit it wishes to be. The window keeps this information so that it can
193 maintain the same relative offset, regardless of its being asked to scroll
194 past its buffer's limits.
196 However, if a 'scrollbind' window that has a relative offset that is past its
197 buffer's limits is given the cursor focus, the other 'scrollbind' windows must
198 jump to a location where the current window's relative offset is valid. This
199 behavior can be changed by clearing the 'jump' flag from the 'scrollopt'
202 *syncbind* *:syncbind*
203 :syncbind Force all 'scrollbind' windows to have the same
204 relative offset. I.e., when any of the 'scrollbind'
205 windows is scrolled to the top of its buffer, all of
206 the 'scrollbind' windows will also be at the top of
209 *scrollbind-quickadj*
210 The 'scrollbind' flag is meaningful when using keyboard commands to vertically
211 scroll a window, and also meaningful when using the vertical scrollbar of the
212 window which has the cursor focus. However, when using the vertical scrollbar
213 of a window which doesn't have the cursor focus, 'scrollbind' is ignored.
214 This allows quick adjustment of the relative offset of 'scrollbind' windows.
216 ==============================================================================
217 6. Scrolling with a mouse wheel *scroll-mouse-wheel*
219 When your mouse has a scroll wheel, it should work with Vim in the GUI. How
220 it works depends on your system. It might also work in an xterm
223 For the Win32 GUI the scroll action is hard coded. It works just like
224 dragging the scrollbar of the current window. How many lines are scrolled
225 depends on your mouse driver. If the scroll action causes input focus
226 problems, see |intellimouse-wheel-problems|.
228 For the X11 GUIs (Motif, Athena and GTK) scrolling the wheel generates key
229 presses <MouseDown> and <MouseUp>. The default action for these keys are:
230 <MouseDown> scroll three lines down. *<MouseDown>*
231 <S-MouseDown> scroll a full page down. *<S-MouseDown>*
232 <MouseUp> scroll three lines up. *<MouseUp>*
233 <S-MouseUp> scroll a full page up. *<S-MouseUp>*
234 This should work in all modes, except when editing the command line.
236 You can modify this behavior by mapping the keys. For example, to make the
237 scroll wheel move one line or half a page in Normal mode:
238 > map <MouseDown> <C-Y>
239 > map <S-MouseDown> <C-U>
240 > map <MouseUp> <C-E>
241 > map <S-MouseUp> <C-D>
242 You can also use Alt and Ctrl modifiers.
244 This only works when Vim gets the scroll wheel events, of course. You can
245 check if this works with the "xev" program.
247 When using Xfree86, the /etc/XF86Config file should have the correct entry for
248 your mouse. For FreeBSD, this entry works for a Logitech scrollmouse:
249 > Protocol "MouseMan"
252 See the Xfree86 documentation for information.
255 To use the mouse wheel in a new xterm you only have to make the scroll wheel
256 work in your Xserver, as mentioned above.
258 To use the mouse wheel in an older xterm you must do this:
259 1. Make it work in your Xserver, as mentioned above.
260 2. Add translations for the xterm, so that the xterm will pass a scroll event
261 to Vim as an escape sequence.
262 3. Add mappings in Vim, to interpret the escape sequences as <MouseUp> or
265 You can do the translations by adding this to your ~.Xdefaults file (or other
266 file where your X resources are kept):
268 > XTerm*VT100.Translations: #override \n\
269 > s<Btn4Down>: string("0x9b") string("[64~") \n\
270 > s<Btn5Down>: string("0x9b") string("[65~") \n\
271 > <Btn4Down>: string("0x9b") string("[62~") \n\
272 > <Btn5Down>: string("0x9b") string("[63~") \n\
276 Add these mappings to your vimrc file:
277 > map <M-Esc>[62~ <MouseDown>
278 > map! <M-Esc>[62~ <MouseDown>
279 > map <M-Esc>[63~ <MouseUp>
280 > map! <M-Esc>[63~ <MouseUp>
281 > map <M-Esc>[64~ <S-MouseDown>
282 > map! <M-Esc>[64~ <S-MouseDown>
283 > map <M-Esc>[65~ <S-MouseUp>
284 > map! <M-Esc>[65~ <S-MouseUp>