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