blob: 3624a7b4d068ec9a72dddb7a1fc62d5d27edfabe [file] [log] [blame]
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00001*various.txt* For Vim version 7.0aa. Last change: 2004 Jun 18
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|
113. Printing |printing|
124. Using Vim like less or more |less|
13
14==============================================================================
151. Various commands *various-cmds*
16
17 *CTRL-L*
18CTRL-L Clear and redraw the screen (later).
19
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*
70:[range]p[rint] Print [range] lines (default current line).
71 Note: If you are looking for a way to print your text
72 file, you need an external program for that. In the
73 GUI you can use the File.Print menu entry.
74 (For printing on paper see |:hardcopy|)
75
76:[range]p[rint] {count}
77 Print {count} lines, starting with [range] (default
78 current line |cmdline-ranges|).
79
80 *:P* *:Print*
81:[range]P[rint] [count]
82 Just as ":print". Was apparently added to Vi for
83 people that keep the shift key pressed too long...
84
85 *:l* *:list*
86:[range]l[ist] [count]
87 Same as :print, but display unprintable characters
88 with '^'.
89
90 *:nu* *:number*
91:[range]nu[mber] [count]
92 Same as :print, but precede each line with its line
93 number. (See also 'highlight' option).
94
95 *:#*
96:[range]# [count] synonym for :number.
97
98 *:z* *E144*
99:{range}z[+-^.=]{count} Display several lines of text surrounding the line
100 specified with {range}, or around the current line
101 if there is no {range}. If there is a {count}, that's
102 how many lines you'll see; otherwise, the current
103 window size is used.
104
105 :z can be used either alone or followed by any of
106 several punctuation marks. These have the following
107 effect:
108
109 mark first line last line new location ~
110 ---- ---------- --------- ------------
111 + current line 1 scr forward 1 scr forward
112 - 1 scr back current line current line
113 ^ 2 scr back 1 scr back 1 scr back
114 . 1/2 scr back 1/2 scr fwd 1/2 src fwd
115 = 1/2 src back 1/2 scr fwd current line
116
117 Specifying no mark at all is the same as "+".
118 If the mark is "=", a line of dashes is printed
119 around the current line.
120
121:{range}z#[+-^.=]{count} *:z#*
122 Like ":z", but number the lines.
123 {not in all versions of Vi, not with these arguments}
124
125 *:=*
126:= Print the last line number.
127
128:{range}= Prints the last line number in {range}. For example,
129 this prints the current line number: >
130 :.=
131
132:norm[al][!] {commands} *:norm* *:normal*
133 Execute Normal mode commands {commands}. This makes
134 it possible to execute Normal mode commands typed on
135 the command-line. {commands} is executed like it is
136 typed. For undo all commands are undone together.
137 If the [!] is given, mappings will not be used.
138 {commands} should be a complete command. If
139 {commands} does not finish a command, the last one
140 will be aborted as if <Esc> or <C-C> was typed.
141 The display isn't updated while ":normal" is busy.
142 This implies that an insert command must be completed
143 (to start Insert mode, see |:startinsert|). A ":"
144 command must be completed as well.
145 {commands} cannot start with a space. Put a 1 (one)
146 before it, 1 space is one space.
147 The 'insertmode' option is ignored for {commands}.
148 This command cannot be followed by another command,
149 since any '|' is considered part of the command.
150 This command can be used recursively, but the depth is
151 limited by 'maxmapdepth'.
152 When this command is called from a non-remappable
153 mapping |:noremap|, the argument can be mapped anyway.
154 An alternative is to use |:execute|, which uses an
155 expression as argument. This allows the use of
156 printable characters. Example: >
157 :exe "normal \<c-w>\<c-w>"
158< {not in Vi, of course}
159 {not available when the |+ex_extra| feature was
160 disabled at compile time}
161
162:{range}norm[al][!] {commands} *:normal-range*
163 Execute Normal mode commands {commands} for each line
164 in the {range}. Before executing the {commands}, the
165 cursor is positioned in the first column of the range,
166 for each line. Otherwise it's the same as the
167 ":normal" command without a range.
168 {not in Vi}
169 Not available when |+ex_extra| feature was disabled at
170 compile time.
171
172 *:sh* *:shell* *E371*
173:sh[ell] This command starts a shell. When the shell exits
174 (after the "exit" command) you return to Vim. The
175 name for the shell command comes from 'shell' option.
176 *E360*
177 Note: This doesn't work when Vim on the Amiga was
178 started in QuickFix mode from a compiler, because the
179 compiler will have set stdin to a non-interactive
180 mode.
181
182 *:!cmd* *:!* *E34*
183:!{cmd} Execute {cmd} with the shell. See also the 'shell'
184 and 'shelltype' option.
185 Any '!' in {cmd} is replaced with the previous
186 external command (see also 'cpoptions'). But not when
187 there is a backslash before the '!', then that
188 backslash is removed. Example: ":!ls" followed by
189 ":!echo ! \! \\!" executes "echo ls ! \!".
190 After the command has been executed, the timestamp of
191 the current file is checked |timestamp|.
192 There cannot be a '|' in {cmd}, see |:bar|.
193 A newline character ends {cmd}, what follows is
194 interpreted as a following ":" command. However, if
195 there is a backslash before the newline it is removed
196 and {cmd} continues. It doesn't matter how many
197 backslashes are before the newline, only one is
198 removed.
199 On Unix the command normally runs in a non-interactive
200 shell. If you want an interactive shell to be used
201 (to use aliases) set 'shellcmdflag' to "-ic".
202 For Win32 also see |:!start|.
203 Vim redraws the screen after the command is finished,
204 because it may have printed any text. This requires a
205 hit-enter prompt, so that you can read any messages.
206 To avoid this use: >
207 :silent !{cmd}
208< The screen is not redrawn then, thus you have to use
209 CTRL-L or ":redraw!" if the command did display
210 something.
211 Also see |shell-window|.
212
213 *:!!*
214:!! Repeat last ":!{cmd}".
215
216 *:ve* *:version*
217:ve[rsion] Print the version number of the editor. If the
218 compiler used understands "__DATE__" the compilation
219 date is mentioned. Otherwise a fixed release-date is
220 shown.
221 The following lines contain information about which
222 features were enabled when Vim was compiled. When
223 there is a preceding '+', the feature is included,
224 when there is a '-' it is excluded. To change this,
225 you have to edit feature.h and recompile Vim.
226 To check for this in an expression, see |has()|.
227 Here is an overview of the features.
228 The first column shows the smallest version in which
229 they are included:
230 T tiny
231 S small
232 N normal
233 B big
234 H huge
235 m manually enabled or depends on other features
236 (none) system dependent
237 Thus if a feature is marked with "N", it is included
238 in the normal, big and huge versions of Vim.
239
240 *+feature-list*
241 *+ARP* Amiga only: ARP support included
242B *+arabic* |Arabic| language support
243N *+autocmd* |:autocmd|, automatic commands
244m *+balloon_eval* |balloon-eval| support
245N *+browse* |:browse| command
246N *+builtin_terms* some terminals builtin |builtin-terms|
247B *++builtin_terms* maximal terminals builtin |builtin-terms|
248N *+byte_offset* support for 'o' flag in 'statusline' option, "go"
249 and ":goto" commands.
250N *+cindent* |'cindent'|, C indenting
251N *+clientserver* Unix and Win32: Remote invocation |clientserver|
252 *+clipboard* |clipboard| support
253N *+cmdline_compl* command line completion |cmdline-completion|
254N *+cmdline_hist* command line history |cmdline-history|
255N *+cmdline_info* |'showcmd'| and |'ruler'|
256N *+comments* |'comments'| support
257N *+cryptv* encryption support |encryption|
258B *+cscope* |cscope| support
259N *+dialog_gui* Support for |:confirm| with GUI dialog.
260N *+dialog_con* Support for |:confirm| with console dialog.
261N *+dialog_con_gui* Support for |:confirm| with GUI and console dialog.
262N *+diff* |vimdiff| and 'diff'
263N *+digraphs* |digraphs| *E196*
264 *+dnd* Support for DnD into the "~ register |quote_~|.
265B *+emacs_tags* |emacs-tags| files
266N *+eval* expression evaluation |eval.txt|
267N *+ex_extra* Vim's extra Ex commands: |:center|, |:left|,
268 |:normal|, |:retab| and |:right|
269N *+extra_search* |'hlsearch'| and |'incsearch'| options.
270B *+farsi* |farsi| language
271N *+file_in_path* |gf|, |CTRL-W_f| and |<cfile>|
272N *+find_in_path* include file searches: |[I|, |:isearch|,
273 |CTRL-W_CTRL-I|, |:checkpath|, etc.
274N *+folding* |folding|
275 *+footer* |gui-footer|
276 *+fork* Unix only: |fork| shell commands
277N *+gettext* message translations |multi-lang|
278 *+GUI_Athena* Unix only: Athena |GUI|
279 *+GUI_neXtaw* Unix only: neXtaw |GUI|
280 *+GUI_BeOS* BeOS only: BeOS |GUI|
281 *+GUI_GTK* Unix only: GTK+ |GUI|
282 *+GUI_Motif* Unix only: Motif |GUI|
283 *+GUI_Photon* QNX only: Photon |GUI|
284m *+hangul_input* Hangul input support |hangul|
285 *+iconv* Compiled with the |iconv()| function, may have |/dyn|
286N *+insert_expand* |insert_expand| Insert mode completion
287N *+jumplist* |jumplist|
288B *+keymap* |'keymap'|
289B *+langmap* |'langmap'|
290N *+libcall* |libcall()|
291N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'|
292N *+lispindent* |'lisp'|
293N *+listcmds* Vim commands for the list of buffers |buffer-hidden|
294 and argument list |:argdelete|
295N *+localmap* Support for mappings local to a buffer |:map-local|
296N *+menu* |:menu|
297N *+mksession* |:mksession|
298N *+modify_fname* |filename-modifiers|
299N *+mouse* Mouse handling |mouse-using|
300N *+mouseshape* |'mouseshape'|
301B *+mouse_dec* Unix only: Dec terminal mouse handling |dec-mouse|
302N *+mouse_gpm* Unix only: Linux console mouse handling |gpm-mouse|
303B *+mouse_netterm* Unix only: netterm mouse handling |netterm-mouse|
304N *+mouse_pterm* QNX only: pterm mouse handling |qnx-terminal|
305N *+mouse_xterm* Unix only: xterm mouse handling |xterm-mouse|
306B *+multi_byte* Korean and other languages |multibyte|
307 *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
308N *+multi_lang* non-English language support |multi-lang|
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000309m *+mzscheme* Mzscheme interface |mzscheme|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000310m *+netbeans_intg* |netbeans|
311m *+ole* Win32 GUI only: |ole-interface|
312 *+osfiletype* Support for the 'osfiletype' option and filetype
313 checking in automatic commands. |autocmd-osfiletypes|
314N *+path_extra* Up/downwards search in 'path' and 'tags'
315m *+perl* Perl interface |perl|, may have |/dyn|
316 *+postscript* |:hardcopy| writes a PostScript file
317N *+printer* |:hardcopy| command
318m *+python* Python interface |python|, may have |/dyn|
319N *+quickfix* |:make| and |quickfix| commands
320B *+rightleft* Right to left typing |'rightleft'|
321m *+ruby* Ruby interface |ruby|, may have |/dyn|
322N *+scrollbind* |'scrollbind'|
323B *+signs* |:sign|
324N *+smartindent* |'smartindent'|
325m *+sniff* SniFF interface |sniff|
326N *+statusline* Options 'statusline', 'rulerformat' and special
327 formats of 'titlestring' and 'iconstring'
328m *+sun_workshop* |workshop|
329N *+syntax* Syntax highlighting |syntax|
330 *+system()* Unix only: opposite of |+fork|
331N *+tag_binary* binary searching in tags file |tag-binary-search|
332N *+tag_old_static* old method for static tags |tag-old-static|
333m *+tag_any_white* any white space allowed in tags file |tag-any-white|
334m *+tcl* Tcl interface |tcl|, may have |/dyn|
335 *+terminfo* uses |terminfo| instead of termcap
336N *+termresponse* support for |t_RV| and |v:termresponse|
337N *+textobjects* |text-objects| selection
338 *+tgetent* non-Unix only: able to use external termcap
339N *+title* Setting the window title |'title'|
340N *+toolbar* |gui-toolbar|
341N *+user_commands* User-defined commands. |user-commands|
342N *+viminfo* |'viminfo'|
343N *+vertsplit* Vertically split windows |:vsplit|
344N *+virtualedit* |'virtualedit'|
345S *+visual* Visual mode |Visual-mode|
346N *+visualextra* extra Visual mode commands |blockwise-operators|
347N *+vreplace* |gR| and |gr|
348N *+wildignore* |'wildignore'|
349N *+wildmenu* |'wildmenu'|
350S *+windows* more than one window
351m *+writebackup* |'writebackup'| is default on
352m *+xim* X input method |xim|
353 *+xfontset* X fontset support |xfontset|
354 *+xsmp* XSMP (X session management) support
355 *+xsmp_interact* interactive XSMP (X session management) support
356N *+xterm_clipboard* Unix only: xterm clipboard handling
357m *+xterm_save* save and restore xterm screen |xterm-screens|
358N *+X11* Unix only: can restore window title |X11|
359
360 */dyn* *E370* *E448*
361 To some of the features "/dyn" is added when the
362 feature is only available when the related library can
363 be dynamically loaded.
364
365:ve[rsion] {nr} Is now ignored. This was previously used to check the
366 version number of a .vimrc file. It was removed,
367 because you can now use the ":if" command for
368 version-dependent behavior. {not in Vi}
369
370 *:redi* *:redir*
371:redi[r][!] > {file} Redirect messages to file {file}. The messages which
372 are the output of commands are written to that file,
373 until redirection ends. The messages are also still
374 shown on the screen. When [!] is included, an
375 existing file is overwritten. When [!] is omitted,
376 and {file} exists, this command fails.
377 Only one ":redir" can be active at a time. Calls to
378 ":redir" will close any active redirection before
379 starting redirection to the new target.
380 To stop the messages and commands from being echoed to
381 the screen, put the commands in a function and call it
382 with ":silent call Function()".
383 {not in Vi}
384
385:redi[r] >> {file} Redirect messages to file {file}. Append if {file}
386 already exists. {not in Vi}
387
388:redi[r] @{a-zA-Z} Redirect messages to register {a-z}. Append to the
389 contents of the register if its name is given
390 uppercase {A-Z}. {not in Vi}
391
392:redi[r] @* Redirect messages to the clipboard. {not in Vi}
393
394:redi[r] @" Redirect messages to the unnamed register. {not in Vi}
395
396:redi[r] END End redirecting messages. {not in Vi}
397
398 *:sil* *:silent*
399:sil[ent][!] {command} Execute {command} silently. Normal messages will not
400 be given or added to the message history.
401 When [!] is added, error messages will also be
402 skipped, and commands and mappings will not be aborted
403 when an error is detected. |v:errmsg| is still set.
404 When [!] is not used, an error message will cause
405 further messages to be displayed normally.
406 Redirection, started with |:redir|, will continue as
407 usual, although there might be small differences.
408 This will allow redirecting the output of a command
409 without seeing it on the screen. Example: >
410 :redir >/tmp/foobar
411 :silent g/Aap/p
412 :redir END
413< To execute a Normal mode command silently, use the
414 |:normal| command. For example, to search for a
415 string without messages: >
416 :silent exe "normal /path\<CR>"
417< ":silent!" is useful to execute a command that may
418 fail, but the failure is to be ignored. Example: >
419 :let v:errmsg = ""
420 :silent! /^begin
421 :if v:errmsg != ""
422 : ... pattern was not found
423< ":silent" will also avoid the hit-enter prompt. When
424 using this for an external command, this may cause the
425 screen to be messed up. Use |CTRL-L| to clean it up
426 then.
427 ":silent menu ..." defines a menu that will not echo a
428 Command-line command. The command will still produce
429 messages though. Use ":silent" in the command itself
430 to avoid that: ":silent menu .... :silent command".
431
432 *:verb* *:verbose*
433:[count]verb[ose] {command}
434 Execute {command} with 'verbose' set to [count]. If
Bram Moolenaared203462004-06-16 11:19:22 +0000435 [count] is omitted one is used. ":0verbose" can be
436 used to set 'verbose' to zero.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437 The additional use of ":silent" makes messages
438 generated but not displayed.
439 The combination of ":silent" and ":verbose" can be
440 used to generate messages and check them with
441 |v:statusmsg| and friends. For example: >
442 :let v:statusmsg = ""
443 :silent verbose runtime foobar.vim
444 :if v:statusmsg != ""
445 : " foobar.vim could not be found
446 :endif
447< When concatenating another command, the ":verbose"
448 only applies to the first one: >
449 :4verbose set verbose | set verbose
450< verbose=4 ~
451 verbose=0 ~
452
453 *K*
454K Run a program to lookup the keyword under the
455 cursor. The name of the program is given with the
456 'keywordprg' (kp) option (default is "man"). The
457 keyword is formed of letters, numbers and the
458 characters in 'iskeyword'. The keyword under or
459 right of the cursor is used. The same can be done
460 with the command >
461 :!{program} {keyword}
462< There is an example of a program to use in the tools
463 directory of Vim. It is called 'ref' and does a
464 simple spelling check.
465 Special cases:
466 - If 'keywordprg' is empty, the ":help" command is
467 used. It's a good idea to include more characters
468 in 'iskeyword' then, to be able to find more help.
469 - When 'keywordprg' is equal to "man", a count before
470 "K" is inserted after the "man" command and before
471 the keyword. For example, using "2K" while the
472 cursor is on "mkdir", results in: >
473 !man 2 mkdir
474< - When 'keywordprg' is equal to "man -s", a count
475 before "K" is inserted after the "-s". If there is
476 no count, the "-s" is removed.
477 {not in Vi}
478
479 *v_K*
480{Visual}K Like "K", but use the visually highlighted text for
481 the keyword. Only works when the highlighted text is
482 not more than one line. {not in Vi}
483
484[N]gs *gs* *:sl* *:sleep*
485:[N]sl[eep] [N] [m] Do nothing for [N] seconds. When [m] is included,
486 sleep for [N] milliseconds. The count for "gs" always
487 uses seconds. The default is one second. >
488 :sleep "sleep for one second
489 :5sleep "sleep for five seconds
490 :sleep 100m "sleep for a hundred milliseconds
491 10gs "sleep for ten seconds
492< Can be interrupted with CTRL-C (CTRL-Break on MS-DOS).
493 "gs" stands for "goto sleep". While sleeping the
494 cursor is positioned in the text (if visible). {not
495 in Vi}
496
497 *g_CTRL-A*
498g CTRL-A Only when Vim was compiled with MEM_PROFILING defined
499 (which is very rare): print memory usage statistics.
500 Only useful for debugging Vim.
501
502==============================================================================
5032. Online help *online-help*
504
505 *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
506<Help> or
507:h[elp] Open a window and display the help file in read-only
508 mode. If there is a help window open already, use
509 that one. Otherwise, if the current window uses the
510 full width of the screen or is at least 80 characters
511 wide, the help window will appear just above the
512 current window. Otherwise the new window is put at
513 the very top.
514 The 'helplang' option is used to select a language, if
515 the main help file is available in several languages.
516 {not in Vi}
517
518 *{subject}* *E149* *E661*
519:h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
520 {subject} can include wildcards like "*", "?" and
521 "[a-z]":
522 :help z? jump to help for any "z" command
523 :help z. jump to the help for "z."
524 If there is no full match for the pattern, or there
525 are several matches, the "best" match will be used.
526 A sophisticated algorithm is used to decide which
527 match is better than another one. These items are
528 considered in the computation:
529 - A match with same case is much better than a match
530 with different case.
531 - A match that starts after a non-alphanumeric
532 character is better than a match in the middle of a
533 word.
534 - A match at or near the beginning of the tag is
535 better than a match further on.
536 - The more alphanumeric characters match, the better.
537 - The shorter the length of the match, the better.
538
539 The 'helplang' option is used to select a language, if
540 the {subject} is available in several languages.
541 To find a tag in a specific language, append "@ab",
542 where "ab" is the two-letter language code. See
543 |help-translated|.
544
545 Note that the longer the {subject} you give, the less
546 matches will be found. You can get an idea how this
547 all works by using commandline completion (type CTRL-D
548 after ":help subject").
549 If there are several matches, you can have them listed
550 by hitting CTRL-D. Example: >
551 :help cont<Ctrl-D>
552< To use a regexp |pattern|, first do ":help" and then
553 use ":tag {pattern}" in the help window. The
554 ":tnext" command can then be used to jump to other
555 matches, "tselect" to list matches and choose one. >
556 :help index| :tse z.
557< This command can be followed by '|' and another
558 command, but you don't need to escape the '|' inside a
559 help command. So these both work: >
560 :help |
561 :help k| only
562< Note that a space before the '|' is seen as part of
563 the ":help" argument.
564 You can also use <LF> or <CR> to separate the help
565 command from a following command. You need to type
566 CTRL-V first to insert the <LF> or <CR>. Example: >
567 :help so<C-V><CR>only
568< {not in Vi}
569
570:h[elp]! [subject] Like ":help", but in non-English help files prefer to
571 find a tag in a file with the same language as the
572 current file. See |help-translated|.
573
574 *:helpg* *:helpgrep*
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000575:helpg[rep] {pattern}[@xx]
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576 Search all help text files and make a list of lines
577 in which {pattern} matches. Jumps to the first match.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000578 The optional [@xx] specifies that only matches in the
579 "xx" language are to be found.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580 You can navigate through the matches with the
581 |quickfix| commands, e.g., |:cnext| to jump to the
582 next one. Or use |:cwindow| to get the list of
583 matches in the quickfix window.
584 {pattern} is used as a Vim regexp |pattern|.
585 'ignorecase' is not used, add "\c" to ignore case.
586 Example for case sensitive search: >
587 :helpgrep Uganda
588< Example for case ignoring search: >
589 :helpgrep uganda\c
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000590< Example for searching in French help: >
591 :helpgrep backspace@fr
Bram Moolenaar071d4272004-06-13 20:20:40 +0000592< Cannot be followed by another command, everything is
593 used as part of the pattern. But you can use
594 |:execute| when needed.
595 Compressed help files will not be searched (Debian
596 compresses the help files).
597 {not in Vi}
598
599
600When no argument is given to |:help| the file given with the 'helpfile' option
601will be opened. Otherwise the specified tag is searched for in all "doc/tags"
602files in the directories specified in the 'runtimepath' option.
603
604The initial height of the help window can be set with the 'helpheight' option
605(default 20).
606
607Jump to specific subjects by using tags. This can be done in two ways:
608- Use the "CTRL-]" command while standing on the name of a command or option.
609 This only works when the tag is a keyword. "<C-Leftmouse>" and
610 "g<LeftMouse>" work just like "CTRL-]".
611- use the ":ta {subject}" command. This also works with non-keyword
612 characters.
613
614Use CTRL-T or CTRL-O to jump back.
615Use ":q" to close the help window.
616
617If there are several matches for an item you are looking for, this is how you
618can jump to each one of them:
6191. Open a help window
6202. Use the ":tag" command with a slash prepended to the tag. E.g.: >
621 :tag /min
6223. Use ":tnext" to jump to the next matching tag.
623
624It is possible to add help files for plugins and other items. You don't need
625to change the distributed help files for that. See |add-local-help|.
626
627To write a local help file, see |write-local-help|.
628
629Note that the title lines from the local help files are automagically added to
630the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
631This is done when viewing the file in Vim, the file itself is not changed. It
632is done by going through all help files and obtaining the first line of each
633file. The files in $VIMRUNTIME/doc are skipped.
634
635 *help-xterm-window*
636If you want to have the help in another xterm window, you could use this
637command: >
638 :!xterm -e vim +help &
639<
640
641 *:helpfind* *:helpf*
642:helpf[ind] Like |:help|, but use a dialog to enter the argument.
643 Only for backwards compatibility. It now executes the
644 ToolBar.FindHelp menu entry instead of using a builtin
645 dialog. {only when compiled with |+GUI_GTK|}
646< {not in Vi}
647
648 *:helpt* *:helptags*
649 *E154* *E150* *E151* *E152* *E153* *E670*
650:helpt[ags] {dir} Generate the help tags file(s) for directory {dir}.
651 All "*.txt" and "*.??x" files in the directory are
652 scanned for a help tag definition in between stars.
653 The "*.??x" files are for translated docs, they
654 generate the "tags-??" file, see |help-translated|.
655 The generated tags files are sorted.
656 When there are duplicates an error message is given.
657 An existing tags file is silently overwritten.
658 To rebuild the help tags in the runtime directory
659 (requires write permission there): >
660 :helptags $VIMRUNTIME/doc
661< {not in Vi}
662
663
664TRANSLATED HELP *help-translated*
665
666It is possible to add translated help files, next to the original English help
667files. Vim will search for all help in "doc" directories in 'runtimepath'.
668This is only available when compiled with the |+multi_lang| feature.
669
670A set of translated help files consists of these files:
671
672 help.abx
673 howto.abx
674 ...
675 tags-ab
676
677"ab" is the two-letter language code. Thus for Italian the names are:
678
679 help.itx
680 howto.itx
681 ...
682 tags-it
683
684The 'helplang' option can be set to the preferred language(s). The default is
685set according to the environment. Vim will first try to find a matching tag
686in the preferred language(s). English is used when it cannot be found.
687
688To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
689two-letter language code. Example: >
690 :he user-manual@it
691 :he user-manual@en
692The first one finds the Italian user manual, even when 'helplang' is empty.
693The second one finds the English user manual, even when 'helplang' is set to
694"it".
695
696When using command-line completion for the ":help" command, the "@en"
697extention is only shown when a tag exists for multiple languages. When the
698tag only exists for English "@en" is omitted.
699
700When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
701find the tag in the same language. If not found then 'helplang' will be used
702to select a language.
703
704Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
705utf-8 when finding non-ASCII characters in the first line. Thus you must
706translate the header with "For Vim version".
707
708The same encoding must be used for the help files of one language in one
709directory. You can use a different encoding for different languages and use
710a different encoding for help files of the same language but in a different
711directory.
712
713Hints for translators:
714- Do not translate the tags. This makes it possible to use 'helplang' to
715 specify the preferred language. You may add new tags in your language.
716- When you do not translate a part of a file, add tags to the English version,
717 using the "tag@en" notation.
718- Make a package with all the files and the tags file available for download.
719 Users can drop it in one of the "doc" directories and start use it.
720 Report this to Bram, so that he can add a link on www.vim.org.
721- Use the |:helptags| command to generate the tags files. It will find all
722 languages in the specified directory.
723
724==============================================================================
7253. Printing *printing*
726
727On MS-Windows Vim can print your text on any installed printer. On other
728systems a PostScript file is produced. This can be directly sent to a
729PostScript printer. For other printers a program like ghostscript needs to be
730used.
731
7323.1 PostScript Printing |postscript-printing|
7333.2 PostScript Printing Encoding |postscript-print-encoding|
7343.3 PostScript Printing Troubleshooting |postscript-print-trouble|
7353.4 PostScript Utilities |postscript-print-util|
7363.5 Formfeed Characters |printing-formfeed|
737
738{not in Vi}
739{only available when compiled with |+printer| feature}
740
741 *:ha* *:hardcopy* *E237* *E238* *E324*
742:[range]ha[rdcopy][!] [arguments]
743 Send [range] lines (default whole file) to the
744 printer.
745
746 On MS-Windows a dialog is displayed to allow selection
747 of printer, paper size etc. To skip the dialog, use
748 the [!]. In this case the printer defined by
749 'printdevice' is used, or, if 'printdevice' is empty,
750 the system default printer.
751
752 For systems other than MS-Windows, PostScript is
753 written in a temp file and 'printexpr' is used to
754 actually print it. Then [arguments] can be used by
755 'printexpr' through |v:cmdarg|. Otherwise [arguments]
756 is ignored. 'printoptions' can be used to specify
757 paper size, duplex, etc.
758
759:[range]ha[rdcopy][!] >{filename}
760 As above, but write the resulting PostScript in file
761 {filename}.
762 Things like "%" are expanded |cmdline-special|
763 Careful: An existing file is silently overwritten.
764 {only available when compiled with the |+postscript|
765 feature}
766 On MS-Windows use the "print to file" feature of the
767 printer driver.
768
769Progress is displayed during printing as a page number and a percentage. To
770abort printing use the interrupt key (CTRL-C or, on MS-systems, CTRL-Break).
771
772Printer output is controlled by the 'printfont' and 'printoptions' options.
773'printheader' specifies the format of a page header.
774
775The printed file is always limited to the selected margins, irrespective of
776the current window's 'wrap' or 'linebreak' settings. The "wrap" item in
777'printoptions' can be used to switch wrapping off.
778The current highlighting colors are used in the printout, with the following
779considerations:
7801) The normal background is always rendered as white (i.e. blank paper.)
7812) White text or the default foreground is rendered as black, so that it shows
782 up!
7833) If 'background' is "dark", then the colours are darkened to compensate for
784 the fact that otherwise they would be too bright to show up clearly on
785 white paper.
786
787
7883.1 PostScript Printing *postscript-printing*
789 *E455* *E456* *E457* *E624*
790Provided you have enough disk space there should be no problems generating a
791PostScript file. You need to have the runtime files correctly installed (if
792you can find the help files, they probably are).
793
794There are currently a number of limitations with PostScript printing:
795
796- 'printfont' - The font name is ignored (the Courier family is always used -
797 it should be available on all PostScript printers) but the font size is
798 used.
799
800- 'printoptions' - The duplex setting is used when generating PostScript
801 output, but it is up to the printer to take notice of the setting. If the
802 printer does not support duplex printing then it should be silently ignored.
803 Some printers, however, don't print at all.
804
805- 8-bit support - While a number of 8-bit print character encodings are
806 supported it is possible that some characters will not print. Whether a
807 character will print depends on the font in the printer knowing the
808 character. Missing characters will be replaced with an upside down question
809 mark, or a space if that character is also not known by the font. It may be
810 possible to get all the characters in an encoding to print by installing a
811 new version of the Courier font family.
812
813- Multi-byte support - Currently VIM will try to convert multi-byte characters
814 to the 8-bit encoding specified by 'printencoding' (or latin1 if it is
815 empty). Any characters that are not successfully converted are shown as
816 unknown characters. Printing will fail if VIM cannot convert the multi-byte
817 to the 8-bit encoding.
818
819
8203.2 Custom 8-bit Print Character Encodings *postscript-print-encoding*
821 *E618* *E619*
822To use your own print character encoding when printing 8-bit character data
823you need to define your own PostScript font encoding vector. Details on how
824to to define a font encoding vector is beyond the scope of this help file, but
825you can find details in the PostScript Language Reference Manual, 3rd Edition,
826published by Addison-Wesley and available in PDF form at
827http://www.adobe.com/. The following describes what you need to do for VIM to
828locate and use your print character encoding.
829
830i. Decide on a unique name for your encoding vector, one that does not clash
831 with any of the recognized or standard encoding names that VIM uses (see
832 |encoding-names| for a list), and that no one else is likely to use.
833ii. Copy $VIMRUNTIME/print/latin1.ps to the print subdirectory in your
834 'runtimepath' and rename it with your unique name.
835iii. Edit your renamed copy of latin1.ps, replacing all occurrences of latin1
836 with your unique name (don't forget the line starting %%Title:), and
837 modify the array of glyph names to define your new encoding vector. The
838 array must have exactly 256 entries or you will not be able to print!
839iv. Within VIM, set 'printencoding' to your unique encoding name and then
840 print your file. VIM will now use your custom print character encoding.
841
842VIM will report an error with the resource file if you change the order or
843content of the first 3 lines, other than the name of the encoding on the line
844starting %%Title: or the version number on the line starting %%Version:.
845
846[Technical explanation for those that know PostScript - VIM looks for a file
847with the same name as the encoding it will use when printing. The file
848defines a new PostScript Encoding resource called /VIM-name, where name is the
849print character encoding VIM will use.]
850
851
8523.3 PostScript Printing Troubleshooting *postscript-print-trouble*
853 *E621*
854Usually the only sign of a problem when printing with PostScript is that your
855printout does not appear. If you are lucky you may get a printed page that
856tells you the PostScript operator that generated the error that prevented the
857print job completing.
858
859There are a number of possible causes as to why the printing may have failed:
860
861- Wrong version of the prolog resource file. The prolog resource file
862 contains some PostScript that VIM needs to be able to print. Each version
863 of VIM needs one particular version. Make sure you have correctly installed
864 the runtime files, and don't have any old versions of a file called prolog
865 in the print directory in your 'runtimepath' directory.
866
867- Paper size. Some PostScript printers will abort printing a file if they do
868 not support the requested paper size. By default VIM uses A4 paper. Find
869 out what size paper your printer normally uses and set the appropriate paper
870 size with 'printoptions'. If you cannot find the name of the paper used,
871 measure a sheet and compare it with the table of supported paper sizes listed
872 for 'printoptions', using the paper that is closest in both width AND height.
873 Note: The dimensions of actual paper may vary slightly from the ones listed.
874 If there is no paper listed close enough, then you may want to try psresize
875 from PSUtils, discussed below.
876
877- Two-sided printing (duplex). Normally a PostScript printer that does not
878 support two-sided printing will ignore any request to do it. However, some
879 printers may abort the job altogether. Try printing with duplex turned off.
880 Note: Duplex prints can be achieved manually using PS utils - see below.
881
882- Collated printing. As with Duplex printing, most PostScript printers that
883 do not support collating printouts will ignore a request to do so. Some may
884 not. Try printing with collation turned off.
885
886- Syntax highlighting. Some print management code may prevent the generated
887 PostScript file from being printed on a black and white printer when syntax
888 highlighting is turned on, even if solid black is the only color used. Try
889 printing with syntax highlighting turned off.
890
891A safe printoptions setting to try is: >
892
893 :set printoptions=paper:A4,duplex:off,collate:n,syntax:n
894
895Replace "A4" with the paper size that best matches your printer paper.
896
897
8983.4 PostScript Utilities *postscript-print-util*
899
9003.4.1 Ghostscript
901
902Ghostscript is a PostScript and PDF interpreter that can be used to display
903and print on non-PostScript printers PostScript and PDF files. It can also
904generate PDF files from PostScript.
905
906Ghostscript will run on a wide variety of platforms.
907
908There are three available versions:
909
910- AFPL Ghostscript (formerly Aladdin Ghostscript) which is free for
911 non-commercial use. It can be obtained from:
912
913 http://www.cs.wisc.edu/~ghost/
914
915- GNU Ghostscript which is available under the GNU General Public License. It
916 can be obtained from:
917
918 ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/gnu/
919
920- A commercial version for inclusion in commercial products.
921
922Additional information on Ghostscript can also be found at:
923
924 http://www.ghostscript.com/
925
926Support for a number of non PostScript printers is provided in the
927distribution as standard, but if you cannot find support for your printer
928check the Ghostscript site for other printers not included by default.
929
930
9313.4.2 Ghostscript Previewers.
932
933The interface to Ghostscript is very primitive so a number of graphical front
934ends have been created. These allow easier PostScript file selection,
935previewing at different zoom levels, and printing. Check supplied
936documentation for full details.
937
938X11
939
940- Ghostview. Obtainable from:
941
942 http://www.cs.wisc.edu/~ghost/gv/
943
944- gv. Derived from Ghostview. Obtainable from:
945
946 http://wwwthep.physik.uni-mainz.de/~plass/gv/
947
948 Copies (possibly not the most recent) can be found at:
949
950 http://www.cs.wisc.edu/~ghost/gv/
951
952OpenVMS
953
954- Is apparently supported in the main code now (untested). See:
955
956 http://wwwthep.physik.uni-mainz.de/~plass/gv/
957
958Windows and OS/2
959
960- GSview. Obtainable from:
961
962 http://www.cs.wisc.edu/~ghost/gsview/
963
964DOS
965
966- ps_view. Obtainable from:
967
968 ftp://ftp.pg.gda.pl/pub/TeX/support/ps_view/
969 ftp://ftp.dante.de/tex-archive/support/ps_view/
970
971Linux
972
973- GSview. Linux version of the popular Windows and OS/2 previewer.
974 Obtainable from:
975
976 http://www.cs.wisc.edu/~ghost/gsview/
977
978- BMV. Different from Ghostview and gv in that it doesn't use X but svgalib.
979 Obtainable from:
980
981 ftp://sunsite.unc.edu/pub/Linux/apps/graphics/viewers/svga/bmv-1.2.tgz
982
983
9843.4.3 PSUtils
985
986PSUtils is a collection of utility programs for manipulating PostScript
987documents. Binary distributions are available for many platforms, as well as
988the full source. PSUtils can be found at:
989
990 http://knackered.org/angus/psutils
991
992The utilities of interest include:
993
994- psnup. Convert PS files for N-up printing.
995- psselect. Select page range and order of printing.
996- psresize. Change the page size.
997- psbook. Reorder and lay out pages ready for making a book.
998
999The output of one program can be used as the input to the next, allowing for
1000complex print document creation.
1001
1002
1003N-UP PRINTING
1004
1005The psnup utility takes an existing PostScript file generated from VIM and
1006convert it to an n-up version. The simplest way to create a 2-up printout is
1007to first create a PostScript file with: >
1008
1009 :hardcopy > test.ps
1010
1011Then on your command line execute: >
1012
1013 psnup -n 2 test.ps final.ps
1014
1015Note: You may get warnings from some Ghostscript previewers for files produced
1016by psnup - these may safely be ignored.
1017
1018Finally print the file final.ps to your PostScript printer with your
1019platform's print command. (You will need to delete the two PostScript files
1020afterwards yourself.) 'printexpr' could be modified to perform this extra
1021step before printing.
1022
1023
1024ALTERNATE DUPLEX PRINTING
1025
1026It is possible to achieve a poor man's version of duplex printing using the PS
1027utility psselect. This utility has options -e and -o for printing just the
1028even or odd pages of a PS file respectively.
1029
1030First generate a PS file with the 'hardcopy' command, then generate a new
1031files with all the odd and even numbered pages with: >
1032
1033 psselect -o test.ps odd.ps
1034 psselect -e test.ps even.ps
1035
1036Next print odd.ps with your platform's normal print command. Then take the
1037print output, turn it over and place it back in the paper feeder. Now print
1038even.ps with your platform's print command. All the even pages should now
1039appear on the back of the odd pages.
1040
1041There a couple of points to bear in mind:
1042
10431. Position of the first page. If the first page is on top of the printout
1044 when printing the odd pages then you need to reverse the order that the odd
1045 pages are printed. This can be done with the -r option to psselect. This
1046 will ensure page 2 is printed on the back of page 1.
1047 Note: it is better to reverse the odd numbered pages rather than the even
1048 numbered in case there are an odd number of pages in the original PS file.
1049
10502. Paper flipping. When turning over the paper with the odd pages printed on
1051 them you may have to either flip them horizontally (along the long edge) or
1052 vertically (along the short edge), as well as possibly rotating them 180
1053 degrees. All this depends on the printer - it will be more obvious for
1054 desktop ink jets than for small office laser printers where the paper path
1055 is hidden from view.
1056
1057
10583.5 Formfeed Characters *printing-formfeed*
1059
1060By default VIM does not do any special processing of |formfeed| control
1061characters. Setting the 'printoptions' formfeed item will make VIM recognize
1062formfeed characters and continue printing the current line at the beginning
1063of the first line on a new page. The use of formfeed characters provides
1064rudimentary print control but there are certain things to be aware of.
1065
1066VIM will always start printing a line (including a line number if enabled)
1067containing a formfeed character, even if it is the first character on the
1068line. This means if a line starting with a formfeed character is the first
1069line of a page then VIM will print a blank page.
1070
1071Since the line number is printed at the start of printing the line containing
1072the formfeed character, the remainder of the line printed on the new page
1073will not have a line number printed for it (in the same way as the wrapped
1074lines of a long line when wrap in 'printoptions' is enabled).
1075
1076If the formfeed character is the last character on a line, then printing will
1077continue on the second line of the new page, not the first. This is due to
1078VIM processing the end of the line after the formfeed character and moving
1079down a line to continue printing.
1080
1081Due to the points made above it is recommended that when formfeed character
1082processing is enabled, printing of line numbers is disabled, and that form
1083feed characters are not the last character on a line. Even then you may need
1084to adjust the number of lines before a formfeed character to prevent
1085accidental blank pages.
1086
1087==============================================================================
10884. Using Vim like less or more *less*
1089
1090If you use the less or more program to view a file, you don't get syntax
1091highlighting. Thus you would like to use Vim instead. You can do this by
1092using the shell script "$VIMRUNTIME/macros/less.sh".
1093
1094This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
1095up mappings to simulate the commands that less supports. Otherwise, you can
1096still use the Vim commands.
1097
1098This isn't perfect. For example, when viewing a short file Vim will still use
1099the whole screen. But it works good enough for most uses, and you get syntax
1100highlighting.
1101
1102The "h" key will give you a short overview of the available commands.
1103
1104 vim:tw=78:ts=8:ft=help:norl: