motion.txt 53 KB

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