motion.txt 53 KB

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