cmdline.txt 45 KB

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