1 *motion.txt* For Vim version 5.8. Last change: 2001 May 18
4 VIM REFERENCE MANUAL by Bram Moolenaar
7 Cursor motions *cursor-motions* *navigation*
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
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. Various motions |various-motions|
21 ==============================================================================
22 1. motions and operators *operator*
24 The motion commands can be used after an operator command, to have the command
25 operate on the text that was moved over. That is the text between the cursor
26 position before and after the motion. Operators are generally used to delete
27 or change text. The following operators are available:
31 |y| y yank into register (does not change the text)
32 |~| ~ swap case (only if 'tildeop' is set)
34 |gu| gu make lower case
35 |gU| gU make upper case
36 |!| ! filter through an external program
37 |=| = filter through 'equalprg' or C-indenting if empty
38 |gq| gq text formatting
42 If the motion includes a count and the operator also had a count before it,
43 the two counts are multiplied. For example: "2d3w" deletes six words.
45 After applying the operator the cursor is mostly left at the start of the text
46 that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe"
47 moves the cursor leftwards to the "e" where the yank started.
49 *linewise* *characterwise*
50 The operator either affects whole lines, or the characters between the start
51 and end position. Generally, motions that move between lines affect lines
52 (are linewise), and motions that move within a line affect characters (are
53 characterwise). However, there are some exceptions.
55 A character motion is either inclusive or exclusive. When inclusive, the start
56 and end position of the motion are included in the operation. When exclusive,
57 the last character towards the end of the buffer is not included. Linewise
58 motions always include the start and end position.
60 Which motions are linewise, inclusive or exclusive is mentioned below. There
61 are however, two general exceptions:
62 1. If the motion is exclusive and the end of the motion is in column 1, the
63 end of the motion is moved to the end of the previous line and the motion
64 becomes inclusive. Example: "}" moves to the first line after a paragraph,
65 but "d}" will not include that line.
66 2. If the motion is exclusive, the end of the motion is in column 1 and the
67 start of the motion was at or before the first non-blank in the line, the
68 motion becomes linewise. Example: If a paragraph begins with some blanks
69 and you do "d}" while standing on the first non-blank, all the lines of
70 the paragraph are deleted, including the blanks. If you do a put now, the
71 deleted lines will be inserted below the cursor position.
73 Note that when the operator is pending (the operator command is typed, but the
74 motion isn't yet), a special set of mappings can be used. See |:omap|.
76 Instead of first giving the operator and then a motion you can use Visual
77 mode: mark the start of the text with "v", move the cursor to the end of the
78 text that is to be affected and then hit the operator. The text between the
79 start and the cursor position is highlighted, so you can see what text will
80 be operated upon. This allows much more freedom, but requires more key
81 strokes and has limited redo functionality. See the chapter on Visual mode
84 If you want to know where you are in the file use the "CTRL-G" command
85 |CTRL-G| or the "g CTRL-G" command |g_CTRL-G|. If you set the 'ruler' option,
86 the cursor position is continuously shown in the status line (which slows down
89 NOTE: Experienced users prefer the hjkl keys because they are always right
90 under their fingers. Beginners often prefer the arrow keys, because they
91 do not know what the hjkl keys do. The mnemonic value of hjkl is clear from
92 looking at the keyboard. Think of j as an arrow pointing downwards.
94 ==============================================================================
95 2. Left-right motions *left-right-motions*
99 CTRL-H or *CTRL-H* *<BS>*
100 <BS> [count] characters to the left (exclusive).
101 Note: If you prefer <BS> to delete a character, use
104 (to enter "CTRL-V<BS>" type the CTRL-V key, followed
106 See |:fixdel| if the <BS> key does not do what you
110 <Right> or *<Right>* *<Space>*
111 <Space> [count] characters to the right (exclusive).
114 0 To the first character of the line (exclusive). When
115 moving up or down, stay in same screen column (if
119 <Home> To the first character of the line (exclusive). When
120 moving up or down, stay in same text column (if
121 possible). Works like "1|", which differs from "0"
122 when the line starts with a <Tab>. {not in Vi}
125 ^ To the first non-blank character of the line
129 $ or <End> To the end of the line and [count - 1] lines downward
133 g0 or g<Home> When lines wrap ('wrap on): To the first character of
134 the screen line (exclusive). Differs from "0" when a
135 line is wider than the screen.
136 When lines don't wrap ('wrap' off): To the leftmost
137 character of the current line that is on the screen.
138 Differs from "0" when the first character of the line
139 is not on the screen. {not in Vi}
142 g^ When lines wrap ('wrap' on): To the first non-blank
143 character of the screen line (exclusive). Differs
144 from "^" when a line is wider than the screen.
145 When lines don't wrap ('wrap' off): To the leftmost
146 non-blank character of the current line that is on the
147 screen. Differs from "^" when the first non-blank
148 character of the line is not on the screen. {not in
152 gm Like "g0", but half a screenwidth to the right (or as
153 much as possible). {not in Vi}
156 g$ or g<End> When lines wrap ('wrap' on): To the last character of
157 the screen line and [count - 1] screen lines downward
158 (inclusive). Differs from "$" when a line is wider
160 When lines don't wrap ('wrap' off): To the rightmost
161 character of the current line that is visible on the
162 screen. Differs from "$" when the last character of
163 the line is not on the screen or when a count is used.
167 | To screen column [count] in the current line
171 f{char} To [count]'th occurrence of {char} to the right. The
172 cursor is placed on {char} (inclusive).
175 F{char} To the [count]'th occurrence of {char} to the left.
176 The cursor is placed on {char} (inclusive).
179 t{char} Till before [count]'th occurrence of {char} to the
180 right. The cursor is placed on the character left of
184 T{char} Till after [count]'th occurrence of {char} to the
185 left. The cursor is placed on the character right of
189 ; Repeat latest f, t, F or T [count] times.
192 , Repeat latest f, t, F or T in opposite direction
195 These commands move the cursor to the specified column in the current line.
196 They stop at the first column and at the end of the line, except "$", which
197 may move to one of the next lines. See 'whichwrap' option to make some of the
198 commands move across line boundaries.
200 ==============================================================================
201 3. Up-down motions *up-down-motions*
204 <Up> or *<Up>* *CTRL-P*
205 CTRL-P [count] lines upward (linewise).
210 <NL> or *<NL>* *CTRL-N*
211 CTRL-N [count] lines downward (linewise).
214 g<Up> [count] display lines upward (exclusive). Differs
215 from 'k' when lines wrap, and when used with an
216 operator, because it's not linewise. {not in Vi}
219 g<Down> [count] display lines downward (exclusive). Differs
220 from 'j' when lines wrap, and when used with an
221 operator, because it's not linewise. {not in Vi}
224 - <minus> [count] lines upward, on the first non-blank
225 character (linewise).
228 CTRL-M or *CTRL-M* *<CR>*
229 <CR> [count] lines downward, on the first non-blank
230 character (linewise).
233 _ <underscore> [count] - 1 lines downward, on the first non-blank
234 character (linewise).
236 <C-End> or *G* *<C-End>*
237 G Goto line [count], default last line, on the first
238 non-blank character (linewise). If 'startofline' not
239 set, keep the same column.
241 <C-Home> or *gg* *<C-Home>*
242 gg Goto line [count], default first line, on the first
243 non-blank character (linewise). If 'startofline' not
244 set, keep the same column.
246 :[range] Set the cursor on the (last) specified line number
247 (cannot be used with an operator).
250 {count}% Go to {count} percentage in the file, on the first
251 non-blank in the line (linewise). To compute the new
252 line number this formula is used:
253 ({count} * number-of-lines + 99) / 100
254 See also 'startofline' option. {not in Vi}
256 :[range]go[to] [count] *:go* *:goto* *go*
257 [count]go Go to {count} byte in the buffer. Default [count] is
258 zero, start of the file. When giving [range], the
259 last number in it used. End-of-line characters are
260 counted depending on the current 'fileformat' setting.
262 {not available when compiled without the
263 |+byte_offset| feature}
265 These commands move to the specified line. They stop when reaching the first
266 or the last line. The first two commands put the cursor in the same column
267 (if possible) as it was after the last command that changed the column,
268 except after the "$" command, then the cursor will be put on the last
269 character of the line.
271 ==============================================================================
272 4. Word motions *word-motions*
274 <S-Right> or *<S-Right>* *w*
275 w [count] words forward (exclusive).
277 <C-Right> or *<C-Right>* *W*
278 W [count] WORDS forward (exclusive).
281 e Forward to the end of word [count] (inclusive).
284 E Forward to the end of WORD [count] (inclusive).
286 <S-Left> or *<S-Left>* *b*
287 b [count] words backward (exclusive).
289 <C-Left> or *<C-Left>* *B*
290 B [count] WORDS backward (exclusive).
293 ge Backward to the end of word [count] (inclusive).
296 gE Backward to the end of WORD [count] (inclusive).
298 These commands move over words or WORDS.
300 A word consists of a sequence of letters, digits and underscores, or a
301 sequence of other non-blank characters, separated with white space (spaces,
302 tabs, <EOL>). This can be changed with the 'iskeyword' option.
304 A WORD consists of a sequence of non-blank characters, separated with white
305 space. An empty line is also considered to be a word and a WORD.
307 Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
308 on a non-blank. This is because "cw" is interpreted as change-word, and a
309 word does not include the following white space. {Vi: "cw" when on a blank
310 followed by other blanks changes only the first blank; this is probably a
311 bug, because "dw" deletes all the blanks}
313 Another special case: When using the "w" motion in combination with an
314 operator and the last word moved over is at the end of a line, the end of
315 that word becomes the end of the operated text, not the first word in the
318 The original Vi implementation of "e" is buggy. For example, the "e" command
319 will stop on the first character of a line if the previous line was empty.
320 But when you use "2e" this does not happen. In Vim "ee" and "2e" are the
321 same, which is more logical. However, this causes a small incompatibility
324 ==============================================================================
325 5. Text object motions *object-motions*
328 ( [count] sentences backward (exclusive).
331 ) [count] sentences forward (exclusive).
334 { [count] paragraphs backward (exclusive).
337 } [count] paragraphs forward (exclusive).
340 ]] [count] sections forward or to the next '{' in the
341 first column. When used after an operator, then the
342 '}' in the first column. (linewise).
345 ][ [count] sections forward or to the next '}' in the
346 first column (linewise).
349 [[ [count] sections backward or to the previous '{' in
350 the first column (linewise).
353 [] [count] sections backward or to the previous '}' in
354 the first column (linewise).
356 These commands move over three kinds of text objects.
359 A sentence is defined as ending at a '.', '!' or '?' followed by either the
360 end of a line, or by a space or tab. Any number of closing ')', ']', '"'
361 and ''' characters my appear after the '.', '!' or '?' before the spaces,
362 tabs or end of line. A paragraph and section boundary is also a sentence
364 If the 'J' flag is present is 'cpoptions', at least two spaces have to
365 follow the punctuation mark; <Tab>s are not recognized as white space.
366 The definition of a sentence cannot be changed.
369 A paragraph begins after each empty line, and also at each of a set of
370 paragraph macros, specified by the pairs of characters in the 'paragraphs'
371 option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the
372 macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in the
373 first column). A section boundary is also a paragraph boundary. Note that
374 this does not include a '{' or '}' in the first column. Also note that a
375 blank line (only containing white space) is NOT a paragraph boundary.
378 A section begins after a form-feed (<C-L>) in the first column and at each of
379 a set of section macros, specified by the pairs of characters in the
380 'sections' option. The default is "SHNHH HUnhsh", which defines a section to
381 start at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh".
383 The "]" and "[" commands stop at the '{' or '}' in the first column. This is
384 useful to find the start or end of a function in a C program. Note that the
385 first character of the command determines the search direction and the
386 second character the type of brace found.
388 If your '{' or '}' are not in the first column, and you would like to use "[["
389 and "]]" anyway, try these mappings:
390 > :map [[ ?{<CR>w99[{
391 > :map ][ /}<CR>b99]}
392 > :map ]] j0[[%/{<CR>
393 > :map [] k$][%?}<CR>
394 [type these literally, see |<>|]
396 ==============================================================================
397 6. Text object selection *object-select* *text-objects*
400 This is a series of commands that can only be used while in Visual mode or
401 after an operator. The commands that start with "a" select "a"n object
402 including white space, the commands starting with "i" select an "inner" object
403 without white space, or just the white space. Thus the "inner" commands
404 always select less text than the "a" commands.
406 These commands are {not in Vi}.
407 These commands are not available when the |+textobjects| feature has been
408 disabled at compile time.
410 aw "a word", select [count] words (see |word|).
411 Leading or trailing white space is included, but not
415 iw "inner word", select [count] words (see |word|).
416 White space between words is counted too.
419 aW "a WORD", select [count] WORDs (see |WORD|).
420 Leading or trailing white space is included, but not
424 iW "inner WORD", select [count] WORDs (see |WORD|).
425 White space between words is counted too.
428 as "a sentence", select [count] sentences (see
432 is "inner sentence", select [count] sentences (see
436 ap "a paragraph", select [count] paragraphs (see
440 ip "inner paragraph", select [count] paragraphs (see
444 a[ "a [] block", select [count] '[' ']' blocks. This
445 goes backwards to the [count] unclosed '[', and finds
446 the matching ']'. The enclosed text is selected,
447 including the '[' and ']'.
450 i[ "inner [] block", select [count] '[' ']' blocks. This
451 goes backwards to the [count] unclosed '[', and finds
452 the matching ']'. The enclosed text is selected,
453 excluding the '[' and ']'.
457 ab "a block", select [count] blocks, from "[count] [(" to
458 the matching ')', including the '(' and ')' (see
463 ib "inner block", select [count] blocks, from "[count] [("
464 to the matching ')', excluding the '(' and ')' (see
468 a< "a <> block", select [count] <> blocks, from the
469 [count]'th unmatched '<' backwards to the matching
470 '>', including the '<' and '>'.
473 i< "inner <> block", select [count] <> blocks, from
474 the [count]'th unmatched '<' backwards to the matching
475 '>', excluding the '<' and '>'.
479 aB "a Block", select [count] Blocks, from "[count] [{" to
480 the matching '}', including the '{' and '}' (see
485 iB "inner Block", select [count] Blocks, from "[count] [{"
486 to the matching '}', excluding the '{' and '}' (see
489 When used after an operator:
490 For non-block objects:
491 For the "a" commands: The operator applies to the object and the white
492 space after the object. If there is no white space after the object
493 or when the cursor was in the white space before the object, the white
494 space before the object is included.
495 For the "inner" commands: If the cursor was on the object, the
496 operator applies to the object. If the cursor was on white space, the
497 operator applies to the white space.
499 The operator applies to the block where the cursor is in, or the block
500 on which the cursor is on one of the braces. For the "inner" commands
501 the surrounding braces are excluded. For the "a" commands, the braces
504 When used in Visual mode:
505 When start and end of the Visual area are the same (just after typing "v"):
506 One object is selected, the same as for using an operator.
507 When start and end of the Visual area are not the same:
508 For non-block objects the area is extended by one object or the white
509 space up to the next object, or both for the "a" objects. The
510 direction in which this happens depends on which side of the Visual
511 area the cursor is. For the block objects the block is extended one
514 For illustration, here is a list of delete commands, grouped from small to big
515 objects. Note that for a single character and a whole line the existing vi
516 movement commands are used.
517 "dl" delete character (alias: "x") |dl|
518 "diw" delete inner word *diw*
519 "daw" delete a word *daw*
520 "diW" delete inner WORD (see |WORD|) *diW*
521 "daW" delete a WORD (see |WORD|) *daW*
522 "dd" delete one line |dd|
523 "dis" delete inner sentence *dis*
524 "das" delete a sentence *das*
525 "dib" delete inner '(' ')' block *dib*
526 "dab" delete a '(' ')' block *dab*
527 "dip" delete inner paragraph *dip*
528 "dap" delete a paragraph *dap*
529 "diB" delete inner '{' '}' block *diB*
530 "daB" delete a '{' '}' block *daB*
532 Note the difference between using a movement command and an object. The
533 movement command operates from here (cursor position) to where the movement
534 takes us. When using an object the whole object is operated upon, no matter
535 where on the object the cursor is. For example, compare "dw" and "da": "dw"
536 deletes from the cursor position to the start of the next word, "da" deletes
537 the word under the cursor and the space after or before it.
539 ==============================================================================
540 7. Various motions *various-motions*
543 m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move
544 the cursor, this is not a motion command).
546 m' or m` Set the previous context mark. This can be jumped to
547 with the "''" or "``" command (does not move the
548 cursor, this is not a motion command).
551 :[range]ma[rk] {a-zA-Z} Set mark {a-zA-Z} at last line number in [range],
552 column 0. Default is cursor line.
555 :[range]k{a-zA-Z} Same as :mark, but the space before the mark name can
559 '{a-z} To the first non-blank character on the line with
560 mark {a-z} (linewise).
562 '{A-Z0-9} To the first non-blank character on the line with
563 mark {A-Z0-9} in the correct file (linewise when in
564 same file, not a motion command when in other file).
568 `{a-z} To the mark {a-z} (exclusive).
570 `{A-Z0-9} To the mark {A-Z0-9} in the correct file (exclusive
571 when in same file, not a motion command when in
572 other file). {not in Vi}
575 :marks List all the current marks (not a motion command).
578 :marks {arg} List the marks that are mentioned in {arg} (not a
579 motion command). For example:
581 to list marks 'a' and 'B'. {not in Vi}
583 A mark is not visible in any way. It is just a position in the file that is
584 remembered. Do not confuse marks with named registers, they are totally
587 'a - 'z lowercase marks, valid within one file
588 'A - 'Z uppercase marks, also called file marks, valid between files
589 '0 - '9 numbered marks, set from .viminfo file
591 Lowercase marks 'a to 'z are remembered as long as the file remains in the
592 buffer list. If you remove the file from the buffer list, all its marks are
593 lost. If you delete a line that contains a mark, that mark is erased.
594 Lowercase marks can be used in combination with operators. For example: "d't"
595 deletes the lines from the cursor position to mark 't'. Hint: Use mark 't' for
596 Top, 'b' for Bottom, etc.. Lowercase marks are restored when using undo and
599 Uppercase marks 'A to 'Z include the file name. {Vi: no uppercase marks} You
600 can use them to jump from file to file. You can only use an uppercase mark
601 with an operator if the mark is in the current file. The line number of the
602 mark remains correct, even if you insert/delete lines or edit another file for
603 a moment. When the 'viminfo' option is not empty, uppercase marks are kept in
604 the .viminfo file. See |viminfo-file-marks|.
606 Numbered marks '0 to '9 are quite different. They can not be set directly.
607 They are only present when using a viminfo file |viminfo-file|. Basically '0
608 is the location of the cursor when you last exited Vim, '1 the last but one
609 time, etc. See |viminfo-file-marks|.
612 '[ To the first non-blank character on the first line
613 of the previously operated, inserted or put text.
617 `[ To the first character of the previously operated,
618 inserted or put text. {not in Vi}
621 '] To the first non-blank character on the last line of
622 the previously operated, inserted or put text.
626 `] To the last character of the previously operated,
627 inserted or put text. {not in Vi}
629 After executing an operator the Cursor is put at the beginning of the text
630 that was operated upon. After a put command ("p" or "P") the cursor is
631 sometimes placed at the first inserted line and sometimes on the last inserted
632 character. The four commands above put the cursor at either end. Example:
633 After yanking 10 lines you want to go to the last one of them: "10Y']". After
634 inserting several lines with the "p" command you want to jump to the lowest
635 inserted line: "p']". This also works for text that has been inserted.
637 Note: After deleting text, the start and end positions are the same, except
638 when using blockwise Visual mode. These commands do not work when no
639 operator, file-read or put command has been used yet in the current file.
642 '< To the first non-blank character on the first line
643 of the last selected Visual area in the current
647 `< To the first character of the last selected Visual
648 area in the current buffer. {not in Vi}.
651 '> To the first non-blank character on the last line
652 of the last selected Visual area in the current
656 `> To the last character of the last selected Visual
657 area in the current buffer. {not in Vi}.
660 '' To the first non-blank character of the line where
661 the cursor was before the latest jump, or where the
662 last "m'" or "m`" command was given (linewise).
665 `` To the position before latest jump, or where the last
666 "m'" or "m`" command was given (exclusive).
667 Also see |restore-position|.
670 '" To the first non-blank character of the line where
671 the cursor was the last time the current buffer was
672 exited (linewise). Defaults to the first line.
673 See |last-position-jump| for how to use this for each
674 opened file. {not in Vi}.
677 `" To the cursor position when last exiting the current
678 buffer (exclusive). Defaults to the first character
679 of the first line. {not in Vi}.
681 A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
682 "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
683 the commands that start editing a new file. If you make the cursor "jump"
684 with one of these commands, the position of the cursor before the jump is
685 remembered. You can return to that position with the "''" and "``" command,
686 unless the line containing that position was changed or deleted.
689 CTRL-O Go to [count] Older cursor position in jump list
690 (not a motion command). {not in Vi}
692 <Tab> or *CTRL-I* *<Tab>*
693 CTRL-I Go to [count] newer cursor position in jump list
694 (not a motion command). {not in Vi}
697 :ju[mps] Print the jump list (not a motion command). {not in
701 Jumps are remembered in a jump list. With the CTRL-O and CTRL-I command you
702 can go to cursor positions before older jumps, and back again. Thus you can
703 move up and down the list. There is a separate jump list for each window.
704 The maximum number of entries is fixed at 50.
706 For example, after three jump commands you have this jump list:
714 The "file/line" column shows the file name, or the text at the jump if it is
715 in the current file (an indent is removed and a long line is truncated to fit
718 You are currently in line 1167. If you then use the CTRL-O command, the
719 cursor is put in line 1154. This results in:
727 The pointer will be set at the last used jump position. The next CTRL-O
728 command will use the entry above it, the next CTRL-I command will use the
729 entry below it. If the pointer is below the last entry, this indicates that
730 you did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command
731 will cause the cursor position to be added to the jump list, so you can get
732 back to the position before the CTRL-O. In this case this is line 1167.
734 With more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I
735 you can go back to 1154 and 1167 again. Note that the number in the "jump"
736 column indicates the count for the CTRL-O or CTRL-I command that takes you to
739 If you use a jump command, the current line number is inserted at the end of
740 the jump list. If the same line was already in the jump list, it is removed.
741 The result is that when repeating CTRL-O you will get back to old positions
744 After the CTRL-O command that got you into line 1154 you could give another
745 jump command (e.g., "G"). The jump list would then become:
754 The line numbers will be adjusted for deleted and inserted lines. This fails
755 if you stop editing a file without writing, like with ":n!".
758 % Find the next item in this line after or under the
759 cursor and jump to its match (inclusive). Items can
761 ([{}]) parenthesis or (curly/square) brackets
762 (this can be changed with the
764 /* */ start or end of C-style comment
765 #if, #ifdef, #else, #elif, #endif
766 C preprocessor conditionals
767 Parens and braces preceded with a backslash are
768 ignored. When the '%' character is not present in
769 'cpoptions', parens and braces inside double quotes
770 are ignored, unless the number of parens/braces in a
771 line is uneven and this line and the previous one does
772 not end in a backslash. '(', '{', '[', ']', '}' and
773 ')' are also ignored (parens and braces inside single
774 quotes). Note that this works fine for C, but not for
775 Perl, where single quotes are used for strings.
776 No count is allowed ({count}% jumps to a line {count}
777 percentage down the file |N%|). Using '%' on
778 #if/#else/#endif makes the movement linewise.
781 [( go to [count] previous unmatched '('. {not in Vi}
784 [{ go to [count] previous unmatched '{'. {not in Vi}
787 ]) go to [count] next unmatched ')'. {not in Vi}
790 ]} go to [count] next unmatched '}'. {not in Vi}
792 The above four commands can be used to go to the start or end of the current
793 code block. It is like doing "%" on the '(', ')', '{' or '}' at the other
794 end of the code block, but you can do this from anywhere in the code block.
795 Very useful for C programs. Example: When standing on "case x:", "[{" will
796 bring you back to the switch statement.
799 ]m Go to [count] next start of a method (for Java or
800 similar structured language). When not before the
801 start of a method, jump to the start or end of the
802 class. When no '{' is found after the cursor, this is
803 an error. {not in Vi}
805 ]M Go to [count] next end of a method (for Java or
806 similar structured language). When not before the end
807 of a method, jump to the start or end of the class.
808 When no '}' is found after the cursor, this is an
811 [m Go to [count] previous start of a method (for Java or
812 similar structured language). When not after the
813 start of a method, jump to the start or end of the
814 class. When no '{' is found before the cursor this is
815 an error. {not in Vi}
817 [M Go to [count] previous end of a method (for Java or
818 similar structured language). When not after the
819 end of a method, jump to the start or end of the
820 class. When no '}' is found before the cursor this is
821 an error. {not in Vi}
823 The above two commands assume that the file contains a class with methods.
824 The class definition is surrounded in '{' and '}'. Each method in the class
825 is also surrounde with '{' and '}'. This applies to the Java language. The
826 file looks like this:
837 Starting with the cursor on "body_two()", using "[m" will jump to the '{' at
838 the start of "method_two()" (obviously this is much more useful when the
839 method is long!). Using "2[m" will jump to the start of "method_one()".
840 Using "3[m" will jump to the start of the class.
843 [# go to [count] previous unmatched "#if" or "#else".
847 ]# go to [count] next unmatched "#else" or "#endif". {not
850 These two commands work in C programs that contain #if/#else/#endif
851 constructs. It brings you to the start or end of the #if/#else/#endif where
852 the current line is included. You can then use "%" to go to the matching line.
855 [* or [/ go to [count] previous start of a C comment "/*". {not
859 ]* or ]/ go to [count] next end of a C comment "*/". {not
864 H To line [count] from top (Home) of screen (default:
865 first line on the screen) on the first non-blank
866 character (linewise). See also 'startofline' option.
867 Cursor is adjusted for 'scrolloff' option.
870 M To Middle line of screen, on the first non-blank
871 character (linewise). See also 'startofline' option.
874 L To line [count] from bottom of screen (default: Last
875 line on the screen) on the first non-blank character
876 (linewise). See also 'startofline' option.
877 Cursor is adjusted for 'scrolloff' option.
879 <LeftMouse> Moves to the position on the screen where the mouse
880 click is (inclusive). See also |<LeftMouse>|. If the
881 position is in a status line, that window is made the
882 active window and the cursor is not moved. {not in Vi}