motion.txt 51 KB

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