blob: 2f1d3fff6f03ee55e160a877e60fdbc53126d9c9 [file] [log] [blame]
Bram Moolenaar1423b9d2006-05-07 15:16:06 +00001*various.txt* For Vim version 7.0. Last change: 2006 Apr 25
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
124 *:z* *E144*
125:{range}z[+-^.=]{count} Display several lines of text surrounding the line
126 specified with {range}, or around the current line
127 if there is no {range}. If there is a {count}, that's
Bram Moolenaar4399ef42005-02-12 14:29:27 +0000128 how many lines you'll see; if there is only one window
129 then the 'window' option is used, otherwise the
130 current window size is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131
132 :z can be used either alone or followed by any of
133 several punctuation marks. These have the following
134 effect:
135
136 mark first line last line new location ~
137 ---- ---------- --------- ------------
138 + current line 1 scr forward 1 scr forward
139 - 1 scr back current line current line
140 ^ 2 scr back 1 scr back 1 scr back
Bram Moolenaar2a8d1f82005-02-05 21:43:56 +0000141 . 1/2 scr back 1/2 scr fwd 1/2 scr fwd
142 = 1/2 scr back 1/2 scr fwd current line
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143
144 Specifying no mark at all is the same as "+".
145 If the mark is "=", a line of dashes is printed
146 around the current line.
147
148:{range}z#[+-^.=]{count} *:z#*
149 Like ":z", but number the lines.
150 {not in all versions of Vi, not with these arguments}
151
152 *:=*
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000153:= [flags] Print the last line number.
154 See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000155
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000156:{range}= [flags] Prints the last line number in {range}. For example,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000157 this prints the current line number: >
158 :.=
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000159< See |ex-flags| for [flags].
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160
161:norm[al][!] {commands} *:norm* *:normal*
162 Execute Normal mode commands {commands}. This makes
163 it possible to execute Normal mode commands typed on
164 the command-line. {commands} is executed like it is
165 typed. For undo all commands are undone together.
166 If the [!] is given, mappings will not be used.
167 {commands} should be a complete command. If
168 {commands} does not finish a command, the last one
169 will be aborted as if <Esc> or <C-C> was typed.
170 The display isn't updated while ":normal" is busy.
171 This implies that an insert command must be completed
172 (to start Insert mode, see |:startinsert|). A ":"
Bram Moolenaar7c626922005-02-07 22:01:03 +0000173 command must be completed as well. And you can't use
174 "Q" or "gQ" to start Ex mode.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000175 {commands} cannot start with a space. Put a 1 (one)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000176 before it, 1 space is one space.
177 The 'insertmode' option is ignored for {commands}.
178 This command cannot be followed by another command,
179 since any '|' is considered part of the command.
180 This command can be used recursively, but the depth is
181 limited by 'maxmapdepth'.
182 When this command is called from a non-remappable
183 mapping |:noremap|, the argument can be mapped anyway.
184 An alternative is to use |:execute|, which uses an
185 expression as argument. This allows the use of
186 printable characters. Example: >
187 :exe "normal \<c-w>\<c-w>"
188< {not in Vi, of course}
189 {not available when the |+ex_extra| feature was
190 disabled at compile time}
191
192:{range}norm[al][!] {commands} *:normal-range*
193 Execute Normal mode commands {commands} for each line
194 in the {range}. Before executing the {commands}, the
195 cursor is positioned in the first column of the range,
196 for each line. Otherwise it's the same as the
197 ":normal" command without a range.
198 {not in Vi}
199 Not available when |+ex_extra| feature was disabled at
200 compile time.
201
202 *:sh* *:shell* *E371*
203:sh[ell] This command starts a shell. When the shell exits
204 (after the "exit" command) you return to Vim. The
205 name for the shell command comes from 'shell' option.
206 *E360*
207 Note: This doesn't work when Vim on the Amiga was
208 started in QuickFix mode from a compiler, because the
209 compiler will have set stdin to a non-interactive
210 mode.
211
212 *:!cmd* *:!* *E34*
213:!{cmd} Execute {cmd} with the shell. See also the 'shell'
214 and 'shelltype' option.
215 Any '!' in {cmd} is replaced with the previous
216 external command (see also 'cpoptions'). But not when
217 there is a backslash before the '!', then that
218 backslash is removed. Example: ":!ls" followed by
219 ":!echo ! \! \\!" executes "echo ls ! \!".
220 After the command has been executed, the timestamp of
221 the current file is checked |timestamp|.
222 There cannot be a '|' in {cmd}, see |:bar|.
223 A newline character ends {cmd}, what follows is
224 interpreted as a following ":" command. However, if
225 there is a backslash before the newline it is removed
226 and {cmd} continues. It doesn't matter how many
227 backslashes are before the newline, only one is
228 removed.
229 On Unix the command normally runs in a non-interactive
230 shell. If you want an interactive shell to be used
231 (to use aliases) set 'shellcmdflag' to "-ic".
232 For Win32 also see |:!start|.
233 Vim redraws the screen after the command is finished,
234 because it may have printed any text. This requires a
235 hit-enter prompt, so that you can read any messages.
236 To avoid this use: >
237 :silent !{cmd}
238< The screen is not redrawn then, thus you have to use
239 CTRL-L or ":redraw!" if the command did display
240 something.
241 Also see |shell-window|.
242
243 *:!!*
244:!! Repeat last ":!{cmd}".
245
246 *:ve* *:version*
247:ve[rsion] Print the version number of the editor. If the
248 compiler used understands "__DATE__" the compilation
249 date is mentioned. Otherwise a fixed release-date is
250 shown.
251 The following lines contain information about which
252 features were enabled when Vim was compiled. When
253 there is a preceding '+', the feature is included,
254 when there is a '-' it is excluded. To change this,
255 you have to edit feature.h and recompile Vim.
256 To check for this in an expression, see |has()|.
257 Here is an overview of the features.
258 The first column shows the smallest version in which
259 they are included:
260 T tiny
261 S small
262 N normal
263 B big
264 H huge
265 m manually enabled or depends on other features
266 (none) system dependent
267 Thus if a feature is marked with "N", it is included
268 in the normal, big and huge versions of Vim.
269
270 *+feature-list*
271 *+ARP* Amiga only: ARP support included
272B *+arabic* |Arabic| language support
273N *+autocmd* |:autocmd|, automatic commands
Bram Moolenaar4d34b432005-03-07 23:22:00 +0000274m *+balloon_eval* |balloon-eval| support. Included when compiling with
275 supported GUI (Motif, GTK, GUI) and either
276 Netbeans/Sun Workshop integration or |+eval| feature.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277N *+browse* |:browse| command
278N *+builtin_terms* some terminals builtin |builtin-terms|
279B *++builtin_terms* maximal terminals builtin |builtin-terms|
280N *+byte_offset* support for 'o' flag in 'statusline' option, "go"
281 and ":goto" commands.
282N *+cindent* |'cindent'|, C indenting
283N *+clientserver* Unix and Win32: Remote invocation |clientserver|
284 *+clipboard* |clipboard| support
285N *+cmdline_compl* command line completion |cmdline-completion|
286N *+cmdline_hist* command line history |cmdline-history|
287N *+cmdline_info* |'showcmd'| and |'ruler'|
288N *+comments* |'comments'| support
289N *+cryptv* encryption support |encryption|
290B *+cscope* |cscope| support
Bram Moolenaarac6e65f2005-08-29 22:25:38 +0000291m *+cursorshape* |termcap-cursor-shape| support
292m *+debug* Compiled for debugging.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293N *+dialog_gui* Support for |:confirm| with GUI dialog.
294N *+dialog_con* Support for |:confirm| with console dialog.
295N *+dialog_con_gui* Support for |:confirm| with GUI and console dialog.
296N *+diff* |vimdiff| and 'diff'
297N *+digraphs* |digraphs| *E196*
298 *+dnd* Support for DnD into the "~ register |quote_~|.
299B *+emacs_tags* |emacs-tags| files
300N *+eval* expression evaluation |eval.txt|
301N *+ex_extra* Vim's extra Ex commands: |:center|, |:left|,
302 |:normal|, |:retab| and |:right|
303N *+extra_search* |'hlsearch'| and |'incsearch'| options.
304B *+farsi* |farsi| language
305N *+file_in_path* |gf|, |CTRL-W_f| and |<cfile>|
306N *+find_in_path* include file searches: |[I|, |:isearch|,
307 |CTRL-W_CTRL-I|, |:checkpath|, etc.
308N *+folding* |folding|
309 *+footer* |gui-footer|
310 *+fork* Unix only: |fork| shell commands
311N *+gettext* message translations |multi-lang|
312 *+GUI_Athena* Unix only: Athena |GUI|
313 *+GUI_neXtaw* Unix only: neXtaw |GUI|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000314 *+GUI_GTK* Unix only: GTK+ |GUI|
315 *+GUI_Motif* Unix only: Motif |GUI|
316 *+GUI_Photon* QNX only: Photon |GUI|
317m *+hangul_input* Hangul input support |hangul|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000318 *+iconv* Compiled with the |iconv()| function
319 *+iconv/dyn* Likewise |iconv-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320N *+insert_expand* |insert_expand| Insert mode completion
321N *+jumplist* |jumplist|
322B *+keymap* |'keymap'|
323B *+langmap* |'langmap'|
324N *+libcall* |libcall()|
325N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'|
326N *+lispindent* |'lisp'|
327N *+listcmds* Vim commands for the list of buffers |buffer-hidden|
328 and argument list |:argdelete|
329N *+localmap* Support for mappings local to a buffer |:map-local|
330N *+menu* |:menu|
331N *+mksession* |:mksession|
332N *+modify_fname* |filename-modifiers|
333N *+mouse* Mouse handling |mouse-using|
334N *+mouseshape* |'mouseshape'|
335B *+mouse_dec* Unix only: Dec terminal mouse handling |dec-mouse|
336N *+mouse_gpm* Unix only: Linux console mouse handling |gpm-mouse|
337B *+mouse_netterm* Unix only: netterm mouse handling |netterm-mouse|
338N *+mouse_pterm* QNX only: pterm mouse handling |qnx-terminal|
339N *+mouse_xterm* Unix only: xterm mouse handling |xterm-mouse|
340B *+multi_byte* Korean and other languages |multibyte|
341 *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
342N *+multi_lang* non-English language support |multi-lang|
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000343m *+mzscheme* Mzscheme interface |mzscheme|
Bram Moolenaar4770d092006-01-12 23:22:24 +0000344m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345m *+netbeans_intg* |netbeans|
346m *+ole* Win32 GUI only: |ole-interface|
347 *+osfiletype* Support for the 'osfiletype' option and filetype
348 checking in automatic commands. |autocmd-osfiletypes|
349N *+path_extra* Up/downwards search in 'path' and 'tags'
Bram Moolenaara5792f52005-11-23 21:25:05 +0000350m *+perl* Perl interface |perl|
351m *+perl/dyn* Perl interface |perl-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 *+postscript* |:hardcopy| writes a PostScript file
353N *+printer* |:hardcopy| command
Bram Moolenaar19a09a12005-03-04 23:39:37 +0000354H *+profile* |:profile| command
Bram Moolenaara5792f52005-11-23 21:25:05 +0000355m *+python* Python interface |python|
356m *+python/dyn* Python interface |python-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357N *+quickfix* |:make| and |quickfix| commands
Bram Moolenaar433f7c82006-03-21 21:29:36 +0000358N *+reltime* |reltime()| function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359B *+rightleft* Right to left typing |'rightleft'|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000360m *+ruby* Ruby interface |ruby|
361m *+ruby/dyn* Ruby interface |ruby-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362N *+scrollbind* |'scrollbind'|
363B *+signs* |:sign|
364N *+smartindent* |'smartindent'|
365m *+sniff* SniFF interface |sniff|
366N *+statusline* Options 'statusline', 'rulerformat' and special
367 formats of 'titlestring' and 'iconstring'
368m *+sun_workshop* |workshop|
369N *+syntax* Syntax highlighting |syntax|
370 *+system()* Unix only: opposite of |+fork|
371N *+tag_binary* binary searching in tags file |tag-binary-search|
372N *+tag_old_static* old method for static tags |tag-old-static|
373m *+tag_any_white* any white space allowed in tags file |tag-any-white|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000374m *+tcl* Tcl interface |tcl|
375m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376 *+terminfo* uses |terminfo| instead of termcap
377N *+termresponse* support for |t_RV| and |v:termresponse|
378N *+textobjects* |text-objects| selection
379 *+tgetent* non-Unix only: able to use external termcap
380N *+title* Setting the window title |'title'|
381N *+toolbar* |gui-toolbar|
382N *+user_commands* User-defined commands. |user-commands|
383N *+viminfo* |'viminfo'|
384N *+vertsplit* Vertically split windows |:vsplit|
385N *+virtualedit* |'virtualedit'|
386S *+visual* Visual mode |Visual-mode|
387N *+visualextra* extra Visual mode commands |blockwise-operators|
388N *+vreplace* |gR| and |gr|
389N *+wildignore* |'wildignore'|
390N *+wildmenu* |'wildmenu'|
391S *+windows* more than one window
392m *+writebackup* |'writebackup'| is default on
393m *+xim* X input method |xim|
394 *+xfontset* X fontset support |xfontset|
395 *+xsmp* XSMP (X session management) support
396 *+xsmp_interact* interactive XSMP (X session management) support
397N *+xterm_clipboard* Unix only: xterm clipboard handling
398m *+xterm_save* save and restore xterm screen |xterm-screens|
399N *+X11* Unix only: can restore window title |X11|
400
401 */dyn* *E370* *E448*
402 To some of the features "/dyn" is added when the
403 feature is only available when the related library can
404 be dynamically loaded.
405
406:ve[rsion] {nr} Is now ignored. This was previously used to check the
407 version number of a .vimrc file. It was removed,
408 because you can now use the ":if" command for
409 version-dependent behavior. {not in Vi}
410
411 *:redi* *:redir*
412:redi[r][!] > {file} Redirect messages to file {file}. The messages which
413 are the output of commands are written to that file,
414 until redirection ends. The messages are also still
415 shown on the screen. When [!] is included, an
416 existing file is overwritten. When [!] is omitted,
417 and {file} exists, this command fails.
418 Only one ":redir" can be active at a time. Calls to
419 ":redir" will close any active redirection before
420 starting redirection to the new target.
421 To stop the messages and commands from being echoed to
422 the screen, put the commands in a function and call it
423 with ":silent call Function()".
Bram Moolenaar54ee7752005-05-31 22:22:17 +0000424 An alternative is to use the 'verbosefile' option,
425 this can be used in combination with ":redir".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 {not in Vi}
427
428:redi[r] >> {file} Redirect messages to file {file}. Append if {file}
429 already exists. {not in Vi}
430
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000431:redi[r] @{a-zA-Z}> Redirect messages to register {a-z}. Append to the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432 contents of the register if its name is given
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000433 uppercase {A-Z}. For backward compatibility, the ">"
434 after the register name can be omitted. {not in Vi}
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +0000435:redi[r] @{a-z}>> Append messages to register {a-z}. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000437:redi[r] @*> Redirect messages to the clipboard. For backward
438 compatibility, the ">" after the register name can be
439 omitted. {not in Vi}
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +0000440:redi[r] @*>> Append messages to the clipboard. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441
Bram Moolenaar6c0b44b2005-06-01 21:56:33 +0000442:redi[r] @"> Redirect messages to the unnamed register. For
443 backward compatibility, the ">" after the register
444 name can be omitted. {not in Vi}
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +0000445:redi[r] @">> Append messages to the unnamed register. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000447:redi[r] => {var} Redirect messages to a variable. If the variable
448 doesn't exist, then it is created. If the variable
449 exists, then it is initialized to an empty string.
450 Only string variables can be used. After the
451 redirection starts, if the variable is removed or
452 locked or the variable type is changed, then further
453 command output messages will cause errors. {not in Vi}
454
455:redi[r] =>> {var} Append messages to an existing variable. Only string
456 variables can be used. {not in Vi}
457
Bram Moolenaar071d4272004-06-13 20:20:40 +0000458:redi[r] END End redirecting messages. {not in Vi}
459
460 *:sil* *:silent*
461:sil[ent][!] {command} Execute {command} silently. Normal messages will not
462 be given or added to the message history.
463 When [!] is added, error messages will also be
464 skipped, and commands and mappings will not be aborted
465 when an error is detected. |v:errmsg| is still set.
466 When [!] is not used, an error message will cause
467 further messages to be displayed normally.
468 Redirection, started with |:redir|, will continue as
469 usual, although there might be small differences.
470 This will allow redirecting the output of a command
471 without seeing it on the screen. Example: >
472 :redir >/tmp/foobar
473 :silent g/Aap/p
474 :redir END
475< To execute a Normal mode command silently, use the
476 |:normal| command. For example, to search for a
477 string without messages: >
478 :silent exe "normal /path\<CR>"
479< ":silent!" is useful to execute a command that may
480 fail, but the failure is to be ignored. Example: >
481 :let v:errmsg = ""
482 :silent! /^begin
483 :if v:errmsg != ""
484 : ... pattern was not found
485< ":silent" will also avoid the hit-enter prompt. When
486 using this for an external command, this may cause the
487 screen to be messed up. Use |CTRL-L| to clean it up
488 then.
489 ":silent menu ..." defines a menu that will not echo a
490 Command-line command. The command will still produce
491 messages though. Use ":silent" in the command itself
492 to avoid that: ":silent menu .... :silent command".
493
494 *:verb* *:verbose*
495:[count]verb[ose] {command}
496 Execute {command} with 'verbose' set to [count]. If
Bram Moolenaared203462004-06-16 11:19:22 +0000497 [count] is omitted one is used. ":0verbose" can be
498 used to set 'verbose' to zero.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499 The additional use of ":silent" makes messages
500 generated but not displayed.
501 The combination of ":silent" and ":verbose" can be
502 used to generate messages and check them with
503 |v:statusmsg| and friends. For example: >
504 :let v:statusmsg = ""
505 :silent verbose runtime foobar.vim
506 :if v:statusmsg != ""
507 : " foobar.vim could not be found
508 :endif
509< When concatenating another command, the ":verbose"
510 only applies to the first one: >
511 :4verbose set verbose | set verbose
512< verbose=4 ~
513 verbose=0 ~
Bram Moolenaar54ee7752005-05-31 22:22:17 +0000514 For logging verbose messages in a file use the
515 'verbosefile' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000516
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000517 *:verbose-cmd*
518When 'verbose' is non-zero, listing the value of a Vim option or a key map or
Bram Moolenaare344bea2005-09-01 20:46:49 +0000519an abbreviation or a user-defined function or a command or a highlight group
520or an autocommand will also display where it was last defined. If it was
521defined manually then there will be no "Last set" message. When it was
522defined while executing a function, user command or autocommand, the script in
523which it was defined is reported.
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000524{not available when compiled without the +eval feature}
525
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 *K*
527K Run a program to lookup the keyword under the
528 cursor. The name of the program is given with the
529 'keywordprg' (kp) option (default is "man"). The
530 keyword is formed of letters, numbers and the
531 characters in 'iskeyword'. The keyword under or
532 right of the cursor is used. The same can be done
533 with the command >
534 :!{program} {keyword}
535< There is an example of a program to use in the tools
536 directory of Vim. It is called 'ref' and does a
537 simple spelling check.
538 Special cases:
539 - If 'keywordprg' is empty, the ":help" command is
540 used. It's a good idea to include more characters
541 in 'iskeyword' then, to be able to find more help.
542 - When 'keywordprg' is equal to "man", a count before
543 "K" is inserted after the "man" command and before
544 the keyword. For example, using "2K" while the
545 cursor is on "mkdir", results in: >
546 !man 2 mkdir
547< - When 'keywordprg' is equal to "man -s", a count
548 before "K" is inserted after the "-s". If there is
549 no count, the "-s" is removed.
550 {not in Vi}
551
552 *v_K*
553{Visual}K Like "K", but use the visually highlighted text for
554 the keyword. Only works when the highlighted text is
555 not more than one line. {not in Vi}
556
557[N]gs *gs* *:sl* *:sleep*
558:[N]sl[eep] [N] [m] Do nothing for [N] seconds. When [m] is included,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000559 sleep for [N] milliseconds. The count for "gs" always
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 uses seconds. The default is one second. >
561 :sleep "sleep for one second
562 :5sleep "sleep for five seconds
563 :sleep 100m "sleep for a hundred milliseconds
564 10gs "sleep for ten seconds
565< Can be interrupted with CTRL-C (CTRL-Break on MS-DOS).
Bram Moolenaar677ee682005-01-27 14:41:15 +0000566 "gs" stands for "goto sleep".
567 While sleeping the cursor is positioned in the text,
568 if at a visible position. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569
570 *g_CTRL-A*
571g CTRL-A Only when Vim was compiled with MEM_PROFILING defined
572 (which is very rare): print memory usage statistics.
573 Only useful for debugging Vim.
574
575==============================================================================
5762. Online help *online-help*
577
578 *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
579<Help> or
580:h[elp] Open a window and display the help file in read-only
581 mode. If there is a help window open already, use
582 that one. Otherwise, if the current window uses the
583 full width of the screen or is at least 80 characters
584 wide, the help window will appear just above the
585 current window. Otherwise the new window is put at
586 the very top.
587 The 'helplang' option is used to select a language, if
588 the main help file is available in several languages.
589 {not in Vi}
590
591 *{subject}* *E149* *E661*
592:h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
593 {subject} can include wildcards like "*", "?" and
594 "[a-z]":
595 :help z? jump to help for any "z" command
596 :help z. jump to the help for "z."
597 If there is no full match for the pattern, or there
598 are several matches, the "best" match will be used.
599 A sophisticated algorithm is used to decide which
600 match is better than another one. These items are
601 considered in the computation:
602 - A match with same case is much better than a match
603 with different case.
604 - A match that starts after a non-alphanumeric
605 character is better than a match in the middle of a
606 word.
607 - A match at or near the beginning of the tag is
608 better than a match further on.
609 - The more alphanumeric characters match, the better.
610 - The shorter the length of the match, the better.
611
612 The 'helplang' option is used to select a language, if
613 the {subject} is available in several languages.
614 To find a tag in a specific language, append "@ab",
615 where "ab" is the two-letter language code. See
616 |help-translated|.
617
618 Note that the longer the {subject} you give, the less
619 matches will be found. You can get an idea how this
620 all works by using commandline completion (type CTRL-D
621 after ":help subject").
622 If there are several matches, you can have them listed
623 by hitting CTRL-D. Example: >
624 :help cont<Ctrl-D>
625< To use a regexp |pattern|, first do ":help" and then
626 use ":tag {pattern}" in the help window. The
627 ":tnext" command can then be used to jump to other
628 matches, "tselect" to list matches and choose one. >
629 :help index| :tse z.
630< This command can be followed by '|' and another
631 command, but you don't need to escape the '|' inside a
632 help command. So these both work: >
633 :help |
634 :help k| only
635< Note that a space before the '|' is seen as part of
636 the ":help" argument.
637 You can also use <LF> or <CR> to separate the help
638 command from a following command. You need to type
639 CTRL-V first to insert the <LF> or <CR>. Example: >
640 :help so<C-V><CR>only
641< {not in Vi}
642
643:h[elp]! [subject] Like ":help", but in non-English help files prefer to
644 find a tag in a file with the same language as the
645 current file. See |help-translated|.
646
647 *:helpg* *:helpgrep*
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000648:helpg[rep] {pattern}[@xx]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000649 Search all help text files and make a list of lines
650 in which {pattern} matches. Jumps to the first match.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000651 The optional [@xx] specifies that only matches in the
652 "xx" language are to be found.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000653 You can navigate through the matches with the
654 |quickfix| commands, e.g., |:cnext| to jump to the
655 next one. Or use |:cwindow| to get the list of
656 matches in the quickfix window.
657 {pattern} is used as a Vim regexp |pattern|.
658 'ignorecase' is not used, add "\c" to ignore case.
659 Example for case sensitive search: >
660 :helpgrep Uganda
661< Example for case ignoring search: >
662 :helpgrep uganda\c
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000663< Example for searching in French help: >
664 :helpgrep backspace@fr
Bram Moolenaar071d4272004-06-13 20:20:40 +0000665< Cannot be followed by another command, everything is
666 used as part of the pattern. But you can use
667 |:execute| when needed.
668 Compressed help files will not be searched (Debian
669 compresses the help files).
670 {not in Vi}
671
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000672 *:lh* *:lhelpgrep*
673:lh[elpgrep] {pattern}[@xx]
674 Same as ":helpgrep", except the location list is used
675 instead of the quickfix list. If the help window is
676 already opened, then the location list for that window
677 is used. Otherwise, a new help window is opened and
678 the location list for that window is set. The
679 location list for the current window is not changed.
680
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +0000681 *:exu* *:exusage*
682:exu[sage] Show help on Ex commands. Added to simulate the Nvi
683 command. {not in Vi}
684
685 *:viu* *:viusage*
686:viu[sage] Show help on Normal mode commands. Added to simulate
687 the Nvi command. {not in Vi}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000688
689When no argument is given to |:help| the file given with the 'helpfile' option
690will be opened. Otherwise the specified tag is searched for in all "doc/tags"
691files in the directories specified in the 'runtimepath' option.
692
693The initial height of the help window can be set with the 'helpheight' option
694(default 20).
695
696Jump to specific subjects by using tags. This can be done in two ways:
697- Use the "CTRL-]" command while standing on the name of a command or option.
698 This only works when the tag is a keyword. "<C-Leftmouse>" and
699 "g<LeftMouse>" work just like "CTRL-]".
700- use the ":ta {subject}" command. This also works with non-keyword
701 characters.
702
703Use CTRL-T or CTRL-O to jump back.
704Use ":q" to close the help window.
705
706If there are several matches for an item you are looking for, this is how you
707can jump to each one of them:
7081. Open a help window
7092. Use the ":tag" command with a slash prepended to the tag. E.g.: >
710 :tag /min
7113. Use ":tnext" to jump to the next matching tag.
712
713It is possible to add help files for plugins and other items. You don't need
714to change the distributed help files for that. See |add-local-help|.
715
716To write a local help file, see |write-local-help|.
717
718Note that the title lines from the local help files are automagically added to
719the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
720This is done when viewing the file in Vim, the file itself is not changed. It
721is done by going through all help files and obtaining the first line of each
722file. The files in $VIMRUNTIME/doc are skipped.
723
724 *help-xterm-window*
725If you want to have the help in another xterm window, you could use this
726command: >
727 :!xterm -e vim +help &
728<
729
730 *:helpfind* *:helpf*
731:helpf[ind] Like |:help|, but use a dialog to enter the argument.
732 Only for backwards compatibility. It now executes the
733 ToolBar.FindHelp menu entry instead of using a builtin
734 dialog. {only when compiled with |+GUI_GTK|}
735< {not in Vi}
736
737 *:helpt* *:helptags*
738 *E154* *E150* *E151* *E152* *E153* *E670*
739:helpt[ags] {dir} Generate the help tags file(s) for directory {dir}.
740 All "*.txt" and "*.??x" files in the directory are
741 scanned for a help tag definition in between stars.
742 The "*.??x" files are for translated docs, they
743 generate the "tags-??" file, see |help-translated|.
744 The generated tags files are sorted.
745 When there are duplicates an error message is given.
746 An existing tags file is silently overwritten.
747 To rebuild the help tags in the runtime directory
748 (requires write permission there): >
749 :helptags $VIMRUNTIME/doc
750< {not in Vi}
751
752
753TRANSLATED HELP *help-translated*
754
755It is possible to add translated help files, next to the original English help
756files. Vim will search for all help in "doc" directories in 'runtimepath'.
757This is only available when compiled with the |+multi_lang| feature.
758
Bram Moolenaardb552d602006-03-23 22:59:57 +0000759At this moment translations are available for:
760 Chinese - multiple authors
761 French - translated by David Blanchet
762 Italian - translated by Antonio Colombo
Bram Moolenaar42bbef42006-03-25 22:02:07 +0000763 Polish - translated by Mikolaj Machowski
Bram Moolenaardb552d602006-03-23 22:59:57 +0000764 Russian - translated by Vassily Ragosin
765See the Vim website to find them: http://www.vim.org/translations.php
766
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767A set of translated help files consists of these files:
768
769 help.abx
770 howto.abx
771 ...
772 tags-ab
773
774"ab" is the two-letter language code. Thus for Italian the names are:
775
776 help.itx
777 howto.itx
778 ...
779 tags-it
780
781The 'helplang' option can be set to the preferred language(s). The default is
782set according to the environment. Vim will first try to find a matching tag
783in the preferred language(s). English is used when it cannot be found.
784
785To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
786two-letter language code. Example: >
787 :he user-manual@it
788 :he user-manual@en
789The first one finds the Italian user manual, even when 'helplang' is empty.
790The second one finds the English user manual, even when 'helplang' is set to
791"it".
792
793When using command-line completion for the ":help" command, the "@en"
794extention is only shown when a tag exists for multiple languages. When the
795tag only exists for English "@en" is omitted.
796
797When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
798find the tag in the same language. If not found then 'helplang' will be used
799to select a language.
800
801Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
802utf-8 when finding non-ASCII characters in the first line. Thus you must
803translate the header with "For Vim version".
804
805The same encoding must be used for the help files of one language in one
806directory. You can use a different encoding for different languages and use
807a different encoding for help files of the same language but in a different
808directory.
809
810Hints for translators:
811- Do not translate the tags. This makes it possible to use 'helplang' to
812 specify the preferred language. You may add new tags in your language.
813- When you do not translate a part of a file, add tags to the English version,
814 using the "tag@en" notation.
815- Make a package with all the files and the tags file available for download.
816 Users can drop it in one of the "doc" directories and start use it.
817 Report this to Bram, so that he can add a link on www.vim.org.
818- Use the |:helptags| command to generate the tags files. It will find all
819 languages in the specified directory.
820
821==============================================================================
Bram Moolenaareb3593b2006-04-22 22:33:57 +00008223. Using Vim like less or more *less*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000823
824If you use the less or more program to view a file, you don't get syntax
825highlighting. Thus you would like to use Vim instead. You can do this by
826using the shell script "$VIMRUNTIME/macros/less.sh".
827
828This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
829up mappings to simulate the commands that less supports. Otherwise, you can
830still use the Vim commands.
831
832This isn't perfect. For example, when viewing a short file Vim will still use
833the whole screen. But it works good enough for most uses, and you get syntax
834highlighting.
835
836The "h" key will give you a short overview of the available commands.
837
838 vim:tw=78:ts=8:ft=help:norl: