cmdline.txt 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  1. *cmdline.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. *Cmdline-mode* *Command-line-mode* *Cmdline*
  4. Command-line mode *cmdline* *Command-line* *mode-cmdline* *:*
  5. Command-line mode is used to enter Ex commands (":"), search patterns
  6. ("/" and "?"), and filter commands ("!").
  7. Basic command line editing is explained in chapter 20 of the user manual
  8. |usr_20.txt|.
  9. Type |gO| to see the table of contents.
  10. ==============================================================================
  11. 1. Command-line editing *cmdline-editing*
  12. Normally characters are inserted in front of the cursor position. You can
  13. move around in the command-line with the left and right cursor keys. With the
  14. <Insert> key, you can toggle between inserting and overstriking characters.
  15. Note that if your keyboard does not have working cursor keys or any of the
  16. other special keys, you can use ":cnoremap" to define another key for them.
  17. For example, to define tcsh style editing keys: *tcsh-style* >
  18. :cnoremap <C-A> <Home>
  19. :cnoremap <C-F> <Right>
  20. :cnoremap <C-B> <Left>
  21. :cnoremap <Esc>b <S-Left>
  22. :cnoremap <Esc>f <S-Right>
  23. (<> notation |<>|; type all this literally)
  24. *cmdline-too-long*
  25. When the command line is getting longer than what fits on the screen, only the
  26. part that fits will be shown. The cursor can only move in this visible part,
  27. thus you cannot edit beyond that.
  28. *cmdline-history* *history*
  29. The command-lines that you enter are remembered in a history table. You can
  30. recall them with the up and down cursor keys. There are actually five
  31. history tables:
  32. - one for ':' commands
  33. - one for search strings
  34. - one for expressions
  35. - one for input lines, typed for the |input()| function.
  36. - one for debug mode commands
  37. These are completely separate. Each history can only be accessed when
  38. entering the same type of line.
  39. Use the 'history' option to set the number of lines that are remembered.
  40. Notes:
  41. - When you enter a command-line that is exactly the same as an older one, the
  42. old one is removed (to avoid repeated commands moving older commands out of
  43. the history).
  44. - Only commands that are typed are remembered. Ones that completely come from
  45. mappings are not put in the history.
  46. - All searches are put in the search history, including the ones that come
  47. from commands like "*" and "#". But for a mapping, only the last search is
  48. remembered (to avoid that long mappings trash the history).
  49. There is an automatic completion of names on the command-line; see
  50. |cmdline-completion|.
  51. *c_CTRL-V*
  52. CTRL-V Insert next non-digit literally. Up to three digits form the
  53. decimal value of a single byte. The non-digit and the three
  54. digits are not considered for mapping. This works the same
  55. way as in Insert mode (see above, |i_CTRL-V|).
  56. For special keys, the CTRL modifier may be included into the
  57. key to produce a control character. If there is no control
  58. character for the key then its |key-notation| is inserted.
  59. Note: Under Windows CTRL-V is often mapped to paste text.
  60. Use CTRL-Q instead then.
  61. *c_CTRL-Q*
  62. CTRL-Q Same as CTRL-V. But with some terminals it is used for
  63. control flow, it doesn't work then.
  64. CTRL-SHIFT-V *c_CTRL-SHIFT-V* *c_CTRL-SHIFT-Q*
  65. CTRL-SHIFT-Q Works just like CTRL-V, but do not try to include the CTRL
  66. modifier into the key.
  67. *c_<Left>* *c_Left*
  68. <Left> cursor left. See 'wildmenu' for behavior during wildmenu
  69. completion mode.
  70. *c_<Right>* *c_Right*
  71. <Right> cursor right. See 'wildmenu' for behavior during wildmenu
  72. completion mode.
  73. *c_<S-Left>*
  74. <S-Left> or <C-Left> *c_<C-Left>*
  75. cursor one WORD left
  76. *c_<S-Right>*
  77. <S-Right> or <C-Right> *c_<C-Right>*
  78. cursor one WORD right
  79. CTRL-B or <Home> *c_CTRL-B* *c_<Home>* *c_Home*
  80. cursor to beginning of command-line
  81. CTRL-E or <End> *c_CTRL-E* *c_<End>* *c_End*
  82. cursor to end of command-line. See 'wildmenu' for behavior
  83. during wildmenu completion mode.
  84. *c_<LeftMouse>*
  85. <LeftMouse> Move the cursor to the position of the mouse click.
  86. *c_<MiddleMouse>*
  87. <MiddleMouse> Paste the contents of the clipboard (for X11 the primary
  88. selection). This is similar to using `CTRL-R *`, but no CR
  89. characters are inserted between lines.
  90. CTRL-H *c_<BS>* *c_CTRL-H* *c_BS*
  91. <BS> Delete the character in front of the cursor.
  92. *c_<Del>* *c_Del*
  93. <Del> Delete the character under the cursor (at end of line:
  94. character before the cursor).
  95. *c_CTRL-W*
  96. CTRL-W Delete the |word| before the cursor. This depends on the
  97. 'iskeyword' option.
  98. *c_CTRL-U*
  99. CTRL-U Remove all characters between the cursor position and
  100. the beginning of the line. Previous versions of vim
  101. deleted all characters on the line. If that is the
  102. preferred behavior, add the following to your vimrc: >
  103. :cnoremap <C-U> <C-E><C-U>
  104. <
  105. *c_<Insert>* *c_Insert*
  106. <Insert> Toggle between insert and overstrike.
  107. {char1} <BS> {char2} or *c_digraph*
  108. CTRL-K {char1} {char2} *c_CTRL-K*
  109. enter digraph (see |digraphs|). When {char1} is a special
  110. key, the code for that key is inserted in <> form.
  111. CTRL-R {register} *c_CTRL-R* *c_<C-R>*
  112. Insert the contents of a numbered or named register. Between
  113. typing CTRL-R and the second character '"' will be displayed
  114. to indicate that you are expected to enter the name of a
  115. register.
  116. The text is inserted as if you typed it, but mappings and
  117. abbreviations are not used. Command-line completion through
  118. 'wildchar' is not triggered though. And characters that end
  119. the command line are inserted literally (<Esc>, <CR>, <NL>,
  120. <C-C>). A <BS> or CTRL-W could still end the command line
  121. though, and remaining characters will then be interpreted in
  122. another mode, which might not be what you intended.
  123. Special registers:
  124. '"' the unnamed register, containing the text of
  125. the last delete or yank
  126. '%' the current file name
  127. '#' the alternate file name
  128. "*" the clipboard contents (X11: primary selection)
  129. '+' the clipboard contents
  130. '/' the last search pattern
  131. ':' the last command-line
  132. '-' the last small (less than a line) delete
  133. '.' the last inserted text
  134. *c_CTRL-R_=*
  135. '=' the expression register: you are prompted to
  136. enter an expression (see |expression|)
  137. (doesn't work at the expression prompt; some
  138. things such as changing the buffer or current
  139. window are not allowed to avoid side effects)
  140. When the result is a |List| the items are used
  141. as lines. They can have line breaks inside
  142. too.
  143. When the result is a Float it's automatically
  144. converted to a String.
  145. Note that when you only want to move the
  146. cursor and not insert anything, you must make
  147. sure the expression evaluates to an empty
  148. string. E.g.: >
  149. <C-R><C-R>=setcmdpos(2)[-1]<CR>
  150. < See |registers| about registers.
  151. Implementation detail: When using the |expression| register
  152. and invoking setcmdpos(), this sets the position before
  153. inserting the resulting string. Use CTRL-R CTRL-R to set the
  154. position afterwards.
  155. CTRL-R CTRL-F *c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
  156. CTRL-R CTRL-P *c_CTRL-R_CTRL-P* *c_<C-R>_<C-P>*
  157. CTRL-R CTRL-W *c_CTRL-R_CTRL-W* *c_<C-R>_<C-W>*
  158. CTRL-R CTRL-A *c_CTRL-R_CTRL-A* *c_<C-R>_<C-A>*
  159. CTRL-R CTRL-L *c_CTRL-R_CTRL-L* *c_<C-R>_<C-L>*
  160. Insert the object under the cursor:
  161. CTRL-F the Filename under the cursor
  162. CTRL-P the Filename under the cursor, expanded with
  163. 'path' as in |gf|
  164. CTRL-W the Word under the cursor
  165. CTRL-A the WORD under the cursor; see |WORD|
  166. CTRL-L the line under the cursor
  167. When 'incsearch' is set the cursor position at the end of the
  168. currently displayed match is used. With CTRL-W the part of
  169. the word that was already typed is not inserted again.
  170. *c_CTRL-R_CTRL-R* *c_<C-R>_<C-R>*
  171. *c_CTRL-R_CTRL-O* *c_<C-R>_<C-O>*
  172. CTRL-R CTRL-R `{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}`
  173. CTRL-R CTRL-O `{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}`
  174. Insert register or object under the cursor. Works like
  175. |c_CTRL-R| but inserts the text literally. For example, if
  176. register a contains "xy^Hz" (where ^H is a backspace),
  177. "CTRL-R a" will insert "xz" while "CTRL-R CTRL-R a" will
  178. insert "xy^Hz".
  179. CTRL-\ e {expr} *c_CTRL-\_e*
  180. Evaluate {expr} and replace the whole command line with the
  181. result. You will be prompted for the expression, type <Enter>
  182. to finish it. It's most useful in mappings though. See
  183. |expression|.
  184. See |c_CTRL-R_=| for inserting the result of an expression.
  185. Useful functions are |getcmdtype()|, |getcmdline()| and
  186. |getcmdpos()|.
  187. The cursor position is unchanged, except when the cursor was
  188. at the end of the line, then it stays at the end.
  189. |setcmdpos()| can be used to set the cursor position.
  190. The |sandbox| is used for evaluating the expression to avoid
  191. nasty side effects.
  192. Example: >
  193. :cmap <F7> <C-\>eAppendSome()<CR>
  194. :func AppendSome()
  195. :let cmd = getcmdline() .. " Some()"
  196. :" place the cursor on the )
  197. :call setcmdpos(strlen(cmd))
  198. :return cmd
  199. :endfunc
  200. < This doesn't work recursively, thus not when already editing
  201. an expression. But it is possible to use in a mapping.
  202. *c_CTRL-Y*
  203. CTRL-Y When there is a modeless selection, copy the selection into
  204. the clipboard.
  205. If there is no selection CTRL-Y is inserted as a character.
  206. See 'wildmenu' for behavior during wildmenu completion mode.
  207. *c_CTRL-Z*
  208. CTRL-Z Trigger 'wildmode'. Same as 'wildcharm', but always available.
  209. CTRL-M or CTRL-J *c_CTRL-M* *c_CTRL-J* *c_<NL>* *c_<CR>* *c_CR*
  210. <CR> or <NL> start entered command
  211. CTRL-[ *c_CTRL-[* *c_<Esc>* *c_Esc*
  212. <Esc> When typed and 'x' not present in 'cpoptions', quit
  213. Command-line mode without executing. In macros or when 'x'
  214. present in 'cpoptions', start entered command.
  215. Note: If your <Esc> key is hard to hit on your keyboard, train
  216. yourself to use CTRL-[.
  217. *c_META* *c_ALT*
  218. ALT (|META|) may act like <Esc> if the chord is not mapped.
  219. For example <A-x> acts like <Esc>x if <A-x> does not have a
  220. command-line mode mapping.
  221. *c_CTRL-C*
  222. CTRL-C quit command-line without executing
  223. *c_<Up>* *c_Up*
  224. <Up> recall older command-line from history, whose beginning
  225. matches the current command-line (see below). See 'wildmenu'
  226. for behavior during wildmenu completion mode.
  227. *c_<Down>* *c_Down*
  228. <Down> recall more recent command-line from history, whose beginning
  229. matches the current command-line (see below). See 'wildmenu'
  230. for behavior during wildmenu completion mode.
  231. *c_<S-Up>* *c_<PageUp>*
  232. <S-Up> or <PageUp>
  233. recall older command-line from history
  234. *c_<S-Down>* *c_<PageDown>*
  235. <S-Down> or <PageDown>
  236. recall more recent command-line from history
  237. CTRL-D command-line completion (see |cmdline-completion|)
  238. 'wildchar' option
  239. command-line completion (see |cmdline-completion|)
  240. CTRL-N command-line completion (see |cmdline-completion|)
  241. CTRL-P command-line completion (see |cmdline-completion|)
  242. CTRL-A command-line completion (see |cmdline-completion|)
  243. CTRL-L command-line completion (see |cmdline-completion|)
  244. *c_CTRL-^*
  245. CTRL-^ Toggle the use of language |:lmap| mappings and/or Input
  246. Method.
  247. When typing a pattern for a search command and 'imsearch' is
  248. not -1, VAL is the value of 'imsearch', otherwise VAL is the
  249. value of 'iminsert'.
  250. When language mappings are defined:
  251. - If VAL is 1 (langmap mappings used) it becomes 0 (no langmap
  252. mappings used).
  253. - If VAL was not 1 it becomes 1, thus langmap mappings are
  254. enabled.
  255. When no language mappings are defined:
  256. - If VAL is 2 (Input Method is used) it becomes 0 (no input
  257. method used)
  258. - If VAL has another value it becomes 2, thus the Input Method
  259. is enabled.
  260. These language mappings are normally used to type characters
  261. that are different from what the keyboard produces. The
  262. 'keymap' option can be used to install a whole number of them.
  263. When entering a command line, langmap mappings are switched
  264. off, since you are expected to type a command. After
  265. switching it on with CTRL-^, the new state is not used again
  266. for the next command or Search pattern.
  267. *c_CTRL-]*
  268. CTRL-] Trigger abbreviation, without inserting a character.
  269. For Emacs-style editing on the command-line see |emacs-keys|.
  270. The <Up> and <Down> keys take the current command-line as a search string.
  271. The beginning of the next/previous command-lines are compared with this
  272. string. The first line that matches is the new command-line. When typing
  273. these two keys repeatedly, the same string is used again. For example, this
  274. can be used to find the previous substitute command: Type ":s" and then <Up>.
  275. The same could be done by typing <S-Up> a number of times until the desired
  276. command-line is shown. (Note: the shifted arrow keys do not work on all
  277. terminals)
  278. *:his* *:history*
  279. :his[tory] Print the history of last entered commands.
  280. :his[tory] [{name}] [{first}][, [{last}]]
  281. List the contents of history {name} which can be:
  282. c[md] or : command-line history
  283. s[earch] or / or ? search string history
  284. e[xpr] or = expression register history
  285. i[nput] or @ input line history
  286. d[ebug] or > debug command history
  287. a[ll] all of the above
  288. If the numbers {first} and/or {last} are given, the respective
  289. range of entries from a history is listed. These numbers can
  290. be specified in the following form:
  291. *:history-indexing*
  292. A positive number represents the absolute index of an entry
  293. as it is given in the first column of a :history listing.
  294. This number remains fixed even if other entries are deleted.
  295. (see |E1510|)
  296. A negative number means the relative position of an entry,
  297. counted from the newest entry (which has index -1) backwards.
  298. Examples:
  299. List entries 6 to 12 from the search history: >
  300. :history / 6,12
  301. <
  302. List the penultimate entry from all histories: >
  303. :history all -2
  304. <
  305. List the most recent two entries from all histories: >
  306. :history all -2,
  307. :keepp[atterns] {command} *:keepp* *:keeppatterns*
  308. Execute {command}, without adding anything to the search
  309. history and, in case of |:s| or |:&|, without modifying the
  310. last substitute pattern or substitute string.
  311. ==============================================================================
  312. 2. Command-line completion *cmdline-completion*
  313. When editing the command-line, a few commands can be used to complete the
  314. word before the cursor. This is available for:
  315. - Command names: At the start of the command-line.
  316. - |++opt| values.
  317. - Tags: Only after the ":tag" command.
  318. - File names: Only after a command that accepts a file name or a setting for
  319. an option that can be set to a file name. This is called file name
  320. completion.
  321. - Shell command names: After ":!cmd", ":r !cmd" and ":w !cmd". $PATH is used.
  322. - Options: Only after the ":set" command.
  323. - Mappings: Only after a ":map" or similar command.
  324. - Variable and function names: Only after a ":if", ":call" or similar command.
  325. The number of help item matches is limited (currently to 300) to avoid a long
  326. delay when there are very many matches.
  327. These are the commands that can be used:
  328. *c_CTRL-D*
  329. CTRL-D List names that match the pattern in front of the cursor.
  330. When showing file names, directories are highlighted (see
  331. |highlight-groups|). Names where 'suffixes' matches are moved
  332. to the end.
  333. The 'wildoptions' option can be set to "tagfile" to list the
  334. file of matching tags.
  335. *c_CTRL-I* *c_wildchar* *c_<Tab>*
  336. 'wildchar' option
  337. A match is done on the pattern in front of the cursor. The
  338. match (if there are several, the first match) is inserted
  339. in place of the pattern. (Note: does not work inside a
  340. macro, because <Tab> or <Esc> are mostly used as 'wildchar',
  341. and these have a special meaning in some macros.) When typed
  342. again and there were multiple matches, the next
  343. match is inserted. After the last match, the first is used
  344. again (wrap around).
  345. The behavior can be changed with the 'wildmode' option.
  346. *c_<S-Tab>*
  347. <S-Tab> Like 'wildchar' or <Tab>, but begin with the last match and
  348. then go to the previous match.
  349. *c_CTRL-N*
  350. CTRL-N After using 'wildchar' which got multiple matches, go to next
  351. match. Otherwise recall more recent command-line from history.
  352. *c_CTRL-P*
  353. CTRL-P After using 'wildchar' which got multiple matches, go to
  354. previous match. Otherwise recall older command-line from
  355. history.
  356. *c_CTRL-A*
  357. CTRL-A All names that match the pattern in front of the cursor are
  358. inserted.
  359. *c_CTRL-L*
  360. CTRL-L A match is done on the pattern in front of the cursor. If
  361. there is one match, it is inserted in place of the pattern.
  362. If there are multiple matches the longest common part is
  363. inserted in place of the pattern. If the result is shorter
  364. than the pattern, no completion is done.
  365. */_CTRL-L*
  366. When 'incsearch' is set, entering a search pattern for "/" or
  367. "?" and the current match is displayed then CTRL-L will add
  368. one character from the end of the current match. If
  369. 'ignorecase' and 'smartcase' are set and the command line has
  370. no uppercase characters, the added character is converted to
  371. lowercase.
  372. *c_CTRL-G* */_CTRL-G*
  373. CTRL-G When 'incsearch' is set, entering a search pattern for "/" or
  374. "?" and the current match is displayed then CTRL-G will move
  375. to the next match (does not take |search-offset| into account)
  376. Use CTRL-T to move to the previous match. Hint: on a regular
  377. keyboard T is above G.
  378. *c_CTRL-T* */_CTRL-T*
  379. CTRL-T When 'incsearch' is set, entering a search pattern for "/" or
  380. "?" and the current match is displayed then CTRL-T will move
  381. to the previous match (does not take |search-offset| into
  382. account).
  383. Use CTRL-G to move to the next match. Hint: on a regular
  384. keyboard T is above G.
  385. The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
  386. a previous version <Esc> was used). In the pattern standard |wildcards| are
  387. accepted when matching file names.
  388. When repeating 'wildchar' or CTRL-N you cycle through the matches, eventually
  389. ending up back to what was typed. If the first match is not what you wanted,
  390. you can use <S-Tab> or CTRL-P to go straight back to what you typed.
  391. The 'wildmenu' option can be set to show the matches just above the command
  392. line.
  393. The 'wildoptions' option provides additional configuration to use a popup menu
  394. for 'wildmenu', and to use fuzzy matching.
  395. The 'wildignorecase' option can be set to ignore case in filenames. For
  396. completing other texts (e.g. command names), the 'ignorecase' option is used
  397. instead (fuzzy matching always ignores case, however).
  398. If you like tcsh's autolist completion, you can use this mapping: >
  399. :cnoremap X <C-L><C-D>
  400. (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
  401. This will find the longest match and then list all matching files.
  402. If you like tcsh's autolist completion, you can use the 'wildmode' option to
  403. emulate it. For example, this mimics autolist=ambiguous: >
  404. :set wildmode=longest,list
  405. This will find the longest match with the first 'wildchar', then list all
  406. matching files with the next.
  407. *complete-script-local-functions*
  408. When completing user function names, prepend "s:" to find script-local
  409. functions.
  410. *suffixes*
  411. For file name completion you can use the 'suffixes' option to set a priority
  412. between files with almost the same name. If there are multiple matches,
  413. those files with an extension that is in the 'suffixes' option are ignored.
  414. The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
  415. in ".bak", "~", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.
  416. An empty entry, two consecutive commas, match a file name that does not
  417. contain a ".", thus has no suffix. This is useful to ignore "prog" and prefer
  418. "prog.c".
  419. Examples:
  420. pattern: files: match: ~
  421. test* test.c test.h test.o test.c
  422. test* test.h test.o test.h and test.o
  423. test* test.i test.h test.c test.i and test.c
  424. It is impossible to ignore suffixes with two dots.
  425. If there is more than one matching file (after ignoring the ones matching
  426. the 'suffixes' option) the first file name is inserted. You can see that
  427. there is only one match when you type 'wildchar' twice and the completed
  428. match stays the same. You can get to the other matches by entering
  429. 'wildchar', CTRL-N or CTRL-P. All files are included, also the ones with
  430. extensions matching the 'suffixes' option.
  431. To completely ignore files with some extension use 'wildignore'.
  432. To match only files that end at the end of the typed text append a "$". For
  433. example, to match only files that end in ".c": >
  434. :e *.c$
  435. This will not match a file ending in ".cpp". Without the "$" it does match.
  436. If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
  437. your .cshrc: >
  438. xmodmap -e "keysym Tab = Tab Find"
  439. And this in your vimrc: >
  440. :cmap <Esc>[1~ <C-P>
  441. < *complete-set-option*
  442. When setting an option using |:set=|, the old value of an option can be
  443. obtained by hitting 'wildchar' just after the '='. For example, typing
  444. 'wildchar' after ":set dir=" will insert the current value of 'dir'. This
  445. overrules file name completion for the options that take a file name.
  446. When using |:set=|, |:set+=|, or |:set^=|, string options that have
  447. pre-defined names or syntax (e.g. 'diffopt', 'listchars') or are a list of
  448. single-character flags (e.g. 'shortmess') will also present a list of possible
  449. values for completion when using 'wildchar'.
  450. When using |:set-=|, comma-separated options like 'diffopt' or 'backupdir'
  451. will show each item separately. Flag list options like 'shortmess' will show
  452. both the entire old value and the individual flags. Otherwise completion will
  453. just fill in with the entire old value.
  454. ==============================================================================
  455. 3. Ex command-lines *cmdline-lines*
  456. The Ex commands have a few specialties:
  457. *:quote* *:comment*
  458. '"' at the start of a line causes the whole line to be ignored. '"'
  459. after a command causes the rest of the line to be ignored. This can be used
  460. to add comments. Example: >
  461. :set ai "set 'autoindent' option
  462. It is not possible to add a comment to a shell command ":!cmd" or to the
  463. ":map" command and a few others (mainly commands that expect expressions)
  464. that see the '"' as part of their argument:
  465. :argdo
  466. :autocmd
  467. :bufdo
  468. :cexpr (and the like)
  469. :cdo (and the like)
  470. :command
  471. :debug
  472. :display
  473. :echo (and the like)
  474. :elseif
  475. :execute
  476. :folddoopen
  477. :folddoclosed
  478. :for
  479. :grep (and the like)
  480. :help (and the like)
  481. :if
  482. :let
  483. :make
  484. :map (and the like including :abbrev commands)
  485. :menu (and the like)
  486. :mkspell
  487. :normal
  488. :ownsyntax
  489. :popup
  490. :registers
  491. :return
  492. :sort
  493. :syntax
  494. :tabdo
  495. :tearoff
  496. :vimgrep (and the like)
  497. :while
  498. :windo
  499. *:bar* *:\bar*
  500. '|' can be used to separate commands, so you can give multiple commands in one
  501. line. If you want to use '|' in an argument, precede it with '\'.
  502. These commands see the '|' as their argument, and can therefore not be
  503. followed by another Vim command:
  504. :argdo
  505. :autocmd
  506. :bufdo
  507. :cdo
  508. :cfdo
  509. :command
  510. :debug
  511. :eval
  512. :folddoopen
  513. :folddoclosed
  514. :function
  515. :global
  516. :help
  517. :helpgrep
  518. :ldo
  519. :lfdo
  520. :lhelpgrep
  521. :make
  522. :normal
  523. :perlfile
  524. :pyfile
  525. :python
  526. :registers
  527. :read !
  528. :sign
  529. :tabdo
  530. :terminal
  531. :vglobal
  532. :windo
  533. :write !
  534. :[range]!
  535. a user defined command without the "-bar" argument |:command|
  536. Note that this is confusing (inherited from Vi): With ":g" the '|' is included
  537. in the command, with ":s" it is not.
  538. To be able to use another command anyway, use the ":execute" command.
  539. Example (append the output of "ls" and jump to the first line): >
  540. :execute 'r !ls' | '[
  541. There is one exception: When the 'b' flag is present in 'cpoptions', with the
  542. ":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
  543. '\'. You can also use "<Bar>" instead. See also |map_bar|.
  544. Examples: >
  545. :!ls | wc view the output of two commands
  546. :r !ls | wc insert the same output in the text
  547. :%g/foo/p|> moves all matching lines one shiftwidth
  548. :%s/foo/bar/|> moves one line one shiftwidth
  549. :map q 10^V| map "q" to "10|"
  550. :map q 10\| map \ l map "q" to "10\" and map "\" to "l"
  551. (when 'b' is present in 'cpoptions')
  552. You can also use <NL> to separate commands in the same way as with '|'. To
  553. insert a <NL> use CTRL-V CTRL-J. "^@" will be shown. Using '|' is the
  554. preferred method. But for external commands a <NL> must be used, because a
  555. '|' is included in the external command. To avoid the special meaning of <NL>
  556. it must be preceded with a backslash. Example: >
  557. :r !date<NL>-join
  558. This reads the current date into the file and joins it with the previous line.
  559. Note that when the command before the '|' generates an error, the following
  560. commands will not be executed.
  561. Because of Vi compatibility the following strange commands are supported: >
  562. :| print current line (like ":p")
  563. :3| print line 3 (like ":3p")
  564. :3 goto line 3
  565. A colon is allowed between the range and the command name. It is ignored
  566. (this is Vi compatible). For example: >
  567. :1,$:s/pat/string
  568. When the character '%' or '#' is used where a file name is expected, they are
  569. expanded to the current and alternate file name (see the chapter "editing
  570. files" |:_%| |:_#|).
  571. Trailing spaces in filenames will be ignored, unless escaped with a backslash
  572. or CTRL-V. Note that the ":next" command uses spaces to separate file names.
  573. Escape the spaces to include them in a file name. Example: >
  574. :next foo\ bar goes\ to school\
  575. starts editing the three files "foo bar", "goes to" and "school ".
  576. When you want to use the special characters '"' or '|' in a command, or want
  577. to use '%' or '#' in a file name, precede them with a backslash. The
  578. backslash is not required in a range and in the ":substitute" command.
  579. See also |`=|.
  580. *:_!*
  581. The '!' (bang) character after an Ex command makes the command behave in a
  582. different way. The '!' should be placed immediately after the command, without
  583. any blanks in between. If you insert blanks the '!' will be seen as an
  584. argument for the command, which has a different meaning. For example:
  585. :w! name write the current buffer to file "name", overwriting
  586. any existing file
  587. :w !name send the current buffer as standard input to command
  588. "name"
  589. ==============================================================================
  590. 4. Ex command-line ranges *cmdline-ranges* *[range]* *E16*
  591. Some Ex commands accept a line range in front of them. This is noted as
  592. [range]. It consists of one or more line specifiers, separated with ',' or
  593. ';'.
  594. The basics are explained in section |10.3| of the user manual.
  595. *:,* *:;*
  596. When separated with ';' the cursor position will be set to that line
  597. before interpreting the next line specifier. This doesn't happen for ','.
  598. Examples: >
  599. 4,/this line/
  600. < from line 4 till match with "this line" after the cursor line. >
  601. 5;/that line/
  602. < from line 5 till match with "that line" after line 5.
  603. The default line specifier for most commands is the cursor position, but the
  604. commands ":write" and ":global" have the whole file (1,$) as default.
  605. If more line specifiers are given than required for the command, the first
  606. one(s) will be ignored.
  607. Line numbers may be specified with: *:range* *{address}*
  608. {number} an absolute line number *E1247*
  609. . the current line *:.*
  610. $ the last line in the file *:$*
  611. % equal to 1,$ (the entire file) *:%*
  612. 't position of mark t (lowercase) *:'*
  613. 'T position of mark T (uppercase); when the mark is in
  614. another file it cannot be used in a range
  615. /{pattern}[/] the next line where {pattern} matches *:/*
  616. also see |:range-pattern| below
  617. ?{pattern}[?] the previous line where {pattern} matches *:?*
  618. also see |:range-pattern| below
  619. \/ the next line where the previously used search
  620. pattern matches
  621. \? the previous line where the previously used search
  622. pattern matches
  623. \& the next line where the previously used substitute
  624. pattern matches
  625. *:range-offset*
  626. Each may be followed (several times) by '+' or '-' and an optional number.
  627. This number is added or subtracted from the preceding line number. If the
  628. number is omitted, 1 is used. If there is nothing before the '+' or '-' then
  629. the current line is used.
  630. *:range-closed-fold*
  631. When a line number after the comma is in a closed fold it is adjusted to the
  632. last line of the fold, thus the whole fold is included.
  633. When a number is added this is done after the adjustment to the last line of
  634. the fold. This means these lines are additionally included in the range. For
  635. example: >
  636. :3,4+2print
  637. On this text:
  638. 1 one ~
  639. 2 two ~
  640. 3 three ~
  641. 4 four FOLDED ~
  642. 5 five FOLDED ~
  643. 6 six ~
  644. 7 seven ~
  645. 8 eight ~
  646. Where lines four and five are a closed fold, ends up printing lines 3 to 7.
  647. The 7 comes from the "4" in the range, which is adjusted to the end of the
  648. closed fold, which is 5, and then the offset 2 is added.
  649. An example for subtracting (which isn't very useful): >
  650. :2,4-1print
  651. On this text:
  652. 1 one ~
  653. 2 two ~
  654. 3 three FOLDED ~
  655. 4 four FOLDED ~
  656. 5 five FOLDED ~
  657. 6 six FOLDED ~
  658. 7 seven ~
  659. 8 eight ~
  660. Where lines three to six are a closed fold, ends up printing lines 2 to 6.
  661. The 6 comes from the "4" in the range, which is adjusted to the end of the
  662. closed fold, which is 6, and then 1 is subtracted, then this is still in the
  663. closed fold and the last line of that fold is used, which is 6.
  664. *:range-pattern*
  665. The "/" and "?" after {pattern} are required to separate the pattern from
  666. anything that follows.
  667. The "/" and "?" may be preceded with another address. The search starts from
  668. there. The difference from using ';' is that the cursor isn't moved.
  669. Examples: >
  670. /pat1//pat2/ Find line containing "pat2" after line containing
  671. "pat1", without moving the cursor.
  672. 7;/pat2/ Find line containing "pat2", after line 7, leaving
  673. the cursor in line 7.
  674. The {number} must be between 0 and the number of lines in the file. When
  675. using a 0 (zero) this is interpreted as a 1 by most commands. Commands that
  676. use it as a count do use it as a zero (|:tag|, |:pop|, etc). Some commands
  677. interpret the zero as "before the first line" (|:read|, search pattern, etc).
  678. Examples: >
  679. .+3 three lines below the cursor
  680. /that/+1 the line below the next line containing "that"
  681. .,$ from current line until end of file
  682. 0;/that the first line containing "that", also matches in the
  683. first line.
  684. 1;/that the first line after line 1 containing "that"
  685. Some commands allow for a count after the command. This count is used as the
  686. number of lines to be used, starting with the line given in the last line
  687. specifier (the default is the cursor line). The commands that accept a count
  688. are the ones that use a range but do not have a file name argument (because
  689. a file name can also be a number). The count cannot be negative.
  690. Examples: >
  691. :s/x/X/g 5 substitute 'x' by 'X' in the current line and four
  692. following lines
  693. :23d 4 delete lines 23, 24, 25 and 26
  694. Folds and Range
  695. When folds are active the line numbers are rounded off to include the whole
  696. closed fold. See |fold-behavior|.
  697. Reverse Range *E493*
  698. A range should have the lower line number first. If this is not the case, Vim
  699. will ask you if it should swap the line numbers.
  700. Backwards range given, OK to swap ~
  701. This is not done within the global command ":g".
  702. You can use ":silent" before a command to avoid the question, the range will
  703. always be swapped then.
  704. Count and Range *N:*
  705. When giving a count before entering ":", this is translated into: >
  706. :.,.+(count - 1)
  707. In words: The "count" lines at and after the cursor. Example: To delete
  708. three lines: >
  709. 3:d<CR> is translated into: .,.+2d<CR>
  710. <
  711. Visual Mode and Range
  712. *v_:*
  713. {Visual}: Starts a command-line with the Visual selected lines as a
  714. range. The code `:'<,'>` is used for this range, which makes
  715. it possible to select a similar line from the command-line
  716. history for repeating a command on different Visually selected
  717. lines.
  718. :* *:star* *:star-visual-range*
  719. When Visual mode was already ended, a short way to use the
  720. Visual area for a range is `:*`.
  721. ==============================================================================
  722. 5. Ex command-line flags *ex-flags*
  723. These flags are supported by a selection of Ex commands. They print the line
  724. that the cursor ends up after executing the command:
  725. l output like for |:list|
  726. # add line number
  727. p output like for |:print|
  728. The flags can be combined, thus "l#" uses both a line number and |:list| style
  729. output.
  730. ==============================================================================
  731. 6. Ex special characters *cmdline-special*
  732. Note: These are special characters in the executed command line. If you want
  733. to insert special things while typing you can use the CTRL-R command. For
  734. example, "%" stands for the current file name, while CTRL-R % inserts the
  735. current file name right away. See |c_CTRL-R|.
  736. Note: If you want to avoid the effects of special characters in a Vim script
  737. you may want to use |fnameescape()|. Also see |`=|.
  738. In Ex commands, at places where a file name can be used, the following
  739. characters have a special meaning. These can also be used in the expression
  740. function |expand()|.
  741. % Is replaced with the current file name. *:_%* *c_%*
  742. # Is replaced with the alternate file name. *:_#* *c_#*
  743. This is remembered for every window.
  744. #n (where n is a number) is replaced with *:_#0* *:_#n*
  745. the file name of buffer n. "#0" is the same as "#". *c_#n*
  746. ## Is replaced with all names in the argument list *:_##* *c_##*
  747. concatenated, separated by spaces. Each space in a name
  748. is preceded with a backslash.
  749. #<n (where n is a number > 0) is replaced with old *:_#<* *c_#<*
  750. file name n. See |:oldfiles| or |v:oldfiles| to get the
  751. number. *E809*
  752. Note that these, except "#<n", give the file name as it was typed. If an
  753. absolute path is needed (when using the file name from a different directory),
  754. you need to add ":p". See |filename-modifiers|.
  755. The "#<n" item returns an absolute path, but it will start with "~/" for files
  756. below your home directory.
  757. Note that backslashes are inserted before spaces, so that the command will
  758. correctly interpret the file name. But this doesn't happen for shell
  759. commands. For those you probably have to use quotes (this fails for files
  760. that contain a quote and wildcards): >
  761. :!ls "%"
  762. :r !spell "%"
  763. To avoid the special meaning of '%' and '#' insert a backslash before it.
  764. Detail: The special meaning is always escaped when there is a backslash before
  765. it, no matter how many backslashes.
  766. you type: result ~
  767. # alternate.file
  768. \# #
  769. \\# \#
  770. Also see |`=|.
  771. *E499* *E500*
  772. Note: these are typed literally, they are not special keys!
  773. *:<cword>* *<cword>*
  774. <cword> is replaced with the word under the cursor (like |star|)
  775. *:<cWORD>* *<cWORD>*
  776. <cWORD> is replaced with the WORD under the cursor (see |WORD|)
  777. *:<cexpr>* *<cexpr>*
  778. <cexpr> is replaced with the word under the cursor, including more
  779. to form a C expression. E.g., when the cursor is on "arg"
  780. of "ptr->arg" then the result is "ptr->arg"; when the
  781. cursor is on "]" of "list[idx]" then the result is
  782. "list[idx]".
  783. *:<cfile>* *<cfile>*
  784. <cfile> is replaced with the path name under the cursor (like what
  785. |gf| uses)
  786. *:<afile>* *<afile>*
  787. <afile> When executing autocommands, is replaced with the file name
  788. of the buffer being manipulated, or the file for a read or
  789. write. *E495*
  790. *:<abuf>* *<abuf>*
  791. <abuf> When executing autocommands, is replaced with the currently
  792. effective buffer number. It is not set for all events,
  793. also see |bufnr()|. For ":r file" and ":so file" it is the
  794. current buffer, the file being read/sourced is not in a
  795. buffer. *E496*
  796. *:<amatch>* *<amatch>*
  797. <amatch> When executing autocommands, is replaced with the match for
  798. which this autocommand was executed. *E497*
  799. It differs from <afile> when the file name isn't used to
  800. match with (for FileType, Syntax and SpellFileMissing
  801. events).
  802. When the match is with a file name, it is expanded to the
  803. full path.
  804. *:<sfile>* *<sfile>*
  805. <sfile> When executing a `:source` command, is replaced with the
  806. file name of the sourced file. *E498*
  807. When executing a function, is replaced with the call stack,
  808. as with <stack> (this is for backwards compatibility, using
  809. <stack> or <script> is preferred).
  810. Note that filename-modifiers are useless when <sfile> is
  811. not used inside a script.
  812. *:<stack>* *<stack>*
  813. <stack> is replaced with the call stack, using
  814. "function {function-name}[{lnum}]" for a function line
  815. and "script {file-name}[{lnum}]" for a script line, and
  816. ".." in between items. E.g.:
  817. "function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
  818. If there is no call stack you get error *E489* .
  819. *:<script>* *<script>*
  820. <script> When executing a `:source` command, is replaced with the file
  821. name of the sourced file. When executing a function, is
  822. replaced with the file name of the script where it is
  823. defined.
  824. If the file name cannot be determined you get error *E1274* .
  825. *:<slnum>* *<slnum>*
  826. <slnum> When executing a `:source` command, is replaced with the
  827. line number. *E842*
  828. When executing a function it's the line number relative to
  829. the start of the function.
  830. *:<sflnum>* *<sflnum>*
  831. <sflnum> When executing a script, is replaced with the line number.
  832. It differs from <slnum> in that <sflnum> is replaced with
  833. the script line number in any situation. *E961*
  834. *filename-modifiers*
  835. *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs* *::S*
  836. *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
  837. The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
  838. "<afile>" or "<abuf>". They are also used with the |fnamemodify()| function.
  839. These modifiers can be given, in this order:
  840. :p Make file name a full path. Must be the first modifier. Also
  841. changes "~/" (and "~user/" for Unix) to the path for the home
  842. directory. If the name is a directory a path separator is
  843. added at the end. For a file name that does not exist and
  844. does not have an absolute path the result is unpredictable.
  845. On MS-Windows an 8.3 filename is expanded to the long name.
  846. :8 Converts the path to 8.3 short format (currently only on
  847. MS-Windows). Will act on as much of a path that is an
  848. existing path.
  849. :~ Reduce file name to be relative to the home directory, if
  850. possible. File name is unmodified if it is not below the home
  851. directory.
  852. :. Reduce file name to be relative to current directory, if
  853. possible. File name is unmodified if it is not below the
  854. current directory.
  855. For maximum shortness, use ":~:.".
  856. :h Head of the file name (the last component and any separators
  857. removed). Cannot be used with :e, :r or :t.
  858. Can be repeated to remove several components at the end.
  859. When the file name ends in a path separator, only the path
  860. separator is removed. Thus ":p:h" on a directory name results
  861. on the directory name itself (without trailing slash).
  862. When the file name is an absolute path (starts with "/" for
  863. Unix; "x:\" for Win32), that part is not removed.
  864. When there is no head (path is relative to current directory)
  865. the result is empty.
  866. :t Tail of the file name (last component of the name). Must
  867. precede any :r or :e.
  868. :r Root of the file name (the last extension removed). When
  869. there is only an extension (file name that starts with '.',
  870. e.g., ".nvimrc"), it is not removed. Can be repeated to
  871. remove several extensions (last one first).
  872. :e Extension of the file name. Only makes sense when used alone.
  873. When there is no extension the result is empty.
  874. When there is only an extension (file name that starts with
  875. '.'), the result is empty. Can be repeated to include more
  876. extensions. If there are not enough extensions (but at least
  877. one) as much as possible are included.
  878. :s?pat?sub?
  879. Substitute the first occurrence of "pat" with "sub". This
  880. works like the |:s| command. "pat" is a regular expression.
  881. Any character can be used for '?', but it must not occur in
  882. "pat" or "sub".
  883. After this, the previous modifiers can be used again. For
  884. example ":p", to make a full path after the substitution.
  885. :gs?pat?sub?
  886. Substitute all occurrences of "pat" with "sub". Otherwise
  887. this works like ":s".
  888. :S Escape special characters for use with a shell command (see
  889. |shellescape()|). Must be the last one. Examples: >
  890. :!dir <cfile>:S
  891. :call system('chmod +w -- ' . expand('%:S'))
  892. Examples, when the file name is "src/version.c", current dir
  893. "/home/mool/vim": >
  894. :p /home/mool/vim/src/version.c
  895. :p:. src/version.c
  896. :p:~ ~/vim/src/version.c
  897. :h src
  898. :p:h /home/mool/vim/src
  899. :p:h:h /home/mool/vim
  900. :t version.c
  901. :p:t version.c
  902. :r src/version
  903. :p:r /home/mool/vim/src/version
  904. :t:r version
  905. :e c
  906. :s?version?main? src/main.c
  907. :s?version?main?:p /home/mool/vim/src/main.c
  908. :p:gs?/?\\? \home\mool\vim\src\version.c
  909. Examples, when the file name is "src/version.c.gz": >
  910. :p /home/mool/vim/src/version.c.gz
  911. :e gz
  912. :e:e c.gz
  913. :e:e:e c.gz
  914. :e:e:r c
  915. :r src/version.c
  916. :r:e c
  917. :r:r src/version
  918. :r:r:r src/version
  919. <
  920. *extension-removal* *:_%<*
  921. If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
  922. name is removed (everything after and including the last '.' in the file
  923. name). This is included for backwards compatibility with version 3.0, the
  924. ":r" form is preferred. Examples: >
  925. % current file name
  926. %< current file name without extension
  927. # alternate file name for current window
  928. #< idem, without extension
  929. #31 alternate file number 31
  930. #31< idem, without extension
  931. <cword> word under the cursor
  932. <cWORD> WORD under the cursor (see |WORD|)
  933. <cfile> path name under the cursor
  934. <cfile>< idem, without extension
  935. Note: Where a file name is expected wildcards expansion is done. On Unix the
  936. shell is used for this, unless it can be done internally (for speed).
  937. Backticks work also, like in >
  938. :n `echo *.c`
  939. But expansion is only done if there are any wildcards before expanding the
  940. '%', '#', etc.. This avoids expanding wildcards inside a file name. If you
  941. want to expand the result of <cfile>, add a wildcard character to it.
  942. Examples: (alternate file name is "?readme?")
  943. command expands to >
  944. :e # :e ?readme?
  945. :e `ls #` :e {files matching "?readme?"}
  946. :e #.* :e {files matching "?readme?.*"}
  947. :cd <cfile> :cd {file name under cursor}
  948. :cd <cfile>* :cd {file name under cursor plus "*" and then expanded}
  949. Also see |`=|.
  950. When the expanded argument contains a "!" and it is used for a shell command
  951. (":!cmd", ":r !cmd" or ":w !cmd"), the "!" is escaped with a backslash to
  952. avoid it being expanded into a previously used command. When the 'shell'
  953. option contains "sh", this is done twice, to avoid the shell trying to expand
  954. the "!".
  955. *filename-backslash*
  956. For filesystems that use a backslash as directory separator (Windows
  957. filesystems), it's a bit difficult to recognize a backslash that is used
  958. to escape the special meaning of the next character. The general rule is: If
  959. the backslash is followed by a normal file name character, it does not have a
  960. special meaning. Therefore "\file\foo" is a valid file name, you don't have
  961. to type the backslash twice.
  962. An exception is the '$' sign. It is a valid character in a file name. But
  963. to avoid a file name like "$home" to be interpreted as an environment variable,
  964. it needs to be preceded by a backslash. Therefore you need to use "/\$home"
  965. for the file "$home" in the root directory. A few examples:
  966. FILE NAME INTERPRETED AS ~
  967. $home expanded to value of environment var $home
  968. \$home file "$home" in current directory
  969. /\$home file "$home" in root directory
  970. \\$home file "\\", followed by expanded $home
  971. Also see |`=|.
  972. ==============================================================================
  973. 7. Command-line window *cmdline-window* *cmdwin*
  974. *command-line-window*
  975. In the command-line window the command line can be edited just like editing
  976. text in any window. It is a special kind of window, because you cannot leave
  977. it in a normal way.
  978. OPEN *c_CTRL-F* *q:* *q/* *q?*
  979. There are two ways to open the command-line window:
  980. 1. From Command-line mode, use the key specified with the 'cedit' option.
  981. 2. From Normal mode, use the "q:", "q/" or "q?" command.
  982. This starts editing an Ex command-line ("q:") or search string ("q/" or
  983. "q?"). Note that this is not possible while recording is in progress (the
  984. "q" stops recording then).
  985. When the window opens it is filled with the command-line history. The last
  986. line contains the command as typed so far. The left column will show a
  987. character that indicates the type of command-line being edited, see
  988. |cmdwin-char|.
  989. Vim will be in Normal mode when the editor is opened.
  990. The height of the window is specified with 'cmdwinheight' (or smaller if there
  991. is no room). The window is always full width and is positioned just above the
  992. command-line.
  993. EDIT
  994. You can now use commands to move around and edit the text in the window. Both
  995. in Normal mode and Insert mode.
  996. It is possible to use ":", "/" and other commands that use the command-line,
  997. but it's not possible to open another command-line window then. There is no
  998. nesting.
  999. *E11* *E1188*
  1000. The command-line window is not a normal window. It is not possible to move to
  1001. another window or edit another buffer. All commands that would do this are
  1002. disabled in the command-line window. Of course it _is_ possible to execute
  1003. any command that you entered in the command-line window. Other text edits are
  1004. discarded when closing the window.
  1005. CLOSE *E199*
  1006. There are several ways to leave the command-line window:
  1007. <CR> Execute the command-line under the cursor. Works both in
  1008. Insert and in Normal mode.
  1009. CTRL-C Continue in Command-line mode. The command-line under the
  1010. cursor is used as the command-line. Works both in Insert and
  1011. in Normal mode. There is no redraw, thus the window will
  1012. remain visible.
  1013. :quit Discard the command line and go back to Normal mode.
  1014. ":close", CTRL-W c, ":exit", ":xit" and CTRL-\ CTRL-N also
  1015. work.
  1016. :qall Quit Vim, unless there are changes in some buffer.
  1017. :qall! Quit Vim, discarding changes to any buffer.
  1018. Once the command-line window is closed the old window sizes are restored. The
  1019. executed command applies to the window and buffer where the command-line was
  1020. started from. This works as if the command-line window was not there, except
  1021. that there will be an extra screen redraw.
  1022. The buffer used for the command-line window is deleted. Any changes to lines
  1023. other than the one that is executed with <CR> are lost.
  1024. If you would like to execute the command under the cursor and then have the
  1025. command-line window open again, you may find this mapping useful: >
  1026. :autocmd CmdwinEnter * map <buffer> <F5> <CR>q:
  1027. VARIOUS
  1028. The command-line window cannot be used when there already is a command-line
  1029. window (no nesting).
  1030. Some options are set when the command-line window is opened:
  1031. 'filetype' "vim", when editing an Ex command-line; this starts Vim syntax
  1032. highlighting if it was enabled
  1033. 'rightleft' off
  1034. 'modifiable' on
  1035. 'buftype' "nofile"
  1036. 'swapfile' off
  1037. It is allowed to write the buffer contents to a file. This is an easy way to
  1038. save the command-line history and read it back later.
  1039. If the 'wildchar' option is set to <Tab>, and the command-line window is used
  1040. for an Ex command, then two mappings will be added to use <Tab> for completion
  1041. in the command-line window, like this: >
  1042. :inoremap <buffer> <Tab> <C-X><C-V>
  1043. :nnoremap <buffer> <Tab> a<C-X><C-V>
  1044. Note that hitting <Tab> in Normal mode will do completion on the next
  1045. character. That way it works at the end of the line.
  1046. If you don't want these mappings, disable them with: >
  1047. au CmdwinEnter [:>] iunmap <buffer> <Tab>
  1048. au CmdwinEnter [:>] nunmap <buffer> <Tab>
  1049. You could put these lines in your vimrc file.
  1050. While in the command-line window you cannot use the mouse to put the cursor in
  1051. another window, or drag statuslines of other windows. You can drag the
  1052. statusline of the command-line window itself and the statusline above it.
  1053. Thus you can resize the command-line window, but not others.
  1054. The |getcmdwintype()| function returns the type of the command-line being
  1055. edited as described in |cmdwin-char|.
  1056. Nvim defines this default CmdWinEnter autocmd in the "nvim_cmdwin" group: >
  1057. autocmd CmdWinEnter [:>] syntax sync minlines=1 maxlines=1
  1058. <
  1059. You can disable this in your config with "autocmd! nvim_cmdwin". |default-autocmds|
  1060. AUTOCOMMANDS
  1061. Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|. You can use
  1062. the Cmdwin events to do settings specifically for the command-line window.
  1063. Be careful not to cause side effects!
  1064. Example: >
  1065. :au CmdwinEnter : let b:cpt_save = &cpt | set cpt=.
  1066. :au CmdwinLeave : let &cpt = b:cpt_save
  1067. This sets 'complete' to use completion in the current window for |i_CTRL-N|.
  1068. Another example: >
  1069. :au CmdwinEnter [/?] startinsert
  1070. This will make Vim start in Insert mode in the command-line window.
  1071. *cmdline-char* *cmdwin-char*
  1072. The character used for the pattern indicates the type of command-line:
  1073. : normal Ex command
  1074. > debug mode command |debug-mode|
  1075. / forward search string
  1076. ? backward search string
  1077. = expression for "= |expr-register|
  1078. @ string for |input()|
  1079. `-` text for |:insert| or |:append|
  1080. vim:tw=78:ts=8:noet:ft=help:norl: