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