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