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