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