blob: 1aa1b9304c5cf699ab1de6f52fc644f4db6e344d [file] [log] [blame]
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001*scroll.txt* For Vim version 7.0aa. Last change: 2005 Apr 01
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Scrolling *scrolling*
8
9These commands move the contents of the window. If the cursor position is
10moved 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
12window minus two. The mnemonics for these commands may be a bit confusing.
13Remember that the commands refer to moving the window (the part of the buffer
14that you see) upwards or downwards in the buffer. When the window moves
15upwards in the buffer, the text in the window moves downwards on your screen.
16
17See section |03.7| of the user manual for an introduction.
18
191. Scrolling downwards |scroll-down|
202. Scrolling upwards |scroll-up|
213. Scrolling relative to cursor |scroll-cursor|
224. Scrolling horizontally |scroll-horizontal|
235. Scrolling synchronously |scroll-binding|
246. Scrolling with a mouse wheel |scroll-mouse-wheel|
25
26==============================================================================
271. Scrolling downwards *scroll-down*
28
29The following commands move the edit window (the part of the buffer that you
30see) downwards (this means that more lines downwards in the text buffer can be
31seen):
32
33 *CTRL-E*
34CTRL-E Scroll window [count] lines downwards in the buffer.
35 Mnemonic: Extra lines.
36
37 *CTRL-D*
38CTRL-D Scroll window Downwards in the buffer. The number of
39 lines comes from the 'scroll' option (default: half a
40 screen). If [count] given, first set 'scroll' option
41 to [count]. The cursor is moved the same number of
42 lines down in the file (if possible; when lines wrap
43 and when hitting the end of the file there may be a
44 difference). When the cursor is on the last line of
45 the buffer nothing happens and a beep is produced.
46 See also 'startofline' option.
47 {difference from vi: Vim scrolls 'scroll' screen
48 lines, instead of file lines; makes a difference when
49 lines wrap}
50
51<S-Down> or *<S-Down>* *<kPageDown>*
52<PageDown> or *<PageDown>* *CTRL-F*
53CTRL-F Scroll window [count] pages Forwards (downwards) in
54 the buffer. See also 'startofline' option.
Bram Moolenaar4399ef42005-02-12 14:29:27 +000055 When there is only one window the 'window' option
56 might be used.
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
58 *z+*
59z+ Without [count]: Redraw with the line just below the
60 window at the top of the window. Put the cursor in
61 that line, at the first non-blank in the line.
62 With [count]: just like "z<CR>".
63
64==============================================================================
652. Scrolling upwards *scroll-up*
66
67The following commands move the edit window (the part of the buffer that you
68see) upwards (this means that more lines upwards in the text buffer can be
69seen):
70
71 *CTRL-Y*
72CTRL-Y Scroll window [count] lines upwards in the buffer.
73 Note: When using the MS-Windows key bindings CTRL-Y is
74 remapped to redo.
75
76 *CTRL-U*
77CTRL-U Scroll window Upwards in the buffer. The number of
78 lines comes from the 'scroll' option (default: half a
79 screen). If [count] given, first set the 'scroll'
80 option to [count]. The cursor is moved the same
81 number of lines up in the file (if possible; when
82 lines wrap and when hitting the end of the file there
83 may be a difference). When the cursor is on the first
84 line of the buffer nothing happens and a beep is
85 produced. See also 'startofline' option.
86 {difference from vi: Vim scrolls 'scroll' screen
87 lines, instead of file lines; makes a difference when
88 lines wrap}
89
90<S-Up> or *<S-Up>* *<kPageUp>*
91<PageUp> or *<PageUp>* *CTRL-B*
92CTRL-B Scroll window [count] pages Backwards (upwards) in the
93 buffer. See also 'startofline' option.
Bram Moolenaar4399ef42005-02-12 14:29:27 +000094 When there is only one window the 'window' option
95 might be used.
Bram Moolenaar071d4272004-06-13 20:20:40 +000096
97 *z^*
98z^ Without [count]: Redraw with the line just above the
99 window at the bottom of the window. Put the cursor in
100 that line, at the first non-blank in the line.
101 With [count]: First scroll the text to put the [count]
102 line at the bottom of the window, then redraw with the
103 line which is now at the top of the window at the
104 bottom of the window. Put the cursor in that line, at
105 the first non-blank in the line.
106
107==============================================================================
1083. Scrolling relative to cursor *scroll-cursor*
109
110The following commands reposition the edit window (the part of the buffer that
111you see) while keeping the cursor on the same line:
112
113 *z<CR>*
114z<CR> Redraw, line [count] at top of window (default
115 cursor line). Put cursor at first non-blank in the
116 line.
117
118 *zt*
119zt Like "z<CR>", but leave the cursor in the same
120 column. {not in Vi}
121
122 *zN<CR>*
123z{height}<CR> Redraw, make window {height} lines tall. This is
124 useful to make the number of lines small when screen
125 updating is very slow. Cannot make the height more
126 than the physical screen height.
127
128 *z.*
129z. Redraw, line [count] at center of window (default
130 cursor line). Put cursor at first non-blank in the
131 line.
132
133 *zz*
134zz Like "z.", but leave the cursor in the same column.
135 Careful: If caps-lock is on, this commands becomes
136 "ZZ": write buffer and exit! {not in Vi}
137
138 *z-*
139z- Redraw, line [count] at bottom of window (default
140 cursor line). Put cursor at first non-blank in the
141 line.
142
143 *zb*
144zb Like "z-", but leave the cursor in the same column.
145 {not in Vi}
146
147==============================================================================
1484. Scrolling horizontally *scroll-horizontal*
149
150For the following four commands the cursor follows the screen. If the
151character that the cursor is on is moved off the screen, the cursor is moved
152to the closest character that is on the screen. The value of 'sidescroll' is
153not used.
154
155z<Right> or *zl* *z<Right>*
156zl Scroll the screen [count] characters to the left.
157 This only works when 'wrap' is off. {not in Vi}
158
159z<Left> or *zh* *z<Left>*
160zh Scroll the screen [count] characters to the right.
161 This only works when 'wrap' is off. {not in Vi}
162
163 *zL*
164zL Scroll the screen half a screenwidth to the left.
165 This only works when 'wrap' is off. {not in Vi}
166
167 *zH*
168zH Scroll the screen half a screenwidth to the right.
169 This only works when 'wrap' is off. {not in Vi}
170
171For the following two commands the cursor is not moved in the text, only the
172text scrolls on the screen.
173
174 *zs*
175zs Scroll the screen horizontally to position the cursor
176 at the start (left side) of the screen. This only
177 works when 'wrap' is off. {not in Vi}
178
179 *ze*
180ze Scroll the screen horizontally to position the cursor
181 at the end (right side) of the screen. This only
182 works when 'wrap' is off. {not in Vi}
183
184==============================================================================
1855. Scrolling synchronously *scroll-binding*
186
187Occasionally, it is desirable to bind two or more windows together such that
188when one window is scrolled, the other windows are scrolled also. In Vim,
189windows can be given this behavior by setting the (window-specific)
190'scrollbind' option. When a window that has 'scrollbind' set is scrolled, all
191other 'scrollbind' windows are scrolled the same amount, if possible. The
192behavior of 'scrollbind' can be modified by the 'scrollopt' option.
193
194When using the scrollbars, the binding only happens when scrolling the window
195with focus (where the cursor is). You can use this to avoid scroll-binding
196for a moment without resetting options.
197
198When a window also has the 'diff' option set, the scroll-binding uses the
199differences between the two buffers to synchronize the position precisely.
200Otherwise the following method is used.
201
202 *scrollbind-relative*
203Each 'scrollbind' window keeps track of its "relative offset," which can be
204thought of as the difference between the current window's vertical scroll
205position and the other window's vertical scroll position. When one of the
206'scrollbind' windows is asked to vertically scroll past the beginning or end
207limit of its text, the window no longer scrolls, but remembers how far past
208the limit it wishes to be. The window keeps this information so that it can
209maintain the same relative offset, regardless of its being asked to scroll
210past its buffer's limits.
211
212However, if a 'scrollbind' window that has a relative offset that is past its
213buffer's limits is given the cursor focus, the other 'scrollbind' windows must
214jump to a location where the current window's relative offset is valid. This
215behavior can be changed by clearing the 'jump' flag from the 'scrollopt'
216option.
217
218 *syncbind* *:syncbind*
219:syncbind Force all 'scrollbind' windows to have the same
220 relative offset. I.e., when any of the 'scrollbind'
221 windows is scrolled to the top of its buffer, all of
222 the 'scrollbind' windows will also be at the top of
223 their buffers.
224
225 *scrollbind-quickadj*
226The 'scrollbind' flag is meaningful when using keyboard commands to vertically
227scroll a window, and also meaningful when using the vertical scrollbar of the
228window which has the cursor focus. However, when using the vertical scrollbar
229of a window which doesn't have the cursor focus, 'scrollbind' is ignored.
230This allows quick adjustment of the relative offset of 'scrollbind' windows.
231
232==============================================================================
2336. Scrolling with a mouse wheel *scroll-mouse-wheel*
234
235When your mouse has a scroll wheel, it should work with Vim in the GUI. How
236it works depends on your system. It might also work in an xterm
237|xterm-mouse-wheel|.
238
239For the Win32 GUI the scroll action is hard coded. It works just like
240dragging the scrollbar of the current window. How many lines are scrolled
241depends on your mouse driver. If the scroll action causes input focus
242problems, see |intellimouse-wheel-problems|.
243
244For the X11 GUIs (Motif, Athena and GTK) scrolling the wheel generates key
245presses <MouseDown> and <MouseUp>. The default action for these keys are:
246 <MouseDown> scroll three lines down. *<MouseDown>*
247 <S-MouseDown> scroll a full page down. *<S-MouseDown>*
248 <C-MouseDown> scroll a full page down. *<C-MouseDown>*
249 <MouseUp> scroll three lines up. *<MouseUp>*
250 <S-MouseUp> scroll a full page up. *<S-MouseUp>*
251 <C-MouseUp> scroll a full page up. *<C-MouseUp>*
252This should work in all modes, except when editing the command line.
253
254Note that <MouseDown> is used for scrolling the text down, this happens when
255you turn the mouse wheel up!
256
257You can modify this behavior by mapping the keys. For example, to make the
258scroll wheel move one line or half a page in Normal mode: >
259 :map <MouseDown> <C-Y>
260 :map <S-MouseDown> <C-U>
261 :map <MouseUp> <C-E>
262 :map <S-MouseUp> <C-D>
263You can also use Alt and Ctrl modifiers.
264
265This only works when Vim gets the scroll wheel events, of course. You can
266check if this works with the "xev" program.
267
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000268When using XFree86, the /etc/XF86Config file should have the correct entry for
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269your mouse. For FreeBSD, this entry works for a Logitech scrollmouse: >
270 Protocol "MouseMan"
271 Device "/dev/psm0"
272 ZAxisMapping 4 5
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000273See the XFree86 documentation for information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274
275 *xterm-mouse-wheel*
276To use the mouse wheel in a new xterm you only have to make the scroll wheel
277work in your Xserver, as mentioned above.
278
279To use the mouse wheel in an older xterm you must do this:
2801. Make it work in your Xserver, as mentioned above.
2812. Add translations for the xterm, so that the xterm will pass a scroll event
282 to Vim as an escape sequence.
2833. Add mappings in Vim, to interpret the escape sequences as <MouseUp> or
284 <MouseDown> keys.
285
286You can do the translations by adding this to your ~.Xdefaults file (or other
287file where your X resources are kept): >
288
289 XTerm*VT100.Translations: #override \n\
290 s<Btn4Down>: string("0x9b") string("[64~") \n\
291 s<Btn5Down>: string("0x9b") string("[65~") \n\
292 <Btn4Down>: string("0x9b") string("[62~") \n\
293 <Btn5Down>: string("0x9b") string("[63~") \n\
294 <Btn4Up>: \n\
295 <Btn5Up>:
296
297Add these mappings to your vimrc file: >
298 :map <M-Esc>[62~ <MouseDown>
299 :map! <M-Esc>[62~ <MouseDown>
300 :map <M-Esc>[63~ <MouseUp>
301 :map! <M-Esc>[63~ <MouseUp>
302 :map <M-Esc>[64~ <S-MouseDown>
303 :map! <M-Esc>[64~ <S-MouseDown>
304 :map <M-Esc>[65~ <S-MouseUp>
305 :map! <M-Esc>[65~ <S-MouseUp>
306<
307 vim:tw=78:ts=8:ft=help:norl: