various.txt 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. *various.txt* For Vim version 9.0. Last change: 2022 Nov 04
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Various commands *various*
  4. 1. Various commands |various-cmds|
  5. 2. Using Vim like less or more |less|
  6. ==============================================================================
  7. 1. Various commands *various-cmds*
  8. *CTRL-L*
  9. CTRL-L Clear and redraw the screen. The redraw may happen
  10. later, after processing typeahead.
  11. *:redr* *:redraw*
  12. :redr[aw][!] Redraw the screen right now. When ! is included it is
  13. cleared first.
  14. Useful to update the screen halfway executing a script
  15. or function. Also when halfway a mapping and
  16. 'lazyredraw' is set.
  17. *:redraws* *:redrawstatus*
  18. :redraws[tatus][!] Redraw the status line of the current window. When !
  19. is included all status lines are redrawn.
  20. Useful to update the status line(s) when 'statusline'
  21. includes an item that doesn't cause automatic
  22. updating.
  23. If the command line is being edited the redraw is
  24. postponed until later.
  25. *:redrawt* *:redrawtabline*
  26. :redrawt[abline] Redraw the tabline. Useful to update the tabline when
  27. 'tabline' includes an item that doesn't trigger
  28. automatic updating.
  29. *N<Del>*
  30. <Del> When entering a number: Remove the last digit.
  31. Note: if you like to use <BS> for this, add this
  32. mapping to your .vimrc: >
  33. :map CTRL-V <BS> CTRL-V <Del>
  34. < See |:fixdel| if your <Del> key does not do what you
  35. want.
  36. :as[cii] or *ga* *:as* *:ascii*
  37. ga Print the ascii value of the character under the
  38. cursor in decimal, hexadecimal and octal.
  39. Mnemonic: Get Ascii value.
  40. For example, when the cursor is on a 'R':
  41. <R> 82, Hex 52, Octal 122 ~
  42. When the character is a non-standard ASCII character,
  43. but printable according to the 'isprint' option, the
  44. non-printable version is also given.
  45. When the character is larger than 127, the <M-x> form
  46. is also printed. For example:
  47. <~A> <M-^A> 129, Hex 81, Octal 201 ~
  48. <p> <|~> <M-~> 254, Hex fe, Octal 376 ~
  49. (where <p> is a special character)
  50. The <Nul> character in a file is stored internally as
  51. <NL>, but it will be shown as:
  52. <^@> 0, Hex 00, Octal 000 ~
  53. If the character has composing characters these are
  54. also shown. The value of 'maxcombine' doesn't matter.
  55. If the character can be inserted as a digraph, also
  56. output the two characters that can be used to create
  57. the character:
  58. <ö> 246, Hex 00f6, Oct 366, Digr o: ~
  59. This shows you can type CTRL-K o : to insert ö.
  60. *g8*
  61. g8 Print the hex values of the bytes used in the
  62. character under the cursor, assuming it is in |UTF-8|
  63. encoding. This also shows composing characters. The
  64. value of 'maxcombine' doesn't matter.
  65. Example of a character with two composing characters:
  66. e0 b8 81 + e0 b8 b9 + e0 b9 89 ~
  67. *8g8*
  68. 8g8 Find an illegal UTF-8 byte sequence at or after the
  69. cursor. This works in two situations:
  70. 1. when 'encoding' is any 8-bit encoding
  71. 2. when 'encoding' is "utf-8" and 'fileencoding' is
  72. any 8-bit encoding
  73. Thus it can be used when editing a file that was
  74. supposed to be UTF-8 but was read as if it is an 8-bit
  75. encoding because it contains illegal bytes.
  76. Does not wrap around the end of the file.
  77. Note that when the cursor is on an illegal byte or the
  78. cursor is halfway a multibyte character the command
  79. won't move the cursor.
  80. *:p* *:pr* *:print* *E749*
  81. :[range]p[rint] [flags]
  82. Print [range] lines (default current line).
  83. Note: If you are looking for a way to print your text
  84. on paper see |:hardcopy|. In the GUI you can use the
  85. File.Print menu entry.
  86. See |ex-flags| for [flags].
  87. The |:filter| command can be used to only show lines
  88. matching a pattern.
  89. :[range]p[rint] {count} [flags]
  90. Print {count} lines, starting with [range] (default
  91. current line |cmdline-ranges|).
  92. See |ex-flags| for [flags].
  93. *:P* *:Print*
  94. :[range]P[rint] [count] [flags]
  95. Just as ":print". Was apparently added to Vi for
  96. people that keep the shift key pressed too long...
  97. This command is not supported in |Vim9| script.
  98. Note: A user command can overrule this command.
  99. See |ex-flags| for [flags].
  100. *:l* *:list*
  101. :[range]l[ist] [count] [flags]
  102. Same as :print, but display unprintable characters
  103. with '^' and put $ after the line. This can be
  104. further changed with the 'listchars' option.
  105. See |ex-flags| for [flags].
  106. *:nu* *:number*
  107. :[range]nu[mber] [count] [flags]
  108. Same as :print, but precede each line with its line
  109. number. (See also 'highlight' and 'numberwidth'
  110. option).
  111. See |ex-flags| for [flags].
  112. *:#*
  113. :[range]# [count] [flags]
  114. synonym for :number.
  115. *:#!*
  116. :#!{anything} Ignored, so that you can start a Vim script with: >
  117. #!vim -S
  118. echo "this is a Vim script"
  119. quit
  120. <
  121. *:z* *E144*
  122. :[range]z[+-^.=][count] Display several lines of text surrounding the line
  123. specified with [range], or around the current line
  124. if there is no [range].
  125. If there is a [count], that's how many lines you'll
  126. see; if there is no [count] and only one window then
  127. twice the value of the 'scroll' option is used,
  128. otherwise the current window height minus 3 is used.
  129. This is the value of "scr" in the table below.
  130. If there is a [count] the 'window' option is set to
  131. its value.
  132. :z can be used either alone or followed by any of
  133. several marks. These have the following effect:
  134. mark first line last line new cursor line ~
  135. ---- ---------- --------- ------------
  136. + current line 1 scr forward 1 scr forward
  137. - 1 scr back current line current line
  138. ^ 2 scr back 1 scr back 1 scr back
  139. . 1/2 scr back 1/2 scr fwd 1/2 scr fwd
  140. = 1/2 scr back 1/2 scr fwd current line
  141. Specifying no mark at all is the same as "+".
  142. If the mark is "=", a line of dashes is printed
  143. around the current line.
  144. *:z!*
  145. :[range]z![+-^.=][count]
  146. Like ":z", but when [count] is not specified, it
  147. defaults to the Vim window height minus one.
  148. :[range]z[!]#[+-^.=][count] *:z#*
  149. Like ":z" or ":z!", but number the lines.
  150. *:=*
  151. := [flags] Print the last line number.
  152. See |ex-flags| for [flags].
  153. :{range}= [flags] Prints the last line number in {range}. For example,
  154. this prints the current line number: >
  155. :.=
  156. < See |ex-flags| for [flags].
  157. :norm[al][!] {commands} *:norm* *:normal*
  158. Execute Normal mode commands {commands}. This makes
  159. it possible to execute Normal mode commands typed on
  160. the command-line. {commands} are executed like they
  161. are typed. For undo all commands are undone together.
  162. Execution stops when an error is encountered.
  163. If the [!] is given, mappings will not be used.
  164. Without it, when this command is called from a
  165. non-remappable mapping (|:noremap|), the argument can
  166. be mapped anyway.
  167. {commands} should be a complete command. If
  168. {commands} does not finish a command, the last one
  169. will be aborted as if <Esc> or <C-C> was typed.
  170. This implies that an insert command must be completed
  171. (to start Insert mode, see |:startinsert|). A ":"
  172. command must be completed as well. And you can't use
  173. "Q" or "gQ" to start Ex mode.
  174. The display is not updated while ":normal" is busy.
  175. {commands} cannot start with a space. Put a count of
  176. 1 (one) before it, "1 " is one space.
  177. The 'insertmode' option is ignored for {commands}.
  178. This command cannot be followed by another command,
  179. since any '|' is considered part of the command.
  180. This command can be used recursively, but the depth is
  181. limited by 'maxmapdepth'.
  182. An alternative is to use |:execute|, which uses an
  183. expression as argument. This allows the use of
  184. printable characters to represent special characters.
  185. Example: >
  186. :exe "normal \<c-w>\<c-w>"
  187. :{range}norm[al][!] {commands} *:normal-range*
  188. Execute Normal mode commands {commands} for each line
  189. in the {range}. Before executing the {commands}, the
  190. cursor is positioned in the first column of the range,
  191. for each line. Otherwise it's the same as the
  192. ":normal" command without a range.
  193. *:sh* *:shell* *E371*
  194. :sh[ell] This command starts a shell. When the shell exits
  195. (after the "exit" command) you return to Vim. The
  196. name for the shell command comes from 'shell' option.
  197. *E360*
  198. Note: This doesn't work when Vim on the Amiga was
  199. started in QuickFix mode from a compiler, because the
  200. compiler will have set stdin to a non-interactive
  201. mode.
  202. *:!cmd* *:!*
  203. :!{cmd} Execute {cmd} with the shell. See also the 'shell'
  204. and 'shelltype' option.
  205. *E34*
  206. Any '!' in {cmd} is replaced with the previous
  207. external command (see also 'cpoptions'). But not when
  208. there is a backslash before the '!', then that
  209. backslash is removed. Example: ":!ls" followed by
  210. ":!echo ! \! \\!" executes "echo ls ! \!".
  211. A '|' in {cmd} is passed to the shell, you cannot use
  212. it to append a Vim command. See |:bar|.
  213. If {cmd} contains "%" it is expanded to the current
  214. file name, "#" is expanded to the alternate file name.
  215. Special characters in the file name are not escaped,
  216. use quotes to avoid their special meaning: >
  217. :!ls "%"
  218. < If the file name contains a "$" then single quotes
  219. might work better, but this only works if the file
  220. name does not contain a single quote: >
  221. :!ls '%'
  222. < This should always work, but it's more typing: >
  223. :exe "!ls " .. shellescape(expand("%"))
  224. < To get a literal "%" or "#" prepend it with a
  225. backslash. For example, to list all files starting
  226. with "%": >
  227. :!ls \%*
  228. <
  229. A newline character ends {cmd}, what follows is
  230. interpreted as a following ":" command. However, if
  231. there is a backslash before the newline it is removed
  232. and {cmd} continues. It doesn't matter how many
  233. backslashes are before the newline, only one is
  234. removed.
  235. On Unix the command normally runs in a non-interactive
  236. shell. If you want an interactive shell to be used
  237. (to use aliases) set 'shellcmdflag' to "-ic".
  238. For Win32 also see |:!start|.
  239. After the command has been executed, the timestamp and
  240. size of the current file is checked |timestamp|.
  241. Vim redraws the screen after the command is finished,
  242. because it may have printed any text. This requires a
  243. hit-enter prompt, so that you can read any messages.
  244. To avoid this use: >
  245. :silent !{cmd}
  246. < The screen is not redrawn then, thus you have to use
  247. CTRL-L or ":redraw!" if the command did display
  248. something. However, this depends on what the |t_ti|
  249. and |t_te| termcap entries are set to.
  250. Also see |shell-window|.
  251. *:!!*
  252. :!! Repeat last ":!{cmd}".
  253. *:ve* *:ver* *:version*
  254. :ve[rsion] Print the version number of the editor. If the
  255. compiler used understands "__DATE__" the compilation
  256. date is mentioned. Otherwise a fixed release-date is
  257. shown.
  258. The following lines contain information about which
  259. features were enabled when Vim was compiled. When
  260. there is a preceding '+', the feature is included,
  261. when there is a '-' it is excluded. To change this,
  262. you have to edit feature.h and recompile Vim.
  263. To check for this in an expression, see |has()|.
  264. Here is an overview of the features.
  265. The first column shows the smallest version in which
  266. they are included:
  267. T tiny (always)
  268. S small
  269. N normal
  270. B big
  271. H huge
  272. m manually enabled or depends on other features
  273. - never, feature was removed
  274. (none) system dependent
  275. Thus if a feature is marked with "N", it is included
  276. in the normal, big and huge versions of Vim.
  277. *+feature-list*
  278. *+acl* |ACL| support included
  279. *+ARP* Amiga only: ARP support included
  280. H *+arabic* |Arabic| language support
  281. N *+autochdir* support 'autochdir' option
  282. T *+autocmd* |:autocmd|, automatic commands. Always enabled since
  283. 8.0.1564
  284. H *+autoservername* Automatically enable |clientserver|
  285. m *+balloon_eval* |balloon-eval| support in the GUI. Included when
  286. compiling with supported GUI (Motif, GTK, GUI) and
  287. either Netbeans/Sun Workshop integration or |+eval|
  288. feature.
  289. H *+balloon_eval_term* |balloon-eval| support in the terminal,
  290. 'balloonevalterm'
  291. N *+browse* |:browse| command
  292. T *++builtin_terms* maximal terminals builtin |builtin-terms| Always
  293. enabled since 9.0.0280
  294. N *+byte_offset* support for 'o' flag in 'statusline' option, "go"
  295. and ":goto" commands.
  296. m *+channel* inter process communication |channel|
  297. T *+cindent* |'cindent'|, C indenting; Always enabled
  298. N *+clientserver* Unix and Win32: Remote invocation |clientserver|
  299. *+clipboard* |clipboard| support compiled-in
  300. *+clipboard_working* |clipboard| support compiled-in and working
  301. T *+cmdline_compl* command line completion |cmdline-completion|
  302. T *+cmdline_hist* command line history |cmdline-history|
  303. T *+cmdline_info* |'showcmd'| and |'ruler'|; Always enabled since
  304. 9.0.0747
  305. T *+cmdwin* |cmdline-window| support; Always enabled since 9.0.0657
  306. T *+comments* |'comments'| support
  307. N *+conceal* "conceal" support, see |conceal| |:syn-conceal| etc.
  308. N *+cryptv* encryption support |encryption|
  309. H *+cscope* |cscope| support
  310. T *+cursorbind* |'cursorbind'| support
  311. m *+cursorshape* |termcap-cursor-shape| support
  312. m *+debug* Compiled for debugging.
  313. N *+dialog_gui* Support for |:confirm| with GUI dialog.
  314. N *+dialog_con* Support for |:confirm| with console dialog.
  315. N *+dialog_con_gui* Support for |:confirm| with GUI and console dialog.
  316. N *+diff* |vimdiff| and 'diff'
  317. N *+digraphs* |digraphs| *E196*
  318. *+directx* Win32 GUI only: DirectX and |'renderoptions'|
  319. *+dnd* Support for DnD into the "~ register |quote_~|.
  320. H *+emacs_tags* |emacs-tags| files
  321. N *+eval* expression evaluation |eval.txt|
  322. T *+ex_extra* always on now, used to be for Vim's extra Ex commands
  323. N *+extra_search* |'hlsearch'| and |'incsearch'| options.
  324. - *+farsi* Removed: |farsi| language
  325. T *+file_in_path* |gf|, |CTRL-W_f| and |<cfile>| Always enabled since
  326. 9.0.265
  327. N *+find_in_path* include file searches: |[I|, |:isearch|,
  328. |CTRL-W_CTRL-I|, |:checkpath|, etc.
  329. N *+folding* |folding|
  330. *+footer* |gui-footer|
  331. *+fork* Unix only: |fork| shell commands
  332. T *+float* Floating point support Always enabled since 9.0.0491
  333. N *+gettext* message translations |multi-lang|
  334. - *+GUI_Athena* Unix only: Athena |GUI|
  335. *+GUI_neXtaw* Unix only: neXtaw |GUI|
  336. *+GUI_GTK* Unix only: GTK+ |GUI|
  337. *+GUI_Motif* Unix only: Motif |GUI|
  338. *+GUI_Photon* QNX only: Photon |GUI|
  339. m *+hangul_input* Hangul input support |hangul|
  340. *+iconv* Compiled with the |iconv()| function
  341. *+iconv/dyn* Likewise |iconv-dynamic| |/dyn|
  342. T *+insert_expand* |insert_expand| Insert mode completion
  343. m *+ipv6* Support for IPv6 networking |channel|
  344. m *+job* starting and stopping jobs |job|
  345. T *+jumplist* |jumplist|; Always enabled since 8.2.3795
  346. H *+keymap* |'keymap'|
  347. N *+lambda* |lambda| and |closure|
  348. H *+langmap* |'langmap'|
  349. N *+libcall* |libcall()|
  350. N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'|
  351. T *+lispindent* |'lisp'|
  352. T *+listcmds* Vim commands for the list of buffers |buffer-hidden|
  353. and argument list |:argdelete|
  354. T *+localmap* Support for mappings local to a buffer |:map-local|
  355. m *+lua* |Lua| interface
  356. m *+lua/dyn* |Lua| interface |/dyn|
  357. N *+menu* |:menu|
  358. N *+mksession* |:mksession|
  359. T *+modify_fname* |filename-modifiers|
  360. T *+mouse* Mouse handling |mouse-using|
  361. N *+mouseshape* |'mouseshape'|
  362. N *+mouse_dec* Unix only: Dec terminal mouse handling |dec-mouse|
  363. N *+mouse_gpm* Unix only: Linux console mouse handling |gpm-mouse|
  364. m *+mouse_gpm/dyn* Same as |+mouse_gpm| with optional library dependency
  365. |/dyn|
  366. N *+mouse_jsbterm* JSB mouse handling |jsbterm-mouse|
  367. N *+mouse_netterm* Unix only: netterm mouse handling |netterm-mouse|
  368. N *+mouse_pterm* QNX only: pterm mouse handling |qnx-terminal|
  369. N *+mouse_sysmouse* Unix only: *BSD console mouse handling |sysmouse|
  370. N *+mouse_sgr* Unix only: sgr mouse handling |sgr-mouse|
  371. N *+mouse_urxvt* Unix only: urxvt mouse handling |urxvt-mouse|
  372. N *+mouse_xterm* Unix only: xterm mouse handling |xterm-mouse|
  373. T *+multi_byte* Unicode support, 16 and 32 bit characters |multibyte|
  374. *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
  375. N *+multi_lang* non-English language support |multi-lang|
  376. m *+mzscheme* Mzscheme interface |mzscheme|
  377. m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn|
  378. m *+netbeans_intg* |netbeans|
  379. T *+num64* 64-bit Number support |Number|
  380. Always enabled since 8.2.0271, use v:numbersize to
  381. check the actual size of a Number.
  382. m *+ole* Win32 GUI only: |ole-interface|
  383. N *+packages* Loading |packages|
  384. T *+path_extra* Up/downwards search in 'path' and 'tags' Always
  385. enabled since 9.0.0270
  386. m *+perl* Perl interface |perl|
  387. m *+perl/dyn* Perl interface |perl-dynamic| |/dyn|
  388. N *+persistent_undo* Persistent undo |undo-persistence|
  389. N *+popupwin* Popup windows |popup-window|
  390. *+postscript* |:hardcopy| writes a PostScript file
  391. N *+printer* |:hardcopy| command
  392. H *+profile* |:profile| command
  393. m *+python* Python 2 interface |python|
  394. m *+python/dyn* Python 2 interface |python-dynamic| |/dyn|
  395. m *+python3* Python 3 interface |python|
  396. m *+python3/dyn* Python 3 interface |python-dynamic| |/dyn|
  397. N *+quickfix* |:make| and |quickfix| commands
  398. N *+reltime* |reltime()| function, 'hlsearch'/'incsearch' timeout,
  399. 'redrawtime' option
  400. H *+rightleft* Right to left typing |'rightleft'|
  401. m *+ruby* Ruby interface |ruby|
  402. m *+ruby/dyn* Ruby interface |ruby-dynamic| |/dyn|
  403. T *+scrollbind* |'scrollbind'|
  404. N *+signs* |:sign|
  405. T *+smartindent* |'smartindent'|
  406. H *+sodium* compiled with libsodium for better encryption support
  407. H *+sound* |sound_playevent()|, |sound_playfile()| functions, etc.
  408. N *+spell* spell checking support, see |spell|
  409. N *+startuptime* |--startuptime| argument
  410. N *+statusline* Options 'statusline', 'rulerformat' and special
  411. formats of 'titlestring' and 'iconstring'
  412. - *+sun_workshop* Removed: |workshop|
  413. N *+syntax* Syntax highlighting |syntax|
  414. *+system()* Unix only: opposite of |+fork|
  415. T *+tag_binary* binary searching in tags file |tag-binary-search|
  416. - *+tag_old_static* Removed; method for static tags |tag-old-static|
  417. - *+tag_any_white* Removed; was to allow any white space in tags files
  418. m *+tcl* Tcl interface |tcl|
  419. m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
  420. m *+terminal* Support for terminal window |terminal|
  421. *+terminfo* uses |terminfo| instead of termcap
  422. N *+termresponse* support for |t_RV| and |v:termresponse|
  423. N *+termguicolors* 24-bit color in xterm-compatible terminals support
  424. T *+textobjects* |text-objects| selection. Always enabled since 9.0.0222.
  425. N *+textprop* |text-properties|
  426. *+tgetent* non-Unix only: able to use external termcap
  427. N *+timers* the |timer_start()| function
  428. T *+title* Setting the window 'title' and 'icon'; Always enabled
  429. N *+toolbar* |gui-toolbar|
  430. T *+user_commands* User-defined commands. |user-commands|
  431. Always enabled since 8.1.1210.
  432. H *+vartabs* Variable-width tabstops. |'vartabstop'|
  433. T *+vertsplit* Vertically split windows |:vsplit|; Always enabled
  434. since 8.0.1118.
  435. T *+vim9script* |Vim9| script
  436. N *+viminfo* |'viminfo'|
  437. T *+virtualedit* |'virtualedit'| Always enabled since 8.1.826.
  438. T *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200.
  439. T *+visualextra* extra Visual mode commands |blockwise-operators|
  440. T *+vreplace* |gR| and |gr|
  441. *+vtp* on MS-Windows console: support for 'termguicolors'
  442. T *+wildignore* |'wildignore'| Always enabled since 9.0.0278
  443. T *+wildmenu* |'wildmenu'|| Always enabled since 9.0.0279
  444. T *+windows* more than one window; Always enabled since 8.0.1118.
  445. m *+writebackup* |'writebackup'| is default on
  446. m *+xim* X input method |xim|
  447. *+xfontset* X fontset support |xfontset|
  448. *+xpm* pixmap support
  449. m *+xpm_w32* Win32 GUI only: pixmap support |w32-xpm-support|
  450. *+xsmp* XSMP (X session management) support
  451. *+xsmp_interact* interactive XSMP (X session management) support
  452. N *+xterm_clipboard* Unix only: xterm clipboard handling
  453. m *+xterm_save* save and restore xterm screen |xterm-screens|
  454. N *+X11* Unix only: can restore window title |X11|
  455. */dyn* *E370* *E448*
  456. To some of the features "/dyn" is added when the
  457. feature is only available when the related library can
  458. be dynamically loaded.
  459. :ve[rsion] {nr} Is now ignored. This was previously used to check the
  460. version number of a .vimrc file. It was removed,
  461. because you can now use the ":if" command for
  462. version-dependent behavior.
  463. *:redi* *:redir*
  464. :redi[r][!] > {file} Redirect messages to file {file}. The messages which
  465. are the output of commands are written to that file,
  466. until redirection ends. The messages are also still
  467. shown on the screen. When [!] is included, an
  468. existing file is overwritten. When [!] is omitted,
  469. and {file} exists, this command fails.
  470. Only one ":redir" can be active at a time. Calls to
  471. ":redir" will close any active redirection before
  472. starting redirection to the new target. For recursive
  473. use check out |execute()|.
  474. To stop the messages and commands from being echoed to
  475. the screen, put the commands in a function and call it
  476. with ":silent call Function()".
  477. An alternative is to use the 'verbosefile' option,
  478. this can be used in combination with ":redir".
  479. :redi[r] >> {file} Redirect messages to file {file}. Append if {file}
  480. already exists.
  481. :redi[r] @{a-zA-Z}
  482. :redi[r] @{a-zA-Z}> Redirect messages to register {a-z}. Append to the
  483. contents of the register if its name is given
  484. uppercase {A-Z}. The ">" after the register name is
  485. optional.
  486. :redi[r] @{a-z}>> Append messages to register {a-z}.
  487. :redi[r] @*>
  488. :redi[r] @+> Redirect messages to the selection or clipboard. For
  489. backward compatibility, the ">" after the register
  490. name can be omitted. See |quotestar| and |quoteplus|.
  491. :redi[r] @*>>
  492. :redi[r] @+>> Append messages to the selection or clipboard.
  493. :redi[r] @"> Redirect messages to the unnamed register. For
  494. backward compatibility, the ">" after the register
  495. name can be omitted.
  496. :redi[r] @">> Append messages to the unnamed register.
  497. *E1092*
  498. :redi[r] => {var} Redirect messages to a variable.
  499. In legacy script: If the variable doesn't exist, then
  500. it is created. If the variable exists, then it is
  501. initialized to an empty string. After the redirection
  502. starts, if the variable is removed or locked or the
  503. variable type is changed, then further command output
  504. messages will cause errors. When using a local
  505. variable (l:var in a function or s:var in a script)
  506. and another `:redir` causes the current one to end,
  507. the scope might be different and the assignment fails.
  508. In Vim9 script: the variable must have been declared
  509. as a string.
  510. The variable will remain empty until redirection ends.
  511. Only string variables can be used.
  512. To get the output of one command the |execute()|
  513. function can be used instead of redirection.
  514. :redi[r] =>> {var} Append messages to an existing variable. Only string
  515. variables can be used.
  516. *E1185*
  517. :redi[r] END End redirecting messages.
  518. *:filt* *:filter*
  519. :filt[er][!] {pattern} {command}
  520. :filt[er][!] /{pattern}/ {command}
  521. Restrict the output of {command} to lines matching
  522. with {pattern}. For example, to list only xml files: >
  523. :filter /\.xml$/ oldfiles
  524. < If the [!] is given, restrict the output of {command}
  525. to lines that do NOT match {pattern}.
  526. {pattern} is a Vim search pattern. Instead of enclosing
  527. it in / any non-ID character (see |'isident'|) can be
  528. used, so long as it does not appear in {pattern}.
  529. Without the enclosing character the pattern cannot
  530. include the bar character. 'ignorecase' is not used.
  531. The pattern is matched against the relevant part of
  532. the output, not necessarily the whole line. Only some
  533. commands support filtering, try it out to check if it
  534. works. Some of the commands that support filtering:
  535. |:#| - filter whole line
  536. |:clist| - filter by file name or module name
  537. |:command| - filter by command name
  538. |:files| - filter by file name
  539. |:highlight| - filter by highlight group
  540. |:jumps| - filter by file name
  541. |:let| - filter by variable name
  542. |:list| - filter whole line
  543. |:llist| - filter by file name or module name
  544. |:marks| - filter by text in the current file,
  545. or file name for other files
  546. |:oldfiles| - filter by file name
  547. |:registers| - filter by register contents
  548. (does not work multi-line)
  549. |:set| - filter by option name
  550. Only normal messages are filtered, error messages are
  551. not.
  552. *:sil* *:silent* *:silent!*
  553. :sil[ent][!] {command} Execute {command} silently. Normal messages will not
  554. be given or added to the message history.
  555. When [!] is added, error messages will also be
  556. skipped, and commands and mappings will not be aborted
  557. when an error is detected. |v:errmsg| is still set.
  558. When [!] is not used, an error message will cause
  559. further messages to be displayed normally.
  560. Redirection, started with |:redir|, will continue as
  561. usual, although there might be small differences.
  562. This will allow redirecting the output of a command
  563. without seeing it on the screen. Example: >
  564. :redir >/tmp/foobar
  565. :silent g/Aap/p
  566. :redir END
  567. < To execute a Normal mode command silently, use the
  568. |:normal| command. For example, to search for a
  569. string without messages: >
  570. :silent exe "normal /path\<CR>"
  571. < ":silent!" is useful to execute a command that may
  572. fail, but the failure is to be ignored. Example: >
  573. :let v:errmsg = ""
  574. :silent! /^begin
  575. :if v:errmsg != ""
  576. : ... pattern was not found
  577. < ":silent" will also avoid the hit-enter prompt. When
  578. using this for an external command, this may cause the
  579. screen to be messed up. Use |CTRL-L| to clean it up
  580. then.
  581. ":silent menu ..." defines a menu that will not echo a
  582. Command-line command. The command will still produce
  583. messages though. Use ":silent" in the command itself
  584. to avoid that: ":silent menu .... :silent command".
  585. *:uns* *:unsilent*
  586. :uns[ilent] {command} Execute {command} not silently. Only makes a
  587. difference when |:silent| was used to get to this
  588. command.
  589. Use this for giving a message even when |:silent| was
  590. used. In this example |:silent| is used to avoid the
  591. message about reading the file and |:unsilent| to be
  592. able to list the first line of each file. >
  593. :silent argdo unsilent echo expand('%') .. ": " .. getline(1)
  594. <
  595. *:verb* *:verbose*
  596. :[count]verb[ose] {command}
  597. Execute {command} with 'verbose' set to [count]. If
  598. [count] is omitted one is used. ":0verbose" can be
  599. used to set 'verbose' to zero.
  600. The additional use of ":silent" makes messages
  601. generated but not displayed.
  602. The combination of ":silent" and ":verbose" can be
  603. used to generate messages and check them with
  604. |v:statusmsg| and friends. For example: >
  605. :let v:statusmsg = ""
  606. :silent verbose runtime foobar.vim
  607. :if v:statusmsg != ""
  608. : " foobar.vim could not be found
  609. :endif
  610. < When concatenating another command, the ":verbose"
  611. only applies to the first one: >
  612. :4verbose set verbose | set verbose
  613. < verbose=4 ~
  614. verbose=0 ~
  615. For logging verbose messages in a file use the
  616. 'verbosefile' option.
  617. *:verbose-cmd*
  618. When 'verbose' is non-zero, listing the value of a Vim option or a key map or
  619. an abbreviation or a user-defined function or a command or a highlight group
  620. or an autocommand will also display where it was last defined. If it was
  621. defined manually then there will be no "Last set" message. When it was
  622. defined while executing a function, user command or autocommand, the script in
  623. which it was defined is reported.
  624. {not available when compiled without the |+eval| feature}
  625. *K*
  626. K Run a program to lookup the keyword under the
  627. cursor. The name of the program is given with the
  628. 'keywordprg' (kp) option (default is "man"). The
  629. keyword is formed of letters, numbers and the
  630. characters in 'iskeyword'. The keyword under or
  631. right of the cursor is used. The same can be done
  632. with the command >
  633. :!{program} {keyword}
  634. < There is an example of a program to use in the tools
  635. directory of Vim. It is called "ref" and does a
  636. simple spelling check.
  637. Special cases:
  638. - If 'keywordprg' begins with ":" it is invoked as
  639. a Vim Ex command with [count].
  640. - If 'keywordprg' is empty, the ":help" command is
  641. used. It's a good idea to include more characters
  642. in 'iskeyword' then, to be able to find more help.
  643. - When 'keywordprg' is equal to "man" or starts with
  644. ":", a [count] before "K" is inserted after
  645. keywordprg and before the keyword. For example,
  646. using "2K" while the cursor is on "mkdir", results
  647. in: >
  648. !man 2 mkdir
  649. < - When 'keywordprg' is equal to "man -s", a count
  650. before "K" is inserted after the "-s". If there is
  651. no count, the "-s" is removed.
  652. *v_K*
  653. {Visual}K Like "K", but use the visually highlighted text for
  654. the keyword. Only works when the highlighted text is
  655. not more than one line.
  656. [N]gs *gs* *:sl* *:sleep*
  657. :[N]sl[eep] [N][m] Do nothing for [N] seconds. When [m] is included,
  658. sleep for [N] milliseconds. The count for "gs" always
  659. uses seconds. The default is one second. >
  660. :sleep "sleep for one second
  661. :5sleep "sleep for five seconds
  662. :sleep 100m "sleep for 100 milliseconds
  663. 10gs "sleep for ten seconds
  664. < Can be interrupted with CTRL-C (CTRL-Break on
  665. MS-Windows). "gs" stands for "goto sleep".
  666. While sleeping the cursor is positioned in the text,
  667. if at a visible position.
  668. Also process the received netbeans messages. {only
  669. available when compiled with the |+netbeans_intg|
  670. feature}
  671. *:sl!* *:sleep!*
  672. :[N]sl[eep]! [N][m] Same as above, but hide the cursor.
  673. *:xrestore* *:xr*
  674. :xr[estore] [display] Reinitializes the connection to the X11 server. Useful
  675. after the X server restarts, e.g. when running Vim for
  676. long time inside screen/tmux and connecting from
  677. different machines.
  678. [display] should be in the format of the $DISPLAY
  679. environment variable (e.g. "localhost:10.0")
  680. If [display] is omitted, then it reinitializes the
  681. connection to the X11 server using the same value as
  682. was used for the previous execution of this command.
  683. If the value was never specified, then it uses the
  684. value of $DISPLAY environment variable as it was when
  685. Vim was started.
  686. {only available when compiled with the |+clipboard|
  687. feature}
  688. *g_CTRL-A*
  689. g CTRL-A Only when Vim was compiled with MEM_PROFILING defined
  690. (which is very rare): print memory usage statistics.
  691. Only useful for debugging Vim.
  692. For incrementing in Visual mode see |v_g_CTRL-A|.
  693. ==============================================================================
  694. 2. Using Vim like less or more *less*
  695. If you use the less or more program to view a file, you don't get syntax
  696. highlighting. Thus you would like to use Vim instead. You can do this by
  697. using the shell script "$VIMRUNTIME/macros/less.sh".
  698. This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
  699. up mappings to simulate the commands that less supports. Otherwise, you can
  700. still use the Vim commands.
  701. This isn't perfect. For example, when viewing a short file Vim will still use
  702. the whole screen. But it works well enough for most uses, and you get syntax
  703. highlighting.
  704. The "h" key will give you a short overview of the available commands.
  705. If you want to set options differently when using less, define the
  706. LessInitFunc in your vimrc, for example: >
  707. func LessInitFunc()
  708. set nocursorcolumn nocursorline
  709. endfunc
  710. <
  711. vim:tw=78:ts=8:noet:ft=help:norl: