527
|
1 *motion.txt* For Vim version 7.0aa. Last change: 2005 Sep 14
|
7
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Bram Moolenaar
|
|
5
|
|
6
|
|
7 Cursor motions *cursor-motions* *navigation*
|
|
8
|
|
9 These commands move the cursor position. If the new position is off of the
|
|
10 screen, the screen is scrolled to show the cursor (see also 'scrolljump' and
|
|
11 'scrolloff' options).
|
|
12
|
|
13 1. Motions and operators |operator|
|
|
14 2. Left-right motions |left-right-motions|
|
|
15 3. Up-down motions |up-down-motions|
|
|
16 4. Word motions |word-motions|
|
|
17 5. Text object motions |object-motions|
|
|
18 6. Text object selection |object-select|
|
|
19 7. Marks |mark-motions|
|
|
20 8. Jumps |jump-motions|
|
|
21 9. Various motions |various-motions|
|
|
22
|
|
23 General remarks:
|
|
24
|
|
25 If you want to know where you are in the file use the "CTRL-G" command
|
|
26 |CTRL-G| or the "g CTRL-G" command |g_CTRL-G|. If you set the 'ruler' option,
|
|
27 the cursor position is continuously shown in the status line (which slows down
|
|
28 Vim a little).
|
|
29
|
|
30 Experienced users prefer the hjkl keys because they are always right under
|
|
31 their fingers. Beginners often prefer the arrow keys, because they do not
|
|
32 know what the hjkl keys do. The mnemonic value of hjkl is clear from looking
|
|
33 at the keyboard. Think of j as an arrow pointing downwards.
|
|
34
|
|
35 The 'virtualedit' option can be set to make it possible to move the cursor to
|
|
36 positions where there is no character or halfway a character.
|
|
37
|
|
38 ==============================================================================
|
|
39 1. Motions and operators *operator*
|
|
40
|
|
41 The motion commands can be used after an operator command, to have the command
|
|
42 operate on the text that was moved over. That is the text between the cursor
|
|
43 position before and after the motion. Operators are generally used to delete
|
|
44 or change text. The following operators are available:
|
|
45
|
|
46 |c| c change
|
|
47 |d| d delete
|
|
48 |y| y yank into register (does not change the text)
|
|
49 |~| ~ swap case (only if 'tildeop' is set)
|
|
50 |g~| g~ swap case
|
|
51 |gu| gu make lowercase
|
|
52 |gU| gU make uppercase
|
|
53 |!| ! filter through an external program
|
|
54 |=| = filter through 'equalprg' or C-indenting if empty
|
|
55 |gq| gq text formatting
|
|
56 |g?| g? ROT13 encoding
|
|
57 |>| > shift right
|
|
58 |<| < shift left
|
|
59 |zf| zf define a fold
|
|
60
|
|
61 If the motion includes a count and the operator also had a count before it,
|
|
62 the two counts are multiplied. For example: "2d3w" deletes six words.
|
|
63
|
|
64 After applying the operator the cursor is mostly left at the start of the text
|
|
65 that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe"
|
|
66 moves the cursor leftwards to the "e" where the yank started.
|
|
67
|
|
68 *linewise* *characterwise*
|
|
69 The operator either affects whole lines, or the characters between the start
|
|
70 and end position. Generally, motions that move between lines affect lines
|
|
71 (are linewise), and motions that move within a line affect characters (are
|
|
72 characterwise). However, there are some exceptions.
|
|
73
|
|
74 *exclusive* *inclusive*
|
456
|
75 A character motion is either inclusive or exclusive. When inclusive, the
|
|
76 start and end position of the motion are included in the operation. When
|
|
77 exclusive, the last character towards the end of the buffer is not included.
|
|
78 Linewise motions always include the start and end position.
|
7
|
79
|
456
|
80 Which motions are linewise, inclusive or exclusive is mentioned with the
|
|
81 command. There are however, two general exceptions:
|
7
|
82 1. If the motion is exclusive and the end of the motion is in column 1, the
|
|
83 end of the motion is moved to the end of the previous line and the motion
|
|
84 becomes inclusive. Example: "}" moves to the first line after a paragraph,
|
|
85 but "d}" will not include that line.
|
20
|
86 *exclusive-linewise*
|
7
|
87 2. If the motion is exclusive, the end of the motion is in column 1 and the
|
|
88 start of the motion was at or before the first non-blank in the line, the
|
|
89 motion becomes linewise. Example: If a paragraph begins with some blanks
|
|
90 and you do "d}" while standing on the first non-blank, all the lines of
|
|
91 the paragraph are deleted, including the blanks. If you do a put now, the
|
|
92 deleted lines will be inserted below the cursor position.
|
|
93
|
|
94 Note that when the operator is pending (the operator command is typed, but the
|
|
95 motion isn't yet), a special set of mappings can be used. See |:omap|.
|
|
96
|
|
97 Instead of first giving the operator and then a motion you can use Visual
|
|
98 mode: mark the start of the text with "v", move the cursor to the end of the
|
|
99 text that is to be affected and then hit the operator. The text between the
|
|
100 start and the cursor position is highlighted, so you can see what text will
|
|
101 be operated upon. This allows much more freedom, but requires more key
|
|
102 strokes and has limited redo functionality. See the chapter on Visual mode
|
|
103 |Visual-mode|.
|
|
104
|
|
105 You can use a ":" command for a motion. For example "d:call FindEnd()".
|
|
106 But this can't be redone with "." if the command is more than one line.
|
|
107 This can be repeated: >
|
|
108 d:call search("f")<CR>
|
|
109 This cannot be repeated: >
|
|
110 d:if 1<CR>
|
|
111 call search("f")<CR>
|
|
112 endif<CR>
|
|
113
|
|
114
|
|
115 FORCING A MOTION TO BE LINEWISE, CHARACTERWISE OR BLOCKWISE
|
|
116
|
|
117 When a motion is not of the type you would like to use, you can force another
|
|
118 type by using "v", "V" or CTRL-V just after the operator.
|
|
119 Example: >
|
|
120 dj
|
|
121 deletes two lines >
|
|
122 dvj
|
|
123 deletes from the cursor position until the character below the cursor >
|
|
124 d<C-V>j
|
|
125 deletes the character under the cursor and the character below the cursor. >
|
|
126
|
|
127 Be careful with forcing a linewise movement to be used characterwise or
|
|
128 blockwise, the column may not always be defined.
|
|
129
|
|
130 *o_v*
|
|
131 v When used after an operator, before the motion command: Force
|
|
132 the operator to work characterwise, also when the motion is
|
|
133 linewise. If the motion was linewise, it will become
|
|
134 |exclusive|.
|
|
135 If the motion already was characterwise, toggle
|
|
136 inclusive/exclusive. This can be used to make an exclusive
|
|
137 motion inclusive and an inclusive motion exclusive.
|
|
138
|
|
139 *o_V*
|
|
140 V When used after an operator, before the motion command: Force
|
|
141 the operator to work linewise, also when the motion is
|
|
142 characterwise.
|
|
143
|
|
144 *o_CTRL-V*
|
|
145 CTRL-V When used after an operator, before the motion command: Force
|
|
146 the operator to work blockwise. This works like Visual block
|
|
147 mode selection, with the corners defined by the cursor
|
|
148 position before and after the motion.
|
|
149
|
|
150 ==============================================================================
|
|
151 2. Left-right motions *left-right-motions*
|
|
152
|
|
153 h or *h*
|
|
154 <Left> or *<Left>*
|
|
155 CTRL-H or *CTRL-H* *<BS>*
|
|
156 <BS> [count] characters to the left. |exclusive| motion.
|
|
157 Note: If you prefer <BS> to delete a character, use
|
|
158 the mapping:
|
|
159 :map CTRL-V<BS> X
|
|
160 (to enter "CTRL-V<BS>" type the CTRL-V key, followed
|
|
161 by the <BS> key)
|
|
162 See |:fixdel| if the <BS> key does not do what you
|
|
163 want.
|
|
164
|
|
165 l or *l*
|
|
166 <Right> or *<Right>* *<Space>*
|
|
167 <Space> [count] characters to the right. |exclusive| motion.
|
|
168
|
|
169 *0*
|
|
170 0 To the first character of the line. |exclusive|
|
|
171 motion. When moving up or down, stay in same screen
|
|
172 column (if possible).
|
|
173
|
|
174 *<Home>* *<kHome>*
|
|
175 <Home> To the first character of the line. |exclusive|
|
|
176 motion. When moving up or down, stay in same text
|
|
177 column (if possible). Works like "1|", which differs
|
|
178 from "0" when the line starts with a <Tab>. {not in
|
|
179 Vi}
|
|
180
|
|
181 *^*
|
|
182 ^ To the first non-blank character of the line.
|
|
183 |exclusive| motion.
|
|
184
|
|
185 *$* *<End>* *<kEnd>*
|
|
186 $ or <End> To the end of the line. When a count is given also go
|
|
187 [count - 1] lines downward |inclusive|.
|
|
188 In Visual mode the cursor goes to just after the last
|
|
189 character in the line.
|
|
190 When 'virtualedit' is active, "$" may move the cursor
|
|
191 back from past the end of the line to the last
|
|
192 character in the line.
|
|
193
|
|
194 *g_*
|
|
195 g_ To the last non-blank character of the line and
|
|
196 [count - 1] lines downward |inclusive|. {not in Vi}
|
|
197
|
|
198 *g0* *g<Home>*
|
|
199 g0 or g<Home> When lines wrap ('wrap' on): To the first character of
|
|
200 the screen line. |exclusive| motion. Differs from
|
|
201 "0" when a line is wider than the screen.
|
|
202 When lines don't wrap ('wrap' off): To the leftmost
|
|
203 character of the current line that is on the screen.
|
|
204 Differs from "0" when the first character of the line
|
|
205 is not on the screen. {not in Vi}
|
|
206
|
|
207 *g^*
|
|
208 g^ When lines wrap ('wrap' on): To the first non-blank
|
|
209 character of the screen line. |exclusive| motion.
|
|
210 Differs from "^" when a line is wider than the screen.
|
|
211 When lines don't wrap ('wrap' off): To the leftmost
|
|
212 non-blank character of the current line that is on the
|
|
213 screen. Differs from "^" when the first non-blank
|
|
214 character of the line is not on the screen. {not in
|
|
215 Vi}
|
|
216
|
|
217 *gm*
|
|
218 gm Like "g0", but half a screenwidth to the right (or as
|
|
219 much as possible). {not in Vi}
|
|
220
|
|
221 *g$* *g<End>*
|
|
222 g$ or g<End> When lines wrap ('wrap' on): To the last character of
|
|
223 the screen line and [count - 1] screen lines downward
|
|
224 |inclusive|. Differs from "$" when a line is wider
|
|
225 than the screen.
|
|
226 When lines don't wrap ('wrap' off): To the rightmost
|
|
227 character of the current line that is visible on the
|
|
228 screen. Differs from "$" when the last character of
|
|
229 the line is not on the screen or when a count is used.
|
|
230 Additionally, vertical movements keep the column,
|
|
231 instead of going to the end of the line.
|
|
232 {not in Vi}
|
|
233
|
|
234 *bar*
|
|
235 | To screen column [count] in the current line.
|
|
236 |exclusive| motion.
|
|
237
|
|
238 *f*
|
|
239 f{char} To [count]'th occurrence of {char} to the right. The
|
|
240 cursor is placed on {char} |inclusive|.
|
|
241 {char} can be entered as a digraph |digraph-arg|.
|
|
242 When 'encoding' is set to Unicode, composing
|
|
243 characters may be used, see |utf-8-char-arg|.
|
|
244 |:lmap| mappings apply to {char}. The CTRL-^ command
|
|
245 in Insert mode can be used to switch this on/off
|
|
246 |i_CTRL-^|.
|
|
247
|
|
248 *F*
|
|
249 F{char} To the [count]'th occurrence of {char} to the left.
|
456
|
250 The cursor is placed on {char} |exclusive|.
|
7
|
251 {char} can be entered like with the |f| command.
|
|
252
|
|
253 *t*
|
|
254 t{char} Till before [count]'th occurrence of {char} to the
|
|
255 right. The cursor is placed on the character left of
|
|
256 {char} |inclusive|.
|
|
257 {char} can be entered like with the |f| command.
|
|
258
|
|
259 *T*
|
|
260 T{char} Till after [count]'th occurrence of {char} to the
|
|
261 left. The cursor is placed on the character right of
|
456
|
262 {char} |exclusive|.
|
7
|
263 {char} can be entered like with the |f| command.
|
|
264
|
|
265 *;*
|
|
266 ; Repeat latest f, t, F or T [count] times.
|
|
267
|
|
268 *,*
|
|
269 , Repeat latest f, t, F or T in opposite direction
|
|
270 [count] times.
|
|
271
|
|
272 These commands move the cursor to the specified column in the current line.
|
|
273 They stop at the first column and at the end of the line, except "$", which
|
|
274 may move to one of the next lines. See 'whichwrap' option to make some of the
|
|
275 commands move across line boundaries.
|
|
276
|
|
277 ==============================================================================
|
|
278 3. Up-down motions *up-down-motions*
|
|
279
|
|
280 k or *k*
|
|
281 <Up> or *<Up>* *CTRL-P*
|
|
282 CTRL-P [count] lines upward |linewise|.
|
|
283
|
|
284 j or *j*
|
|
285 <Down> or *<Down>*
|
|
286 CTRL-J or *CTRL-J*
|
|
287 <NL> or *<NL>* *CTRL-N*
|
|
288 CTRL-N [count] lines downward |linewise|.
|
|
289
|
|
290 gk or *gk* *g<Up>*
|
|
291 g<Up> [count] display lines upward. |exclusive| motion.
|
|
292 Differs from 'k' when lines wrap, and when used with
|
|
293 an operator, because it's not linewise. {not in Vi}
|
|
294
|
|
295 gj or *gj* *g<Down>*
|
|
296 g<Down> [count] display lines downward. |exclusive| motion.
|
|
297 Differs from 'j' when lines wrap, and when used with
|
|
298 an operator, because it's not linewise. {not in Vi}
|
|
299
|
|
300 *-*
|
|
301 - <minus> [count] lines upward, on the first non-blank
|
|
302 character |linewise|.
|
|
303
|
|
304 + or *+*
|
|
305 CTRL-M or *CTRL-M* *<CR>*
|
|
306 <CR> [count] lines downward, on the first non-blank
|
|
307 character |linewise|.
|
|
308
|
|
309 *_*
|
|
310 _ <underscore> [count] - 1 lines downward, on the first non-blank
|
|
311 character |linewise|.
|
|
312
|
|
313 *G*
|
|
314 G Goto line [count], default last line, on the first
|
|
315 non-blank character |linewise|. If 'startofline' not
|
|
316 set, keep the same column.
|
|
317
|
|
318 *<C-End>*
|
|
319 <C-End> Goto line [count], default last line, on the last
|
|
320 character |inclusive|. {not in Vi}
|
|
321
|
|
322 <C-Home> or *gg* *<C-Home>*
|
|
323 gg Goto line [count], default first line, on the first
|
|
324 non-blank character |linewise|. If 'startofline' not
|
|
325 set, keep the same column.
|
|
326
|
|
327 :[range] Set the cursor on the specified line number. If
|
|
328 there are several numbers, the last one is used.
|
|
329
|
|
330 *N%*
|
|
331 {count}% Go to {count} percentage in the file, on the first
|
|
332 non-blank in the line |linewise|. To compute the new
|
|
333 line number this formula is used:
|
|
334 ({count} * number-of-lines + 99) / 100
|
|
335 See also 'startofline' option. {not in Vi}
|
|
336
|
|
337 :[range]go[to] [count] *:go* *:goto* *go*
|
|
338 [count]go Go to {count} byte in the buffer. Default [count] is
|
|
339 one, start of the file. When giving [range], the
|
|
340 last number in it used as the byte count. End-of-line
|
|
341 characters are counted depending on the current
|
|
342 'fileformat' setting.
|
|
343 {not in Vi}
|
|
344 {not available when compiled without the
|
|
345 |+byte_offset| feature}
|
|
346
|
|
347 These commands move to the specified line. They stop when reaching the first
|
|
348 or the last line. The first two commands put the cursor in the same column
|
|
349 (if possible) as it was after the last command that changed the column,
|
|
350 except after the "$" command, then the cursor will be put on the last
|
|
351 character of the line.
|
|
352
|
161
|
353 If "k", "-" or CTRL-P is used with a [count] and there are less than [count]
|
|
354 lines above the cursor and the 'cpo' option includes the "-" flag it is an
|
|
355 error. |cpo--|.
|
|
356
|
7
|
357 ==============================================================================
|
|
358 4. Word motions *word-motions*
|
|
359
|
|
360 <S-Right> or *<S-Right>* *w*
|
|
361 w [count] words forward. |exclusive| motion.
|
|
362
|
|
363 <C-Right> or *<C-Right>* *W*
|
|
364 W [count] WORDS forward. |exclusive| motion.
|
|
365
|
|
366 *e*
|
|
367 e Forward to the end of word [count] |inclusive|.
|
|
368
|
|
369 *E*
|
|
370 E Forward to the end of WORD [count] |inclusive|.
|
|
371
|
|
372 <S-Left> or *<S-Left>* *b*
|
|
373 b [count] words backward. |exclusive| motion.
|
|
374
|
|
375 <C-Left> or *<C-Left>* *B*
|
|
376 B [count] WORDS backward. |exclusive| motion.
|
|
377
|
|
378 *ge*
|
|
379 ge Backward to the end of word [count] |inclusive|.
|
|
380
|
|
381 *gE*
|
|
382 gE Backward to the end of WORD [count] |inclusive|.
|
|
383
|
|
384 These commands move over words or WORDS.
|
|
385 *word*
|
|
386 A word consists of a sequence of letters, digits and underscores, or a
|
|
387 sequence of other non-blank characters, separated with white space (spaces,
|
|
388 tabs, <EOL>). This can be changed with the 'iskeyword' option.
|
|
389 *WORD*
|
|
390 A WORD consists of a sequence of non-blank characters, separated with white
|
|
391 space. An empty line is also considered to be a word and a WORD.
|
|
392
|
|
393 A sequence of folded lines is counted for one word of a single character.
|
|
394 "w" and "W", "e" and "E" move to the start/end of the first word or WORD after
|
|
395 a range of folded lines. "b" and "B" move to the start of the first word or
|
|
396 WORD before the fold.
|
|
397
|
|
398 Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
|
|
399 on a non-blank. This is because "cw" is interpreted as change-word, and a
|
|
400 word does not include the following white space. {Vi: "cw" when on a blank
|
|
401 followed by other blanks changes only the first blank; this is probably a
|
|
402 bug, because "dw" deletes all the blanks}
|
|
403
|
|
404 Another special case: When using the "w" motion in combination with an
|
|
405 operator and the last word moved over is at the end of a line, the end of
|
|
406 that word becomes the end of the operated text, not the first word in the
|
|
407 next line.
|
|
408
|
|
409 The original Vi implementation of "e" is buggy. For example, the "e" command
|
|
410 will stop on the first character of a line if the previous line was empty.
|
|
411 But when you use "2e" this does not happen. In Vim "ee" and "2e" are the
|
|
412 same, which is more logical. However, this causes a small incompatibility
|
|
413 between Vi and Vim.
|
|
414
|
|
415 ==============================================================================
|
|
416 5. Text object motions *object-motions*
|
|
417
|
|
418 *(*
|
|
419 ( [count] sentences backward. |exclusive| motion.
|
|
420
|
|
421 *)*
|
|
422 ) [count] sentences forward. |exclusive| motion.
|
|
423
|
|
424 *{*
|
|
425 { [count] paragraphs backward. |exclusive| motion.
|
|
426
|
|
427 *}*
|
|
428 } [count] paragraphs forward. |exclusive| motion.
|
|
429
|
|
430 *]]*
|
|
431 ]] [count] sections forward or to the next '{' in the
|
20
|
432 first column. When used after an operator, then also
|
|
433 stops below a '}' in the first column. |exclusive|
|
|
434 Note that |exclusive-linewise| often applies.
|
7
|
435
|
|
436 *][*
|
|
437 ][ [count] sections forward or to the next '}' in the
|
20
|
438 first column. |exclusive|
|
|
439 Note that |exclusive-linewise| often applies.
|
7
|
440
|
|
441 *[[*
|
|
442 [[ [count] sections backward or to the previous '{' in
|
20
|
443 the first column. |exclusive|
|
|
444 Note that |exclusive-linewise| often applies.
|
7
|
445
|
|
446 *[]*
|
|
447 [] [count] sections backward or to the previous '}' in
|
20
|
448 the first column. |exclusive|
|
|
449 Note that |exclusive-linewise| often applies.
|
7
|
450
|
|
451 These commands move over three kinds of text objects.
|
|
452
|
|
453 *sentence*
|
|
454 A sentence is defined as ending at a '.', '!' or '?' followed by either the
|
|
455 end of a line, or by a space or tab. Any number of closing ')', ']', '"'
|
|
456 and ''' characters may appear after the '.', '!' or '?' before the spaces,
|
|
457 tabs or end of line. A paragraph and section boundary is also a sentence
|
|
458 boundary.
|
|
459 If the 'J' flag is present in 'cpoptions', at least two spaces have to
|
|
460 follow the punctuation mark; <Tab>s are not recognized as white space.
|
|
461 The definition of a sentence cannot be changed.
|
|
462
|
|
463 *paragraph*
|
|
464 A paragraph begins after each empty line, and also at each of a set of
|
|
465 paragraph macros, specified by the pairs of characters in the 'paragraphs'
|
|
466 option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the
|
|
467 macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in the
|
164
|
468 first column). A section boundary is also a paragraph boundary.
|
|
469 Note that a blank line (only containing white space) is NOT a paragraph
|
|
470 boundary.
|
|
471 Also note that this does not include a '{' or '}' in the first column. When
|
|
472 the '{' flag is in 'cpoptions' then '{' in the first column is used as a
|
|
473 paragraph boundary |posix|.
|
7
|
474
|
|
475 *section*
|
|
476 A section begins after a form-feed (<C-L>) in the first column and at each of
|
|
477 a set of section macros, specified by the pairs of characters in the
|
|
478 'sections' option. The default is "SHNHH HUnhsh", which defines a section to
|
|
479 start at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh".
|
|
480
|
|
481 The "]" and "[" commands stop at the '{' or '}' in the first column. This is
|
|
482 useful to find the start or end of a function in a C program. Note that the
|
|
483 first character of the command determines the search direction and the
|
|
484 second character the type of brace found.
|
|
485
|
|
486 If your '{' or '}' are not in the first column, and you would like to use "[["
|
|
487 and "]]" anyway, try these mappings: >
|
|
488 :map [[ ?{<CR>w99[{
|
|
489 :map ][ /}<CR>b99]}
|
|
490 :map ]] j0[[%/{<CR>
|
|
491 :map [] k$][%?}<CR>
|
|
492 [type these literally, see |<>|]
|
|
493
|
|
494 ==============================================================================
|
|
495 6. Text object selection *object-select* *text-objects*
|
|
496 *v_a* *v_i*
|
|
497
|
|
498 This is a series of commands that can only be used while in Visual mode or
|
|
499 after an operator. The commands that start with "a" select "a"n object
|
|
500 including white space, the commands starting with "i" select an "inner" object
|
|
501 without white space, or just the white space. Thus the "inner" commands
|
|
502 always select less text than the "a" commands.
|
|
503
|
|
504 These commands are {not in Vi}.
|
|
505 These commands are not available when the |+textobjects| feature has been
|
|
506 disabled at compile time.
|
|
507 *v_aw* *aw*
|
|
508 aw "a word", select [count] words (see |word|).
|
|
509 Leading or trailing white space is included, but not
|
|
510 counted.
|
|
511 When used in Visual linewise mode "aw" switches to
|
|
512 Visual characterwise mode.
|
|
513
|
|
514 *v_iw* *iw*
|
|
515 iw "inner word", select [count] words (see |word|).
|
|
516 White space between words is counted too.
|
|
517 When used in Visual linewise mode "iw" switches to
|
|
518 Visual characterwise mode.
|
|
519
|
|
520 *v_aW* *aW*
|
|
521 aW "a WORD", select [count] WORDs (see |WORD|).
|
|
522 Leading or trailing white space is included, but not
|
|
523 counted.
|
|
524 When used in Visual linewise mode "aW" switches to
|
|
525 Visual characterwise mode.
|
|
526
|
|
527 *v_iW* *iW*
|
|
528 iW "inner WORD", select [count] WORDs (see |WORD|).
|
|
529 White space between words is counted too.
|
|
530 When used in Visual linewise mode "iW" switches to
|
|
531 Visual characterwise mode.
|
|
532
|
|
533 *v_as* *as*
|
|
534 as "a sentence", select [count] sentences (see
|
|
535 |sentence|).
|
|
536 When used in Visual mode it is made characterwise.
|
|
537
|
|
538 *v_is* *is*
|
|
539 is "inner sentence", select [count] sentences (see
|
|
540 |sentence|).
|
|
541 When used in Visual mode it is made characterwise.
|
|
542
|
|
543 *v_ap* *ap*
|
|
544 ap "a paragraph", select [count] paragraphs (see
|
|
545 |paragraph|).
|
|
546 Exception: a blank line (only containing white space)
|
|
547 is also a paragraph boundary.
|
|
548 When used in Visual mode it is made linewise.
|
|
549
|
|
550 *v_ip* *ip*
|
|
551 ip "inner paragraph", select [count] paragraphs (see
|
|
552 |paragraph|).
|
|
553 Exception: a blank line (only containing white space)
|
|
554 is also a paragraph boundary.
|
|
555 When used in Visual mode it is made linewise.
|
|
556
|
|
557 a] *v_a]* *v_a[* *a]* *a[*
|
|
558 a[ "a [] block", select [count] '[' ']' blocks. This
|
|
559 goes backwards to the [count] unclosed '[', and finds
|
|
560 the matching ']'. The enclosed text is selected,
|
|
561 including the '[' and ']'.
|
|
562 When used in Visual mode it is made characterwise.
|
|
563
|
|
564 i] *v_i]* *v_i[* *i]* *i[*
|
|
565 i[ "inner [] block", select [count] '[' ']' blocks. This
|
|
566 goes backwards to the [count] unclosed '[', and finds
|
|
567 the matching ']'. The enclosed text is selected,
|
|
568 excluding the '[' and ']'.
|
|
569 When used in Visual mode it is made characterwise.
|
|
570
|
|
571 a) *v_a)* *a)* *a(*
|
|
572 a( *v_ab* *v_a(* *ab*
|
|
573 ab "a block", select [count] blocks, from "[count] [(" to
|
|
574 the matching ')', including the '(' and ')' (see
|
|
575 |[(|). Does not include white space outside of the
|
|
576 parenthesis.
|
|
577 When used in Visual mode it is made characterwise.
|
|
578
|
|
579 i) *v_i)* *i)* *i(*
|
|
580 i( *v_ib* *v_i(* *ib*
|
|
581 ib "inner block", select [count] blocks, from "[count] [("
|
|
582 to the matching ')', excluding the '(' and ')' (see
|
|
583 |[(|).
|
|
584 When used in Visual mode it is made characterwise.
|
|
585
|
|
586 a> *v_a>* *v_a<* *a>* *a<*
|
|
587 a< "a <> block", select [count] <> blocks, from the
|
|
588 [count]'th unmatched '<' backwards to the matching
|
|
589 '>', including the '<' and '>'.
|
|
590 When used in Visual mode it is made characterwise.
|
|
591
|
|
592 i> *v_i>* *v_i<* *i>* *i<*
|
|
593 i< "inner <> block", select [count] <> blocks, from
|
|
594 the [count]'th unmatched '<' backwards to the matching
|
|
595 '>', excluding the '<' and '>'.
|
|
596 When used in Visual mode it is made characterwise.
|
|
597
|
422
|
598 *v_at* *at*
|
|
599 at "a tag block", select [count] tag blocks, from the
|
|
600 [count]'th unmatched "<aaa>" backwards to the matching
|
|
601 "</aaa>", including the "<aaa>" and "</aaa>".
|
|
602 See |tag-blocks| about the details.
|
|
603 When used in Visual mode it is made characterwise.
|
|
604
|
|
605 *v_it* *it*
|
|
606 it "inner tag block", select [count] tag blocks, from the
|
|
607 [count]'th unmatched "<aaa>" backwards to the matching
|
|
608 "</aaa>", excluding the "<aaa>" and "</aaa>".
|
|
609 See |tag-blocks| about the details.
|
|
610 When used in Visual mode it is made characterwise.
|
|
611
|
7
|
612 a} *v_a}* *a}* *a{*
|
|
613 a{ *v_aB* *v_a{* *aB*
|
|
614 aB "a Block", select [count] Blocks, from "[count] [{" to
|
|
615 the matching '}', including the '{' and '}' (see
|
|
616 |[{|).
|
|
617 When used in Visual mode it is made characterwise.
|
|
618
|
|
619 i} *v_i}* *i}* *i{*
|
|
620 i{ *v_iB* *v_i{* *iB*
|
|
621 iB "inner Block", select [count] Blocks, from "[count] [{"
|
|
622 to the matching '}', excluding the '{' and '}' (see
|
|
623 |[{|).
|
|
624 When used in Visual mode it is made characterwise.
|
|
625
|
12
|
626 a" *v_aquote* *aquote*
|
|
627 a' *v_a'* *a'*
|
|
628 a` *v_a`* *a`*
|
|
629 "a quoted string". Selects the text from the previous
|
|
630 quote until the next quote. The 'quoteescape' is used
|
|
631 to skip escaped quotes.
|
|
632 When the cursor starts on a quote, Vim will figure out
|
|
633 which quote pairs form a string by searching from the
|
|
634 start of the line.
|
|
635 Any trailing or leading white space is included.
|
|
636 When used in Visual mode it is made characterwise.
|
|
637 Repeating this object in Visual mode another string is
|
|
638 included. A count is currently not used.
|
|
639
|
|
640 i" *v_iquote* *iquote*
|
|
641 i' *v_i'* *i'*
|
|
642 i` *v_i`* *i`*
|
|
643 Like a", a' and a`, but exclude the quotes and
|
|
644 repeating won't extend the Visual selection.
|
527
|
645 Special case: With a count of 2 the quotes are
|
|
646 included, but no extra white space as with a"/a'/a`.
|
12
|
647
|
7
|
648 When used after an operator:
|
|
649 For non-block objects:
|
|
650 For the "a" commands: The operator applies to the object and the white
|
|
651 space after the object. If there is no white space after the object
|
|
652 or when the cursor was in the white space before the object, the white
|
|
653 space before the object is included.
|
|
654 For the "inner" commands: If the cursor was on the object, the
|
|
655 operator applies to the object. If the cursor was on white space, the
|
|
656 operator applies to the white space.
|
|
657 For a block object:
|
|
658 The operator applies to the block where the cursor is in, or the block
|
|
659 on which the cursor is on one of the braces. For the "inner" commands
|
|
660 the surrounding braces are excluded. For the "a" commands, the braces
|
|
661 are included.
|
|
662
|
|
663 When used in Visual mode:
|
|
664 When start and end of the Visual area are the same (just after typing "v"):
|
|
665 One object is selected, the same as for using an operator.
|
|
666 When start and end of the Visual area are not the same:
|
|
667 For non-block objects the area is extended by one object or the white
|
|
668 space up to the next object, or both for the "a" objects. The
|
|
669 direction in which this happens depends on which side of the Visual
|
|
670 area the cursor is. For the block objects the block is extended one
|
|
671 level outwards.
|
|
672
|
|
673 For illustration, here is a list of delete commands, grouped from small to big
|
|
674 objects. Note that for a single character and a whole line the existing vi
|
|
675 movement commands are used.
|
|
676 "dl" delete character (alias: "x") |dl|
|
|
677 "diw" delete inner word *diw*
|
|
678 "daw" delete a word *daw*
|
|
679 "diW" delete inner WORD (see |WORD|) *diW*
|
|
680 "daW" delete a WORD (see |WORD|) *daW*
|
|
681 "dd" delete one line |dd|
|
|
682 "dis" delete inner sentence *dis*
|
|
683 "das" delete a sentence *das*
|
|
684 "dib" delete inner '(' ')' block *dib*
|
|
685 "dab" delete a '(' ')' block *dab*
|
|
686 "dip" delete inner paragraph *dip*
|
|
687 "dap" delete a paragraph *dap*
|
|
688 "diB" delete inner '{' '}' block *diB*
|
|
689 "daB" delete a '{' '}' block *daB*
|
|
690
|
|
691 Note the difference between using a movement command and an object. The
|
|
692 movement command operates from here (cursor position) to where the movement
|
|
693 takes us. When using an object the whole object is operated upon, no matter
|
|
694 where on the object the cursor is. For example, compare "dw" and "daw": "dw"
|
|
695 deletes from the cursor position to the start of the next word, "daw" deletes
|
|
696 the word under the cursor and the space after or before it.
|
|
697
|
422
|
698
|
|
699 Tag blocks *tag-blocks*
|
|
700
|
|
701 For the "it" and "at" text objects an attempt is done to select blocks between
|
|
702 matching tags for HTML and XML. But since these are not completely compatible
|
|
703 there are a few restrictions.
|
|
704
|
|
705 The normal method is to select a <tag> until the matching </tag>. For "at"
|
|
706 the tags are included, for "it" they are excluded. But when "it" is repeated
|
|
707 the tags will be included (otherwise nothing would change).
|
|
708
|
|
709 "<aaa/>" items are skipped. Case is ignored, also for XML where case does
|
|
710 matter.
|
|
711
|
|
712 In HTML it is possible to have a tag like <br> or <meta ...> without a
|
|
713 matching end tag. These are ignored.
|
|
714
|
|
715 The text objects are tolerant about mistakes. Stray end tags are ignored.
|
|
716
|
7
|
717 ==============================================================================
|
|
718 7. Marks *mark-motions* *E20* *E78*
|
|
719
|
|
720 Jumping to a mark can be done in two ways:
|
|
721 1. With ` (backtick): The cursor is positioned at the specified location
|
|
722 and the motion is |exclusive|.
|
|
723 2. With ' (single quote): The cursor is positioned on the first non-blank
|
|
724 character in the line of the specified location and
|
|
725 the motion is linewise.
|
|
726
|
|
727 *m* *mark* *Mark*
|
|
728 m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move
|
|
729 the cursor, this is not a motion command).
|
|
730
|
|
731 *m'* *m`*
|
|
732 m' or m` Set the previous context mark. This can be jumped to
|
|
733 with the "''" or "``" command (does not move the
|
|
734 cursor, this is not a motion command).
|
|
735
|
|
736 *m[* *m]*
|
|
737 m[ or m] Set the |'[| or |']| mark. Useful when an operator is
|
|
738 to be simulated by multiple commands. (does not move
|
|
739 the cursor, this is not a motion command).
|
|
740
|
|
741 *:ma* *:mark* *E191*
|
9
|
742 :[range]ma[rk] {a-zA-Z'}
|
|
743 Set mark {a-zA-Z'} at last line number in [range],
|
7
|
744 column 0. Default is cursor line.
|
|
745
|
|
746 *:k*
|
9
|
747 :[range]k{a-zA-Z'} Same as :mark, but the space before the mark name can
|
7
|
748 be omitted.
|
|
749
|
|
750 *'* *'a* *`* *`a*
|
|
751 '{a-z} `{a-z} Jump to the mark {a-z}.
|
|
752
|
|
753 *'A* *'0* *`A* *`0*
|
|
754 '{A-Z0-9} `{A-Z0-9} To the mark {A-Z0-9} in the correct file (not a motion
|
|
755 command when in another file). {not in Vi}
|
|
756
|
|
757 *g'* *g'a* *g`* *g`a*
|
|
758 g'{mark} g`{mark}
|
|
759 Jump to the {mark}, but don't change the jumplist when
|
|
760 jumping within the current buffer. Example: >
|
|
761 g`"
|
|
762 < jumps to the last known position in a file. See
|
9
|
763 $VIMRUNTIME/vimrc_example.vim.
|
|
764 Also see |:keepjumps|.
|
|
765 {not in Vi}
|
7
|
766
|
|
767 *:marks*
|
|
768 :marks List all the current marks (not a motion command).
|
|
769 The |'(|, |')|, |'{| and |'}| marks are not listed.
|
|
770 {not in Vi}
|
|
771 *E283*
|
|
772 :marks {arg} List the marks that are mentioned in {arg} (not a
|
|
773 motion command). For example: >
|
|
774 :marks aB
|
|
775 < to list marks 'a' and 'B'. {not in Vi}
|
|
776
|
24
|
777 *:delm* *:delmarks*
|
|
778 :delm[arks] {marks} Delete the specified marks. Marks that can be deleted
|
|
779 include A-Z and 0-9. You cannot delete the ' mark.
|
|
780 They can be specified by giving the list of mark
|
|
781 names, or with a range, separated with a dash. Spaces
|
|
782 are ignored. Examples: >
|
|
783 :delmarks a deletes mark a
|
|
784 :delmarks a b 1 deletes marks a, b and 1
|
|
785 :delmarks Aa deletes marks A and a
|
|
786 :delmarks p-z deletes marks in the range p to z
|
|
787 :delmarks ^.[] deletes marks ^ . [ ]
|
|
788 :delmarks \" deletes mark "
|
|
789 < {not in Vi}
|
|
790
|
|
791 :delm[arks]! Delete all marks for the current buffer, but not marks
|
|
792 A-Z or 0-9.
|
|
793 {not in Vi}
|
|
794
|
7
|
795 A mark is not visible in any way. It is just a position in the file that is
|
|
796 remembered. Do not confuse marks with named registers, they are totally
|
|
797 unrelated.
|
|
798
|
|
799 'a - 'z lowercase marks, valid within one file
|
|
800 'A - 'Z uppercase marks, also called file marks, valid between files
|
|
801 '0 - '9 numbered marks, set from .viminfo file
|
|
802
|
|
803 Lowercase marks 'a to 'z are remembered as long as the file remains in the
|
|
804 buffer list. If you remove the file from the buffer list, all its marks are
|
|
805 lost. If you delete a line that contains a mark, that mark is erased.
|
|
806
|
|
807 To delete a mark: Create a new line, position the mark there, delete the line.
|
|
808 E.g.: "o<Esc>mxdd". This does change the file though. Using "u" won't work,
|
|
809 it also restores marks.
|
|
810
|
|
811 Lowercase marks can be used in combination with operators. For example: "d't"
|
|
812 deletes the lines from the cursor position to mark 't'. Hint: Use mark 't' for
|
|
813 Top, 'b' for Bottom, etc.. Lowercase marks are restored when using undo and
|
|
814 redo.
|
|
815
|
|
816 Uppercase marks 'A to 'Z include the file name. {Vi: no uppercase marks} You
|
|
817 can use them to jump from file to file. You can only use an uppercase mark
|
|
818 with an operator if the mark is in the current file. The line number of the
|
|
819 mark remains correct, even if you insert/delete lines or edit another file for
|
|
820 a moment. When the 'viminfo' option is not empty, uppercase marks are kept in
|
|
821 the .viminfo file. See |viminfo-file-marks|.
|
|
822
|
|
823 Numbered marks '0 to '9 are quite different. They can not be set directly.
|
|
824 They are only present when using a viminfo file |viminfo-file|. Basically '0
|
|
825 is the location of the cursor when you last exited Vim, '1 the last but one
|
|
826 time, etc. Use the "r" flag in 'viminfo' to specify files for which no
|
|
827 Numbered mark should be stored. See |viminfo-file-marks|.
|
|
828
|
|
829
|
|
830 *'[* *`[*
|
|
831 '[ `[ To the first character of the previously changed
|
|
832 or yanked text. {not in Vi}
|
|
833
|
|
834 *']* *`]*
|
|
835 '] `] To the last character of the previously changed or
|
|
836 yanked text. {not in Vi}
|
|
837
|
|
838 After executing an operator the Cursor is put at the beginning of the text
|
|
839 that was operated upon. After a put command ("p" or "P") the cursor is
|
|
840 sometimes placed at the first inserted line and sometimes on the last inserted
|
|
841 character. The four commands above put the cursor at either end. Example:
|
|
842 After yanking 10 lines you want to go to the last one of them: "10Y']". After
|
|
843 inserting several lines with the "p" command you want to jump to the lowest
|
|
844 inserted line: "p']". This also works for text that has been inserted.
|
|
845
|
|
846 Note: After deleting text, the start and end positions are the same, except
|
|
847 when using blockwise Visual mode. These commands do not work when no change
|
|
848 was made yet in the current file.
|
|
849
|
|
850 *'<* *`<*
|
|
851 '< `< To the first character of the last selected Visual
|
|
852 area in the current buffer. {not in Vi}.
|
|
853
|
|
854 *'>* *`>*
|
|
855 '> `> To the last character of the last selected Visual
|
|
856 area in the current buffer. {not in Vi}.
|
|
857
|
|
858 *''* *``*
|
36
|
859 '' `` To the position before the latest jump, or where the
|
|
860 last "m'" or "m`" command was given. Not set when the
|
7
|
861 |:keepjumps| command modifier was used.
|
|
862 Also see |restore-position|.
|
|
863
|
|
864 *'quote* *`quote*
|
|
865 '" `" To the cursor position when last exiting the current
|
|
866 buffer. Defaults to the first character of the first
|
|
867 line. See |last-position-jump| for how to use this
|
|
868 for each opened file.
|
|
869 Only one position is remembered per buffer, not one
|
|
870 for each window. As long as the buffer is visible in
|
|
871 a window the position won't be changed.
|
|
872 {not in Vi}.
|
|
873
|
|
874 *'^* *`^*
|
|
875 '^ `^ To the position where the cursor was the last time
|
42
|
876 when Insert mode was stopped. This is used by the
|
|
877 |gi| command. Not set when the |:keepjumps| command
|
7
|
878 modifier was used. {not in Vi}
|
|
879
|
|
880 *'.* *`.*
|
|
881 '. `. To the position where the last change was made. The
|
|
882 position is at or near where the change started.
|
|
883 Sometimes a command is executed as several changes,
|
|
884 then the position can be near the end of what the
|
|
885 command changed. For example when inserting a word,
|
|
886 the position will be on the last character.
|
|
887 {not in Vi}
|
|
888
|
|
889 *'(* *`(*
|
|
890 '( `( To the start of the current sentence, like the |(|
|
|
891 command. {not in Vi}
|
|
892
|
|
893 *')* *`)*
|
|
894 ') `) To the end of the current sentence, like the |)|
|
|
895 command. {not in Vi}
|
|
896
|
|
897 *'{* *`{*
|
|
898 '{ `{ To the start of the current paragraph, like the |{|
|
|
899 command. {not in Vi}
|
|
900
|
|
901 *'}* *`}*
|
|
902 '} `} To the end of the current paragraph, like the |}|
|
|
903 command. {not in Vi}
|
|
904
|
|
905 These commands are not marks themselves, but jump to a mark:
|
|
906
|
|
907 *]'*
|
|
908 ]' [count] times to next line with a lowercase mark below
|
|
909 the cursor, on the first non-blank character in the
|
|
910 line. {not in Vi}
|
|
911
|
|
912 *]`*
|
|
913 ]` [count] times to lowercase mark after the cursor. {not
|
|
914 in Vi}
|
|
915
|
|
916 *['*
|
|
917 [' [count] times to previous line with a lowercase mark
|
|
918 before the cursor, on the first non-blank character in
|
|
919 the line. {not in Vi}
|
|
920
|
|
921 *[`*
|
|
922 [` [count] times to lowercase mark before the cursor.
|
|
923 {not in Vi}
|
|
924
|
|
925
|
|
926 :loc[kmarks] {command} *:loc* *:lockmarks*
|
|
927 Execute {command} without adjusting marks. This is
|
|
928 useful when changing text in a way that the line count
|
|
929 will be the same when the change has completed.
|
|
930 WARNING: When the line count does change, marks below
|
|
931 the change will keep their line number, thus move to
|
|
932 another text line.
|
|
933 These items will not be adjusted for deleted/inserted
|
|
934 lines:
|
|
935 - lower case letter marks 'a - 'z
|
|
936 - upper case letter marks 'A - 'Z
|
|
937 - numbered marks '0 - '9
|
|
938 - last insert position '^
|
|
939 - last change position '.
|
|
940 - the Visual area '< and '>
|
|
941 - line numbers in placed signs
|
|
942 - line numbers in quickfix positions
|
|
943 - positions in the |jumplist|
|
|
944 - positions in the |tagstack|
|
|
945 These items will still be adjusted:
|
|
946 - previous context mark ''
|
|
947 - the cursor position
|
|
948 - the view of a window on a buffer
|
|
949 - folds
|
|
950 - diffs
|
|
951
|
|
952 :kee[pmarks] {command} *:kee* *:keepmarks*
|
|
953 Currently only has effect for the filter command
|
|
954 |:range!|:
|
|
955 - When the number of lines after filtering is equal to
|
|
956 or larger than before, all marks are kept at the
|
|
957 same line number.
|
|
958 - When the number of lines decreases, the marks in the
|
9
|
959 lines that disappeared are deleted.
|
7
|
960 In any case the marks below the filtered text have
|
|
961 their line numbers adjusted, thus stick to the text,
|
|
962 as usual.
|
|
963 When the 'R' flag is missing from 'cpoptions' this has
|
|
964 the same effect as using ":keepmarks".
|
|
965
|
|
966 *:keepj* *:keepjumps*
|
|
967 :keepj[umps] {command}
|
9
|
968 Moving around in {command} does not change the |''|,
|
|
969 |'.| and |'^| marks, the |jumplist| or the
|
|
970 |changelist|.
|
|
971 Useful when making a change or inserting text
|
|
972 automatically and the user doesn't want to go to this
|
|
973 position. E.g., when updating a "Last change"
|
|
974 timestamp in the first line: >
|
|
975
|
|
976 :let lnum = getline(".")
|
|
977 :keepjumps normal gg
|
|
978 :call SetLastChange()
|
|
979 :keepjumps exe "normal " . lnum . "G"
|
|
980 <
|
|
981 Note that ":keepjumps" must be used for every command.
|
|
982 When invoking a function the commands in that function
|
85
|
983 can still change the jumplist. Also, for
|
|
984 ":keepjumps exe 'command '" the "command" won't keep
|
|
985 jumps. Instead use: ":exe 'keepjumps command'"
|
7
|
986
|
|
987 ==============================================================================
|
|
988 8. Jumps *jump-motions*
|
|
989
|
|
990 A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
|
|
991 "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
|
|
992 the commands that start editing a new file. If you make the cursor "jump"
|
|
993 with one of these commands, the position of the cursor before the jump is
|
|
994 remembered. You can return to that position with the "''" and "``" command,
|
|
995 unless the line containing that position was changed or deleted.
|
|
996
|
|
997 *CTRL-O*
|
|
998 CTRL-O Go to [count] Older cursor position in jump list
|
|
999 (not a motion command). {not in Vi}
|
|
1000 {not available without the +jumplist feature}
|
|
1001
|
|
1002 <Tab> or *CTRL-I* *<Tab>*
|
|
1003 CTRL-I Go to [count] newer cursor position in jump list
|
|
1004 (not a motion command).
|
|
1005 In a |quickfix-window| it takes you to the position of
|
|
1006 the error under the cursor.
|
|
1007 {not in Vi}
|
|
1008 {not available without the +jumplist feature}
|
|
1009
|
|
1010 *:ju* *:jumps*
|
|
1011 :ju[mps] Print the jump list (not a motion command). {not in
|
|
1012 Vi} {not available without the +jumplist feature}
|
|
1013
|
|
1014 *jumplist*
|
|
1015 Jumps are remembered in a jump list. With the CTRL-O and CTRL-I command you
|
|
1016 can go to cursor positions before older jumps, and back again. Thus you can
|
|
1017 move up and down the list. There is a separate jump list for each window.
|
|
1018 The maximum number of entries is fixed at 100.
|
|
1019 {not available without the +jumplist feature}
|
|
1020
|
|
1021 For example, after three jump commands you have this jump list:
|
|
1022
|
|
1023 jump line col file/line ~
|
|
1024 3 1 0 some text ~
|
|
1025 2 70 0 another line ~
|
|
1026 1 1154 23 end. ~
|
|
1027 > ~
|
|
1028
|
|
1029 The "file/line" column shows the file name, or the text at the jump if it is
|
|
1030 in the current file (an indent is removed and a long line is truncated to fit
|
|
1031 in the window).
|
|
1032
|
|
1033 You are currently in line 1167. If you then use the CTRL-O command, the
|
|
1034 cursor is put in line 1154. This results in:
|
|
1035
|
|
1036 jump line col file/line ~
|
|
1037 2 1 0 some text ~
|
|
1038 1 70 0 another line ~
|
|
1039 > 0 1154 23 end. ~
|
|
1040 1 1167 0 foo bar ~
|
|
1041
|
|
1042 The pointer will be set at the last used jump position. The next CTRL-O
|
|
1043 command will use the entry above it, the next CTRL-I command will use the
|
|
1044 entry below it. If the pointer is below the last entry, this indicates that
|
|
1045 you did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command
|
|
1046 will cause the cursor position to be added to the jump list, so you can get
|
|
1047 back to the position before the CTRL-O. In this case this is line 1167.
|
|
1048
|
|
1049 With more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I
|
|
1050 you can go back to 1154 and 1167 again. Note that the number in the "jump"
|
|
1051 column indicates the count for the CTRL-O or CTRL-I command that takes you to
|
|
1052 this position.
|
|
1053
|
|
1054 If you use a jump command, the current line number is inserted at the end of
|
|
1055 the jump list. If the same line was already in the jump list, it is removed.
|
|
1056 The result is that when repeating CTRL-O you will get back to old positions
|
|
1057 only once.
|
|
1058
|
|
1059 When the |:keepjumps| command modifier is used, jumps are not stored in the
|
|
1060 jumplist.
|
|
1061
|
|
1062 After the CTRL-O command that got you into line 1154 you could give another
|
|
1063 jump command (e.g., "G"). The jump list would then become:
|
|
1064
|
|
1065 jump line col file/line ~
|
|
1066 4 1 0 some text ~
|
|
1067 3 70 0 another line ~
|
|
1068 2 1167 0 foo bar ~
|
|
1069 1 1154 23 end. ~
|
|
1070 > ~
|
|
1071
|
|
1072 The line numbers will be adjusted for deleted and inserted lines. This fails
|
|
1073 if you stop editing a file without writing, like with ":n!".
|
|
1074
|
|
1075 When you split a window, the jumplist will be copied to the new window.
|
|
1076
|
|
1077 If you have included the ' item in the 'viminfo' option the jumplist will be
|
|
1078 stored in the viminfo file and restored when starting Vim.
|
|
1079
|
|
1080
|
|
1081 CHANGE LIST JUMPS *changelist* *change-list-jumps* *E664*
|
|
1082
|
|
1083 When making a change the cursor position is remembered. One position is
|
|
1084 remembered for every change that can be undone, unless it is close to a
|
|
1085 previous change. Two commands can be used to jump to positions of changes,
|
|
1086 also those that have been undone:
|
|
1087
|
|
1088 *g;* *E662*
|
|
1089 g; Go to [count] older position in change list.
|
|
1090 If [count] is larger than the number of older change
|
|
1091 positions go to the oldest change.
|
|
1092 If there is no older change an error message is given.
|
|
1093 (not a motion command)
|
|
1094 {not in Vi}
|
|
1095 {not available without the +jumplist feature}
|
|
1096
|
|
1097 *g,* *E663*
|
|
1098 g, Go to [count] newer cursor position in change list.
|
236
|
1099 Just like |g;| but in the opposite direction.
|
7
|
1100 (not a motion command)
|
|
1101 {not in Vi}
|
|
1102 {not available without the +jumplist feature}
|
|
1103
|
|
1104 When using a count you jump as far back or forward as possible. Thus you can
|
|
1105 use "999g;" to go to the first change for which the position is still
|
|
1106 remembered. The number of entries in the change list is fixed and is the same
|
|
1107 as for the |jumplist|.
|
|
1108
|
|
1109 When two undo-able changes are in the same line and at a column position less
|
|
1110 than 'textwidth' apart only the last one is remembered. This avoids that a
|
|
1111 sequence of small changes in a line, for example "xxxxx", adds many positions
|
|
1112 to the change list. When 'textwidth' is zero 'wrapmargin' is used. When that
|
|
1113 also isn't set a fixed number of 79 is used. Detail: For the computations
|
|
1114 bytes are used, not characters, to avoid a speed penalty (this only matters
|
|
1115 for multi-byte encodings).
|
|
1116
|
|
1117 Note that when text has been inserted or deleted the cursor position might be
|
|
1118 a bit different from the position of the change. Especially when lines have
|
|
1119 been deleted.
|
|
1120
|
|
1121 When the |:keepjumps| command modifier is used the position of a change is not
|
|
1122 remembered.
|
|
1123
|
|
1124 *:changes*
|
|
1125 :changes Print the change list. A ">" character indicates the
|
|
1126 current position. Just after a change it is below the
|
|
1127 newest entry, indicating that "g;" takes you to the
|
|
1128 newest entry position. The first column indicates the
|
|
1129 count needed to take you to this position. Example:
|
|
1130
|
|
1131 change line col text ~
|
|
1132 3 9 8 bla bla bla
|
|
1133 2 11 57 foo is a bar
|
|
1134 1 14 54 the latest changed line
|
|
1135 >
|
|
1136
|
|
1137 The "3g;" command takes you to line 9. Then the
|
|
1138 output of ":changes is:
|
|
1139
|
|
1140 change line col text ~
|
|
1141 > 0 9 8 bla bla bla
|
|
1142 1 11 57 foo is a bar
|
|
1143 2 14 54 the latest changed line
|
|
1144
|
|
1145 Now you can use "g," to go to line 11 and "2g," to go
|
|
1146 to line 14.
|
|
1147
|
|
1148 ==============================================================================
|
|
1149 9. Various motions *various-motions*
|
|
1150
|
|
1151 *%*
|
|
1152 % Find the next item in this line after or under the
|
|
1153 cursor and jump to its match. |inclusive| motion.
|
|
1154 Items can be:
|
|
1155 ([{}]) parenthesis or (curly/square) brackets
|
|
1156 (this can be changed with the
|
|
1157 'matchpairs' option)
|
|
1158 /* */ start or end of C-style comment
|
|
1159 #if, #ifdef, #else, #elif, #endif
|
|
1160 C preprocessor conditionals (when the
|
|
1161 cursor is on the # or no ([{
|
|
1162 following)
|
|
1163 For other items the matchit plugin can be used, see
|
|
1164 |matchit-install|.
|
|
1165
|
|
1166 When 'cpoptions' contains "M" |cpo-M| backslashes
|
|
1167 before parens and braces are ignored. Without "M" the
|
|
1168 number of backslashes matters: an even number doesn't
|
|
1169 match with an odd number. Thus in "( \) )" and "\( (
|
|
1170 \)" the first and last parenthesis match.
|
|
1171 When the '%' character is not present in 'cpoptions'
|
|
1172 |cpo-%|, parens and braces inside double quotes are
|
|
1173 ignored, unless the number of parens/braces in a line
|
|
1174 is uneven and this line and the previous one does not
|
|
1175 end in a backslash. '(', '{', '[', ']', '}' and ')'
|
|
1176 are also ignored (parens and braces inside single
|
|
1177 quotes). Note that this works fine for C, but not for
|
|
1178 Perl, where single quotes are used for strings.
|
|
1179 No count is allowed ({count}% jumps to a line {count}
|
|
1180 percentage down the file |N%|). Using '%' on
|
|
1181 #if/#else/#endif makes the movement linewise.
|
|
1182
|
|
1183 *[(*
|
|
1184 [( go to [count] previous unmatched '('.
|
|
1185 |exclusive| motion. {not in Vi}
|
|
1186
|
|
1187 *[{*
|
|
1188 [{ go to [count] previous unmatched '{'.
|
|
1189 |exclusive| motion. {not in Vi}
|
|
1190
|
|
1191 *])*
|
|
1192 ]) go to [count] next unmatched ')'.
|
|
1193 |exclusive| motion. {not in Vi}
|
|
1194
|
|
1195 *]}*
|
|
1196 ]} go to [count] next unmatched '}'.
|
|
1197 |exclusive| motion. {not in Vi}
|
|
1198
|
|
1199 The above four commands can be used to go to the start or end of the current
|
|
1200 code block. It is like doing "%" on the '(', ')', '{' or '}' at the other
|
|
1201 end of the code block, but you can do this from anywhere in the code block.
|
|
1202 Very useful for C programs. Example: When standing on "case x:", "[{" will
|
|
1203 bring you back to the switch statement.
|
|
1204
|
|
1205 *]m*
|
|
1206 ]m Go to [count] next start of a method (for Java or
|
|
1207 similar structured language). When not before the
|
|
1208 start of a method, jump to the start or end of the
|
|
1209 class. When no '{' is found after the cursor, this is
|
|
1210 an error. |exclusive| motion. {not in Vi}
|
|
1211 *]M*
|
|
1212 ]M Go to [count] next end of a method (for Java or
|
|
1213 similar structured language). When not before the end
|
|
1214 of a method, jump to the start or end of the class.
|
|
1215 When no '}' is found after the cursor, this is an
|
|
1216 error. |exclusive| motion. {not in Vi}
|
|
1217 *[m*
|
|
1218 [m Go to [count] previous start of a method (for Java or
|
|
1219 similar structured language). When not after the
|
|
1220 start of a method, jump to the start or end of the
|
|
1221 class. When no '{' is found before the cursor this is
|
|
1222 an error. |exclusive| motion. {not in Vi}
|
|
1223 *[M*
|
|
1224 [M Go to [count] previous end of a method (for Java or
|
|
1225 similar structured language). When not after the
|
|
1226 end of a method, jump to the start or end of the
|
|
1227 class. When no '}' is found before the cursor this is
|
|
1228 an error. |exclusive| motion. {not in Vi}
|
|
1229
|
|
1230 The above two commands assume that the file contains a class with methods.
|
|
1231 The class definition is surrounded in '{' and '}'. Each method in the class
|
|
1232 is also surrounded with '{' and '}'. This applies to the Java language. The
|
|
1233 file looks like this: >
|
|
1234
|
|
1235 // comment
|
|
1236 class foo {
|
|
1237 int method_one() {
|
|
1238 body_one();
|
|
1239 }
|
|
1240 int method_two() {
|
|
1241 body_two();
|
|
1242 }
|
|
1243 }
|
|
1244 Starting with the cursor on "body_two()", using "[m" will jump to the '{' at
|
|
1245 the start of "method_two()" (obviously this is much more useful when the
|
|
1246 method is long!). Using "2[m" will jump to the start of "method_one()".
|
|
1247 Using "3[m" will jump to the start of the class.
|
|
1248
|
|
1249 *[#*
|
|
1250 [# go to [count] previous unmatched "#if" or "#else".
|
|
1251 |exclusive| motion. {not in Vi}
|
|
1252
|
|
1253 *]#*
|
|
1254 ]# go to [count] next unmatched "#else" or "#endif".
|
|
1255 |exclusive| motion. {not in Vi}
|
|
1256
|
|
1257 These two commands work in C programs that contain #if/#else/#endif
|
|
1258 constructs. It brings you to the start or end of the #if/#else/#endif where
|
|
1259 the current line is included. You can then use "%" to go to the matching line.
|
|
1260
|
|
1261 *[star* *[/*
|
|
1262 [* or [/ go to [count] previous start of a C comment "/*".
|
|
1263 |exclusive| motion. {not in Vi}
|
|
1264
|
|
1265 *]star* *]/*
|
|
1266 ]* or ]/ go to [count] next end of a C comment "*/".
|
|
1267 |exclusive| motion. {not in Vi}
|
|
1268
|
|
1269
|
|
1270 *H*
|
|
1271 H To line [count] from top (Home) of window (default:
|
|
1272 first line on the window) on the first non-blank
|
|
1273 character |linewise|. See also 'startofline' option.
|
|
1274 Cursor is adjusted for 'scrolloff' option.
|
|
1275
|
|
1276 *M*
|
|
1277 M To Middle line of window, on the first non-blank
|
|
1278 character |linewise|. See also 'startofline' option.
|
|
1279
|
|
1280 *L*
|
|
1281 L To line [count] from bottom of window (default: Last
|
|
1282 line on the window) on the first non-blank character
|
|
1283 |linewise|. See also 'startofline' option.
|
|
1284 Cursor is adjusted for 'scrolloff' option.
|
|
1285
|
|
1286 <LeftMouse> Moves to the position on the screen where the mouse
|
36
|
1287 click is |exclusive|. See also |<LeftMouse>|. If the
|
7
|
1288 position is in a status line, that window is made the
|
|
1289 active window and the cursor is not moved. {not in Vi}
|
|
1290
|
|
1291 vim:tw=78:ts=8:ft=help:norl:
|