cmdline.txt 45 KB

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