motion.txt 52 KB

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