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