blob: ffb9f2682ba2fdc9e7d5d004038f6b6329786113 [file] [log] [blame]
Bram Moolenaared39e1d2008-08-09 17:55:22 +00001*various.txt* For Vim version 7.2. Last change: 2008 Aug 06
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Various commands *various*
8
91. Various commands |various-cmds|
102. Online help |online-help|
Bram Moolenaar8299df92004-07-10 09:47:34 +0000113. Using Vim like less or more |less|
Bram Moolenaar071d4272004-06-13 20:20:40 +000012
13==============================================================================
141. Various commands *various-cmds*
15
16 *CTRL-L*
Bram Moolenaar30abd282005-06-22 22:35:10 +000017CTRL-L Clear and redraw the screen. The redraw may happen
18 later, after processing typeahead.
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
20 *:redr* *:redraw*
21:redr[aw][!] Redraw the screen right now. When ! is included it is
22 cleared first.
23 Useful to update the screen halfway executing a script
24 or function. Also when halfway a mapping and
25 'lazyredraw' is set.
26
27 *:redraws* *:redrawstatus*
28:redraws[tatus][!] Redraw the status line of the current window. When !
29 is included all status lines are redrawn.
30 Useful to update the status line(s) when 'statusline'
31 includes an item that doesn't cause automatic
32 updating.
33
34 *N<Del>*
35<Del> When entering a number: Remove the last digit.
36 Note: if you like to use <BS> for this, add this
37 mapping to your .vimrc: >
38 :map CTRL-V <BS> CTRL-V <Del>
39< See |:fixdel| if your <Del> key does not do what you
40 want.
41
42:as[cii] or *ga* *:as* *:ascii*
43ga Print the ascii value of the character under the
44 cursor in decimal, hexadecimal and octal. For
45 example, when the cursor is on a 'R':
46 <R> 82, Hex 52, Octal 122 ~
47 When the character is a non-standard ASCII character,
48 but printable according to the 'isprint' option, the
49 non-printable version is also given. When the
50 character is larger than 127, the <M-x> form is also
51 printed. For example:
52 <~A> <M-^A> 129, Hex 81, Octal 201 ~
53 <p> <|~> <M-~> 254, Hex fe, Octal 376 ~
54 (where <p> is a special character)
55 The <Nul> character in a file is stored internally as
56 <NL>, but it will be shown as:
57 <^@> 0, Hex 00, Octal 000 ~
Bram Moolenaar362e1a32006-03-06 23:29:24 +000058 If the character has composing characters these are
59 also shown. The value of 'maxcombine' doesn't matter.
Bram Moolenaar071d4272004-06-13 20:20:40 +000060 Mnemonic: Get Ascii value. {not in Vi}
61
62 *g8*
63g8 Print the hex values of the bytes used in the
64 character under the cursor, assuming it is in |UTF-8|
Bram Moolenaar362e1a32006-03-06 23:29:24 +000065 encoding. This also shows composing characters. The
66 value of 'maxcombine' doesn't matter.
67 Example of a character with two composing characters:
Bram Moolenaar071d4272004-06-13 20:20:40 +000068 e0 b8 81 + e0 b8 b9 + e0 b9 89 ~
Bram Moolenaarca003e12006-03-17 23:19:38 +000069 {not in Vi} {only when compiled with the |+multi_byte|
70 feature}
71
72 *8g8*
738g8 Find an illegal UTF-8 byte sequence at or after the
74 cursor. This works in two situations:
75 1. when 'encoding' is any 8-bit encoding
76 2. when 'encoding' is "utf-8" and 'fileencoding' is
77 any 8-bit encoding
78 Thus it can be used when editing a file that was
79 supposed to be UTF-8 but was read as if it is an 8-bit
80 encoding because it contains illegal bytes.
81 Does not wrap around the end of the file.
82 Note that when the cursor is on an illegal byte or the
83 cursor is halfway a multi-byte character the command
84 won't move the cursor.
85 {not in Vi} {only when compiled with the |+multi_byte|
86 feature}
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
Bram Moolenaar551dbcc2006-04-25 22:13:59 +000088 *:p* *:pr* *:print* *E749*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000089:[range]p[rint] [flags]
90 Print [range] lines (default current line).
Bram Moolenaar071d4272004-06-13 20:20:40 +000091 Note: If you are looking for a way to print your text
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000092 on paper see |:hardcopy|. In the GUI you can use the
93 File.Print menu entry.
94 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +000095
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000096:[range]p[rint] {count} [flags]
Bram Moolenaar071d4272004-06-13 20:20:40 +000097 Print {count} lines, starting with [range] (default
98 current line |cmdline-ranges|).
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000099 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
101 *:P* *:Print*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000102:[range]P[rint] [count] [flags]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103 Just as ":print". Was apparently added to Vi for
104 people that keep the shift key pressed too long...
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000105 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107 *:l* *:list*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000108:[range]l[ist] [count] [flags]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109 Same as :print, but display unprintable characters
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000110 with '^' and put $ after the line.
111 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112
113 *:nu* *:number*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000114:[range]nu[mber] [count] [flags]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115 Same as :print, but precede each line with its line
Bram Moolenaarfaa959a2006-02-20 21:37:40 +0000116 number. (See also 'highlight' and 'numberwidth'
117 option).
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000118 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119
120 *:#*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000121:[range]# [count] [flags]
122 synonym for :number.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000124 *:#!*
125:#!{anything} Ignored, so that you can start a Vim script with: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000126 #!vim -S
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000127 echo "this is a Vim script"
128 quit
129<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130 *:z* *E144*
131:{range}z[+-^.=]{count} Display several lines of text surrounding the line
132 specified with {range}, or around the current line
133 if there is no {range}. If there is a {count}, that's
Bram Moolenaar4399ef42005-02-12 14:29:27 +0000134 how many lines you'll see; if there is only one window
135 then the 'window' option is used, otherwise the
136 current window size is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
138 :z can be used either alone or followed by any of
139 several punctuation marks. These have the following
140 effect:
141
142 mark first line last line new location ~
143 ---- ---------- --------- ------------
144 + current line 1 scr forward 1 scr forward
145 - 1 scr back current line current line
146 ^ 2 scr back 1 scr back 1 scr back
Bram Moolenaar2a8d1f82005-02-05 21:43:56 +0000147 . 1/2 scr back 1/2 scr fwd 1/2 scr fwd
148 = 1/2 scr back 1/2 scr fwd current line
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149
150 Specifying no mark at all is the same as "+".
151 If the mark is "=", a line of dashes is printed
152 around the current line.
153
154:{range}z#[+-^.=]{count} *:z#*
155 Like ":z", but number the lines.
156 {not in all versions of Vi, not with these arguments}
157
158 *:=*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000159:= [flags] Print the last line number.
160 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000161
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000162:{range}= [flags] Prints the last line number in {range}. For example,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163 this prints the current line number: >
164 :.=
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000165< See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166
167:norm[al][!] {commands} *:norm* *:normal*
168 Execute Normal mode commands {commands}. This makes
169 it possible to execute Normal mode commands typed on
170 the command-line. {commands} is executed like it is
171 typed. For undo all commands are undone together.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000172 Execution stops when an error is encountered.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000173 If the [!] is given, mappings will not be used.
174 {commands} should be a complete command. If
175 {commands} does not finish a command, the last one
176 will be aborted as if <Esc> or <C-C> was typed.
177 The display isn't updated while ":normal" is busy.
178 This implies that an insert command must be completed
179 (to start Insert mode, see |:startinsert|). A ":"
Bram Moolenaar7c626922005-02-07 22:01:03 +0000180 command must be completed as well. And you can't use
181 "Q" or "gQ" to start Ex mode.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000182 {commands} cannot start with a space. Put a 1 (one)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000183 before it, 1 space is one space.
184 The 'insertmode' option is ignored for {commands}.
185 This command cannot be followed by another command,
186 since any '|' is considered part of the command.
187 This command can be used recursively, but the depth is
188 limited by 'maxmapdepth'.
189 When this command is called from a non-remappable
190 mapping |:noremap|, the argument can be mapped anyway.
191 An alternative is to use |:execute|, which uses an
192 expression as argument. This allows the use of
193 printable characters. Example: >
194 :exe "normal \<c-w>\<c-w>"
195< {not in Vi, of course}
196 {not available when the |+ex_extra| feature was
197 disabled at compile time}
198
199:{range}norm[al][!] {commands} *:normal-range*
200 Execute Normal mode commands {commands} for each line
201 in the {range}. Before executing the {commands}, the
202 cursor is positioned in the first column of the range,
203 for each line. Otherwise it's the same as the
204 ":normal" command without a range.
205 {not in Vi}
206 Not available when |+ex_extra| feature was disabled at
207 compile time.
208
209 *:sh* *:shell* *E371*
210:sh[ell] This command starts a shell. When the shell exits
211 (after the "exit" command) you return to Vim. The
212 name for the shell command comes from 'shell' option.
213 *E360*
214 Note: This doesn't work when Vim on the Amiga was
215 started in QuickFix mode from a compiler, because the
216 compiler will have set stdin to a non-interactive
217 mode.
218
219 *:!cmd* *:!* *E34*
220:!{cmd} Execute {cmd} with the shell. See also the 'shell'
221 and 'shelltype' option.
222 Any '!' in {cmd} is replaced with the previous
223 external command (see also 'cpoptions'). But not when
224 there is a backslash before the '!', then that
225 backslash is removed. Example: ":!ls" followed by
226 ":!echo ! \! \\!" executes "echo ls ! \!".
227 After the command has been executed, the timestamp of
228 the current file is checked |timestamp|.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000229 A '|' in {cmd} is passed to the shell, you cannot use
230 it to append a Vim command. See |:bar|.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000231 A newline character ends {cmd}, what follows is
232 interpreted as a following ":" command. However, if
233 there is a backslash before the newline it is removed
234 and {cmd} continues. It doesn't matter how many
235 backslashes are before the newline, only one is
236 removed.
237 On Unix the command normally runs in a non-interactive
238 shell. If you want an interactive shell to be used
239 (to use aliases) set 'shellcmdflag' to "-ic".
240 For Win32 also see |:!start|.
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.
249 Also see |shell-window|.
250
251 *:!!*
252:!! Repeat last ":!{cmd}".
253
254 *:ve* *:version*
255:ve[rsion] Print the version number of the editor. If the
256 compiler used understands "__DATE__" the compilation
257 date is mentioned. Otherwise a fixed release-date is
258 shown.
259 The following lines contain information about which
260 features were enabled when Vim was compiled. When
261 there is a preceding '+', the feature is included,
262 when there is a '-' it is excluded. To change this,
263 you have to edit feature.h and recompile Vim.
264 To check for this in an expression, see |has()|.
265 Here is an overview of the features.
266 The first column shows the smallest version in which
267 they are included:
268 T tiny
269 S small
270 N normal
271 B big
272 H huge
273 m manually enabled or depends on other features
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
278 *+feature-list*
279 *+ARP* Amiga only: ARP support included
280B *+arabic* |Arabic| language support
281N *+autocmd* |:autocmd|, automatic commands
Bram Moolenaar4d34b432005-03-07 23:22:00 +0000282m *+balloon_eval* |balloon-eval| support. Included when compiling with
283 supported GUI (Motif, GTK, GUI) and either
284 Netbeans/Sun Workshop integration or |+eval| feature.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285N *+browse* |:browse| command
286N *+builtin_terms* some terminals builtin |builtin-terms|
287B *++builtin_terms* maximal terminals builtin |builtin-terms|
288N *+byte_offset* support for 'o' flag in 'statusline' option, "go"
289 and ":goto" commands.
290N *+cindent* |'cindent'|, C indenting
291N *+clientserver* Unix and Win32: Remote invocation |clientserver|
292 *+clipboard* |clipboard| support
293N *+cmdline_compl* command line completion |cmdline-completion|
294N *+cmdline_hist* command line history |cmdline-history|
295N *+cmdline_info* |'showcmd'| and |'ruler'|
296N *+comments* |'comments'| support
297N *+cryptv* encryption support |encryption|
298B *+cscope* |cscope| support
Bram Moolenaarac6e65f2005-08-29 22:25:38 +0000299m *+cursorshape* |termcap-cursor-shape| support
300m *+debug* Compiled for debugging.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301N *+dialog_gui* Support for |:confirm| with GUI dialog.
302N *+dialog_con* Support for |:confirm| with console dialog.
303N *+dialog_con_gui* Support for |:confirm| with GUI and console dialog.
304N *+diff* |vimdiff| and 'diff'
305N *+digraphs* |digraphs| *E196*
306 *+dnd* Support for DnD into the "~ register |quote_~|.
307B *+emacs_tags* |emacs-tags| files
308N *+eval* expression evaluation |eval.txt|
309N *+ex_extra* Vim's extra Ex commands: |:center|, |:left|,
310 |:normal|, |:retab| and |:right|
311N *+extra_search* |'hlsearch'| and |'incsearch'| options.
312B *+farsi* |farsi| language
313N *+file_in_path* |gf|, |CTRL-W_f| and |<cfile>|
314N *+find_in_path* include file searches: |[I|, |:isearch|,
315 |CTRL-W_CTRL-I|, |:checkpath|, etc.
316N *+folding* |folding|
317 *+footer* |gui-footer|
318 *+fork* Unix only: |fork| shell commands
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000319 *+float* Floating point support
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320N *+gettext* message translations |multi-lang|
321 *+GUI_Athena* Unix only: Athena |GUI|
322 *+GUI_neXtaw* Unix only: neXtaw |GUI|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000323 *+GUI_GTK* Unix only: GTK+ |GUI|
324 *+GUI_Motif* Unix only: Motif |GUI|
325 *+GUI_Photon* QNX only: Photon |GUI|
326m *+hangul_input* Hangul input support |hangul|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000327 *+iconv* Compiled with the |iconv()| function
328 *+iconv/dyn* Likewise |iconv-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000329N *+insert_expand* |insert_expand| Insert mode completion
330N *+jumplist* |jumplist|
331B *+keymap* |'keymap'|
332B *+langmap* |'langmap'|
333N *+libcall* |libcall()|
334N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'|
335N *+lispindent* |'lisp'|
336N *+listcmds* Vim commands for the list of buffers |buffer-hidden|
337 and argument list |:argdelete|
338N *+localmap* Support for mappings local to a buffer |:map-local|
339N *+menu* |:menu|
340N *+mksession* |:mksession|
341N *+modify_fname* |filename-modifiers|
342N *+mouse* Mouse handling |mouse-using|
343N *+mouseshape* |'mouseshape'|
344B *+mouse_dec* Unix only: Dec terminal mouse handling |dec-mouse|
345N *+mouse_gpm* Unix only: Linux console mouse handling |gpm-mouse|
346B *+mouse_netterm* Unix only: netterm mouse handling |netterm-mouse|
347N *+mouse_pterm* QNX only: pterm mouse handling |qnx-terminal|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000348N *+mouse_sysmouse* Unix only: *BSD console mouse handling |sysmouse|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349N *+mouse_xterm* Unix only: xterm mouse handling |xterm-mouse|
350B *+multi_byte* Korean and other languages |multibyte|
351 *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
352N *+multi_lang* non-English language support |multi-lang|
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000353m *+mzscheme* Mzscheme interface |mzscheme|
Bram Moolenaar4770d092006-01-12 23:22:24 +0000354m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355m *+netbeans_intg* |netbeans|
356m *+ole* Win32 GUI only: |ole-interface|
357 *+osfiletype* Support for the 'osfiletype' option and filetype
358 checking in automatic commands. |autocmd-osfiletypes|
359N *+path_extra* Up/downwards search in 'path' and 'tags'
Bram Moolenaara5792f52005-11-23 21:25:05 +0000360m *+perl* Perl interface |perl|
361m *+perl/dyn* Perl interface |perl-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362 *+postscript* |:hardcopy| writes a PostScript file
363N *+printer* |:hardcopy| command
Bram Moolenaar19a09a12005-03-04 23:39:37 +0000364H *+profile* |:profile| command
Bram Moolenaara5792f52005-11-23 21:25:05 +0000365m *+python* Python interface |python|
366m *+python/dyn* Python interface |python-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000367N *+quickfix* |:make| and |quickfix| commands
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000368N *+reltime* |reltime()| function, 'hlsearch'/'incsearch' timeout,
369 'redrawtime' option
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370B *+rightleft* Right to left typing |'rightleft'|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000371m *+ruby* Ruby interface |ruby|
372m *+ruby/dyn* Ruby interface |ruby-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000373N *+scrollbind* |'scrollbind'|
374B *+signs* |:sign|
375N *+smartindent* |'smartindent'|
376m *+sniff* SniFF interface |sniff|
377N *+statusline* Options 'statusline', 'rulerformat' and special
378 formats of 'titlestring' and 'iconstring'
379m *+sun_workshop* |workshop|
380N *+syntax* Syntax highlighting |syntax|
381 *+system()* Unix only: opposite of |+fork|
382N *+tag_binary* binary searching in tags file |tag-binary-search|
383N *+tag_old_static* old method for static tags |tag-old-static|
384m *+tag_any_white* any white space allowed in tags file |tag-any-white|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000385m *+tcl* Tcl interface |tcl|
386m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000387 *+terminfo* uses |terminfo| instead of termcap
388N *+termresponse* support for |t_RV| and |v:termresponse|
389N *+textobjects* |text-objects| selection
390 *+tgetent* non-Unix only: able to use external termcap
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000391N *+title* Setting the window 'title' and 'icon'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000392N *+toolbar* |gui-toolbar|
393N *+user_commands* User-defined commands. |user-commands|
394N *+viminfo* |'viminfo'|
395N *+vertsplit* Vertically split windows |:vsplit|
396N *+virtualedit* |'virtualedit'|
397S *+visual* Visual mode |Visual-mode|
398N *+visualextra* extra Visual mode commands |blockwise-operators|
399N *+vreplace* |gR| and |gr|
400N *+wildignore* |'wildignore'|
401N *+wildmenu* |'wildmenu'|
402S *+windows* more than one window
403m *+writebackup* |'writebackup'| is default on
404m *+xim* X input method |xim|
405 *+xfontset* X fontset support |xfontset|
406 *+xsmp* XSMP (X session management) support
407 *+xsmp_interact* interactive XSMP (X session management) support
408N *+xterm_clipboard* Unix only: xterm clipboard handling
409m *+xterm_save* save and restore xterm screen |xterm-screens|
410N *+X11* Unix only: can restore window title |X11|
411
412 */dyn* *E370* *E448*
413 To some of the features "/dyn" is added when the
414 feature is only available when the related library can
415 be dynamically loaded.
416
417:ve[rsion] {nr} Is now ignored. This was previously used to check the
418 version number of a .vimrc file. It was removed,
419 because you can now use the ":if" command for
420 version-dependent behavior. {not in Vi}
421
422 *:redi* *:redir*
423:redi[r][!] > {file} Redirect messages to file {file}. The messages which
424 are the output of commands are written to that file,
425 until redirection ends. The messages are also still
426 shown on the screen. When [!] is included, an
427 existing file is overwritten. When [!] is omitted,
428 and {file} exists, this command fails.
429 Only one ":redir" can be active at a time. Calls to
430 ":redir" will close any active redirection before
431 starting redirection to the new target.
432 To stop the messages and commands from being echoed to
433 the screen, put the commands in a function and call it
434 with ":silent call Function()".
Bram Moolenaar54ee7752005-05-31 22:22:17 +0000435 An alternative is to use the 'verbosefile' option,
436 this can be used in combination with ":redir".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437 {not in Vi}
438
439:redi[r] >> {file} Redirect messages to file {file}. Append if {file}
440 already exists. {not in Vi}
441
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000442:redi[r] @{a-zA-Z}
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000443:redi[r] @{a-zA-Z}> Redirect messages to register {a-z}. Append to the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444 contents of the register if its name is given
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000445 uppercase {A-Z}. The ">" after the register name is
446 optional. {not in Vi}
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +0000447:redi[r] @{a-z}>> Append messages to register {a-z}. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000449:redi[r] @*>
450:redi[r] @+> Redirect messages to the selection or clipboard. For
451 backward compatibility, the ">" after the register
452 name can be omitted. See |quotestar| and |quoteplus|.
453 {not in Vi}
454:redi[r] @*>>
455:redi[r] @+>> Append messages to the selection or clipboard.
456 {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000458:redi[r] @"> Redirect messages to the unnamed register. For
459 backward compatibility, the ">" after the register
460 name can be omitted. {not in Vi}
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +0000461:redi[r] @">> Append messages to the unnamed register. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000462
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000463:redi[r] => {var} Redirect messages to a variable. If the variable
464 doesn't exist, then it is created. If the variable
465 exists, then it is initialized to an empty string.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000466 The variable will remain empty until redirection ends.
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000467 Only string variables can be used. After the
468 redirection starts, if the variable is removed or
469 locked or the variable type is changed, then further
470 command output messages will cause errors. {not in Vi}
471
472:redi[r] =>> {var} Append messages to an existing variable. Only string
473 variables can be used. {not in Vi}
474
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475:redi[r] END End redirecting messages. {not in Vi}
476
477 *:sil* *:silent*
478:sil[ent][!] {command} Execute {command} silently. Normal messages will not
479 be given or added to the message history.
480 When [!] is added, error messages will also be
481 skipped, and commands and mappings will not be aborted
482 when an error is detected. |v:errmsg| is still set.
483 When [!] is not used, an error message will cause
484 further messages to be displayed normally.
485 Redirection, started with |:redir|, will continue as
486 usual, although there might be small differences.
487 This will allow redirecting the output of a command
488 without seeing it on the screen. Example: >
489 :redir >/tmp/foobar
490 :silent g/Aap/p
491 :redir END
492< To execute a Normal mode command silently, use the
493 |:normal| command. For example, to search for a
494 string without messages: >
495 :silent exe "normal /path\<CR>"
496< ":silent!" is useful to execute a command that may
497 fail, but the failure is to be ignored. Example: >
498 :let v:errmsg = ""
499 :silent! /^begin
500 :if v:errmsg != ""
501 : ... pattern was not found
502< ":silent" will also avoid the hit-enter prompt. When
503 using this for an external command, this may cause the
504 screen to be messed up. Use |CTRL-L| to clean it up
505 then.
506 ":silent menu ..." defines a menu that will not echo a
507 Command-line command. The command will still produce
508 messages though. Use ":silent" in the command itself
509 to avoid that: ":silent menu .... :silent command".
510
Bram Moolenaar8e258a42009-07-09 13:55:43 +0000511 *:uns* *:unsilent*
512:uns[ilent] {command} Execute {command} not silently. Only makes a
513 difference when |:silent| was used to get to this
514 command.
515 Use this for giving a message even when |:silent| was
516 used. In this example |:silent| is used to avoid the
517 message about reading the file and |:unsilent| to be
518 able to list the first line of each file. >
519 :silent argdo unsilent echo expand('%') . ": " . getline(1)
520<
521
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522 *:verb* *:verbose*
523:[count]verb[ose] {command}
524 Execute {command} with 'verbose' set to [count]. If
Bram Moolenaared203462004-06-16 11:19:22 +0000525 [count] is omitted one is used. ":0verbose" can be
526 used to set 'verbose' to zero.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000527 The additional use of ":silent" makes messages
528 generated but not displayed.
529 The combination of ":silent" and ":verbose" can be
530 used to generate messages and check them with
531 |v:statusmsg| and friends. For example: >
532 :let v:statusmsg = ""
533 :silent verbose runtime foobar.vim
534 :if v:statusmsg != ""
535 : " foobar.vim could not be found
536 :endif
537< When concatenating another command, the ":verbose"
538 only applies to the first one: >
539 :4verbose set verbose | set verbose
540< verbose=4 ~
541 verbose=0 ~
Bram Moolenaar54ee7752005-05-31 22:22:17 +0000542 For logging verbose messages in a file use the
543 'verbosefile' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000545 *:verbose-cmd*
546When 'verbose' is non-zero, listing the value of a Vim option or a key map or
Bram Moolenaare344bea2005-09-01 20:46:49 +0000547an abbreviation or a user-defined function or a command or a highlight group
548or an autocommand will also display where it was last defined. If it was
549defined manually then there will be no "Last set" message. When it was
550defined while executing a function, user command or autocommand, the script in
551which it was defined is reported.
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000552{not available when compiled without the +eval feature}
553
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 *K*
555K Run a program to lookup the keyword under the
556 cursor. The name of the program is given with the
557 'keywordprg' (kp) option (default is "man"). The
558 keyword is formed of letters, numbers and the
559 characters in 'iskeyword'. The keyword under or
560 right of the cursor is used. The same can be done
561 with the command >
562 :!{program} {keyword}
563< There is an example of a program to use in the tools
564 directory of Vim. It is called 'ref' and does a
565 simple spelling check.
566 Special cases:
567 - If 'keywordprg' is empty, the ":help" command is
568 used. It's a good idea to include more characters
569 in 'iskeyword' then, to be able to find more help.
570 - When 'keywordprg' is equal to "man", a count before
571 "K" is inserted after the "man" command and before
572 the keyword. For example, using "2K" while the
573 cursor is on "mkdir", results in: >
574 !man 2 mkdir
575< - When 'keywordprg' is equal to "man -s", a count
576 before "K" is inserted after the "-s". If there is
577 no count, the "-s" is removed.
578 {not in Vi}
579
580 *v_K*
581{Visual}K Like "K", but use the visually highlighted text for
582 the keyword. Only works when the highlighted text is
583 not more than one line. {not in Vi}
584
585[N]gs *gs* *:sl* *:sleep*
586:[N]sl[eep] [N] [m] Do nothing for [N] seconds. When [m] is included,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000587 sleep for [N] milliseconds. The count for "gs" always
Bram Moolenaar071d4272004-06-13 20:20:40 +0000588 uses seconds. The default is one second. >
589 :sleep "sleep for one second
590 :5sleep "sleep for five seconds
591 :sleep 100m "sleep for a hundred milliseconds
592 10gs "sleep for ten seconds
593< Can be interrupted with CTRL-C (CTRL-Break on MS-DOS).
Bram Moolenaar677ee682005-01-27 14:41:15 +0000594 "gs" stands for "goto sleep".
595 While sleeping the cursor is positioned in the text,
596 if at a visible position. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597
598 *g_CTRL-A*
599g CTRL-A Only when Vim was compiled with MEM_PROFILING defined
600 (which is very rare): print memory usage statistics.
601 Only useful for debugging Vim.
602
603==============================================================================
6042. Online help *online-help*
605
606 *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
607<Help> or
608:h[elp] Open a window and display the help file in read-only
609 mode. If there is a help window open already, use
610 that one. Otherwise, if the current window uses the
611 full width of the screen or is at least 80 characters
612 wide, the help window will appear just above the
613 current window. Otherwise the new window is put at
614 the very top.
615 The 'helplang' option is used to select a language, if
616 the main help file is available in several languages.
617 {not in Vi}
618
619 *{subject}* *E149* *E661*
620:h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
621 {subject} can include wildcards like "*", "?" and
622 "[a-z]":
623 :help z? jump to help for any "z" command
624 :help z. jump to the help for "z."
625 If there is no full match for the pattern, or there
626 are several matches, the "best" match will be used.
627 A sophisticated algorithm is used to decide which
628 match is better than another one. These items are
629 considered in the computation:
630 - A match with same case is much better than a match
631 with different case.
632 - A match that starts after a non-alphanumeric
633 character is better than a match in the middle of a
634 word.
635 - A match at or near the beginning of the tag is
636 better than a match further on.
637 - The more alphanumeric characters match, the better.
638 - The shorter the length of the match, the better.
639
640 The 'helplang' option is used to select a language, if
641 the {subject} is available in several languages.
642 To find a tag in a specific language, append "@ab",
643 where "ab" is the two-letter language code. See
644 |help-translated|.
645
646 Note that the longer the {subject} you give, the less
647 matches will be found. You can get an idea how this
648 all works by using commandline completion (type CTRL-D
649 after ":help subject").
650 If there are several matches, you can have them listed
651 by hitting CTRL-D. Example: >
652 :help cont<Ctrl-D>
653< To use a regexp |pattern|, first do ":help" and then
654 use ":tag {pattern}" in the help window. The
655 ":tnext" command can then be used to jump to other
656 matches, "tselect" to list matches and choose one. >
657 :help index| :tse z.
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000658< When there is no argument you will see matches for
659 "help", to avoid listing all possible matches (that
660 would be very slow).
661 The number of matches displayed is limited to 300.
662
663 This command can be followed by '|' and another
Bram Moolenaar071d4272004-06-13 20:20:40 +0000664 command, but you don't need to escape the '|' inside a
665 help command. So these both work: >
666 :help |
667 :help k| only
668< Note that a space before the '|' is seen as part of
669 the ":help" argument.
670 You can also use <LF> or <CR> to separate the help
671 command from a following command. You need to type
672 CTRL-V first to insert the <LF> or <CR>. Example: >
673 :help so<C-V><CR>only
674< {not in Vi}
675
676:h[elp]! [subject] Like ":help", but in non-English help files prefer to
677 find a tag in a file with the same language as the
678 current file. See |help-translated|.
679
680 *:helpg* *:helpgrep*
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000681:helpg[rep] {pattern}[@xx]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 Search all help text files and make a list of lines
683 in which {pattern} matches. Jumps to the first match.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000684 The optional [@xx] specifies that only matches in the
685 "xx" language are to be found.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000686 You can navigate through the matches with the
687 |quickfix| commands, e.g., |:cnext| to jump to the
688 next one. Or use |:cwindow| to get the list of
689 matches in the quickfix window.
690 {pattern} is used as a Vim regexp |pattern|.
691 'ignorecase' is not used, add "\c" to ignore case.
692 Example for case sensitive search: >
693 :helpgrep Uganda
694< Example for case ignoring search: >
695 :helpgrep uganda\c
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000696< Example for searching in French help: >
697 :helpgrep backspace@fr
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000698< The pattern does not support line breaks, it must
699 match within one line. You can use |:grep| instead,
700 but then you need to get the list of help files in a
701 complicated way.
702 Cannot be followed by another command, everything is
Bram Moolenaar071d4272004-06-13 20:20:40 +0000703 used as part of the pattern. But you can use
704 |:execute| when needed.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000705 Compressed help files will not be searched (Fedora
Bram Moolenaar071d4272004-06-13 20:20:40 +0000706 compresses the help files).
707 {not in Vi}
708
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000709 *:lh* *:lhelpgrep*
710:lh[elpgrep] {pattern}[@xx]
711 Same as ":helpgrep", except the location list is used
712 instead of the quickfix list. If the help window is
713 already opened, then the location list for that window
714 is used. Otherwise, a new help window is opened and
715 the location list for that window is set. The
716 location list for the current window is not changed.
717
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +0000718 *:exu* *:exusage*
719:exu[sage] Show help on Ex commands. Added to simulate the Nvi
720 command. {not in Vi}
721
722 *:viu* *:viusage*
723:viu[sage] Show help on Normal mode commands. Added to simulate
724 the Nvi command. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000725
726When no argument is given to |:help| the file given with the 'helpfile' option
727will be opened. Otherwise the specified tag is searched for in all "doc/tags"
728files in the directories specified in the 'runtimepath' option.
729
730The initial height of the help window can be set with the 'helpheight' option
731(default 20).
732
733Jump to specific subjects by using tags. This can be done in two ways:
734- Use the "CTRL-]" command while standing on the name of a command or option.
735 This only works when the tag is a keyword. "<C-Leftmouse>" and
736 "g<LeftMouse>" work just like "CTRL-]".
737- use the ":ta {subject}" command. This also works with non-keyword
738 characters.
739
740Use CTRL-T or CTRL-O to jump back.
741Use ":q" to close the help window.
742
743If there are several matches for an item you are looking for, this is how you
744can jump to each one of them:
7451. Open a help window
7462. Use the ":tag" command with a slash prepended to the tag. E.g.: >
747 :tag /min
7483. Use ":tnext" to jump to the next matching tag.
749
750It is possible to add help files for plugins and other items. You don't need
751to change the distributed help files for that. See |add-local-help|.
752
753To write a local help file, see |write-local-help|.
754
755Note that the title lines from the local help files are automagically added to
756the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
757This is done when viewing the file in Vim, the file itself is not changed. It
758is done by going through all help files and obtaining the first line of each
759file. The files in $VIMRUNTIME/doc are skipped.
760
761 *help-xterm-window*
762If you want to have the help in another xterm window, you could use this
763command: >
764 :!xterm -e vim +help &
765<
766
767 *:helpfind* *:helpf*
768:helpf[ind] Like |:help|, but use a dialog to enter the argument.
769 Only for backwards compatibility. It now executes the
770 ToolBar.FindHelp menu entry instead of using a builtin
771 dialog. {only when compiled with |+GUI_GTK|}
772< {not in Vi}
773
774 *:helpt* *:helptags*
775 *E154* *E150* *E151* *E152* *E153* *E670*
Bram Moolenaar426e5c92008-01-11 20:02:02 +0000776:helpt[ags] [++t] {dir}
777 Generate the help tags file(s) for directory {dir}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000778 All "*.txt" and "*.??x" files in the directory are
779 scanned for a help tag definition in between stars.
780 The "*.??x" files are for translated docs, they
781 generate the "tags-??" file, see |help-translated|.
782 The generated tags files are sorted.
783 When there are duplicates an error message is given.
784 An existing tags file is silently overwritten.
Bram Moolenaar426e5c92008-01-11 20:02:02 +0000785 The optional "++t" argument forces adding the
786 "help-tags" tag. This is also done when the {dir} is
787 equal to $VIMRUNTIME/doc.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000788 To rebuild the help tags in the runtime directory
789 (requires write permission there): >
790 :helptags $VIMRUNTIME/doc
791< {not in Vi}
792
793
794TRANSLATED HELP *help-translated*
795
796It is possible to add translated help files, next to the original English help
797files. Vim will search for all help in "doc" directories in 'runtimepath'.
798This is only available when compiled with the |+multi_lang| feature.
799
Bram Moolenaardb552d602006-03-23 22:59:57 +0000800At this moment translations are available for:
801 Chinese - multiple authors
802 French - translated by David Blanchet
803 Italian - translated by Antonio Colombo
Bram Moolenaar42bbef42006-03-25 22:02:07 +0000804 Polish - translated by Mikolaj Machowski
Bram Moolenaardb552d602006-03-23 22:59:57 +0000805 Russian - translated by Vassily Ragosin
806See the Vim website to find them: http://www.vim.org/translations.php
807
Bram Moolenaar071d4272004-06-13 20:20:40 +0000808A set of translated help files consists of these files:
809
810 help.abx
811 howto.abx
812 ...
813 tags-ab
814
815"ab" is the two-letter language code. Thus for Italian the names are:
816
817 help.itx
818 howto.itx
819 ...
820 tags-it
821
822The 'helplang' option can be set to the preferred language(s). The default is
823set according to the environment. Vim will first try to find a matching tag
824in the preferred language(s). English is used when it cannot be found.
825
826To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
827two-letter language code. Example: >
828 :he user-manual@it
829 :he user-manual@en
830The first one finds the Italian user manual, even when 'helplang' is empty.
831The second one finds the English user manual, even when 'helplang' is set to
832"it".
833
834When using command-line completion for the ":help" command, the "@en"
Bram Moolenaarc236c162008-07-13 17:41:49 +0000835extension is only shown when a tag exists for multiple languages. When the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000836tag only exists for English "@en" is omitted.
837
838When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
839find the tag in the same language. If not found then 'helplang' will be used
840to select a language.
841
842Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
843utf-8 when finding non-ASCII characters in the first line. Thus you must
844translate the header with "For Vim version".
845
846The same encoding must be used for the help files of one language in one
847directory. You can use a different encoding for different languages and use
848a different encoding for help files of the same language but in a different
849directory.
850
851Hints for translators:
852- Do not translate the tags. This makes it possible to use 'helplang' to
853 specify the preferred language. You may add new tags in your language.
854- When you do not translate a part of a file, add tags to the English version,
855 using the "tag@en" notation.
856- Make a package with all the files and the tags file available for download.
857 Users can drop it in one of the "doc" directories and start use it.
858 Report this to Bram, so that he can add a link on www.vim.org.
859- Use the |:helptags| command to generate the tags files. It will find all
860 languages in the specified directory.
861
862==============================================================================
Bram Moolenaareb3593b2006-04-22 22:33:57 +00008633. Using Vim like less or more *less*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000864
865If you use the less or more program to view a file, you don't get syntax
866highlighting. Thus you would like to use Vim instead. You can do this by
867using the shell script "$VIMRUNTIME/macros/less.sh".
868
869This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
870up mappings to simulate the commands that less supports. Otherwise, you can
871still use the Vim commands.
872
873This isn't perfect. For example, when viewing a short file Vim will still use
874the whole screen. But it works good enough for most uses, and you get syntax
875highlighting.
876
877The "h" key will give you a short overview of the available commands.
878
879 vim:tw=78:ts=8:ft=help:norl: