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