Bram Moolenaar | 5cdd0df | 2007-05-12 12:58:05 +0000 | [diff] [blame] | 1 | *vi_diff.txt* For Vim version 7.1. Last change: 2007 May 07 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Differences between Vim and Vi *vi-differences* |
| 8 | |
| 9 | Throughout the help files differences between Vim and Vi/Ex are given in |
| 10 | curly braces, like "{not in Vi}". This file only lists what has not been |
| 11 | mentioned in other files and gives an overview. |
| 12 | |
| 13 | Vim is mostly POSIX 1003.2-1 compliant. The only command known to be missing |
| 14 | is ":open". There are probably a lot of small differences (either because Vim |
| 15 | is missing something or because Posix is beside the mark). |
| 16 | |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 17 | 1. Simulated command |simulated-command| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | 2. Missing options |missing-options| |
| 19 | 3. Limits |limits| |
| 20 | 4. The most interesting additions |vim-additions| |
| 21 | 5. Other vim features |other-features| |
| 22 | 6. Command-line arguments |cmdline-arguments| |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 23 | 7. POSIX compliance |posix-compliance| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | |
| 25 | ============================================================================== |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 26 | 1. Simulated command *simulated-command* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 27 | |
Bram Moolenaar | dd2a3cd | 2007-05-05 17:10:09 +0000 | [diff] [blame] | 28 | This command is in Vi, but Vim only simulates it: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 29 | |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 30 | *:o* *:op* *:open* |
| 31 | :[range]o[pen] Works like |:visual|: end Ex mode. |
| 32 | {Vi: start editing in open mode} |
| 33 | |
| 34 | :[range]o[pen] /pattern/ As above, additionally move the cursor to the |
| 35 | column where "pattern" matches in the cursor |
| 36 | line. |
| 37 | |
| 38 | Vim does not support open mode, since it's not really useful. For those |
| 39 | situations where ":open" would start open mode Vim will leave Ex mode, which |
| 40 | allows executing the same commands, but updates the whole screen instead of |
| 41 | only one line. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 42 | |
| 43 | ============================================================================== |
| 44 | 2. Missing options *missing-options* |
| 45 | |
| 46 | These options are in the Unix Vi, but not in Vim. If you try to set one of |
| 47 | them you won't get an error message, but the value is not used and cannot be |
| 48 | printed. |
| 49 | |
| 50 | autoprint (ap) boolean (default on) *'autoprint'* *'ap'* |
| 51 | beautify (bf) boolean (default off) *'beautify'* *'bf'* |
| 52 | flash (fl) boolean (default ??) *'flash'* *'fl'* |
| 53 | graphic (gr) boolean (default off) *'graphic'* *'gr'* |
| 54 | hardtabs (ht) number (default 8) *'hardtabs'* *'ht'* |
| 55 | number of spaces that a <Tab> moves on the display |
| 56 | mesg boolean (default on) *'mesg'* |
| 57 | novice boolean (default off) *'novice'* |
| 58 | open boolean (default on) *'open'* |
| 59 | optimize (op) boolean (default off) *'optimize'* *'op'* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 60 | redraw boolean (default off) *'redraw'* |
| 61 | slowopen (slow) boolean (default off) *'slowopen'* *'slow'* |
| 62 | sourceany boolean (default off) *'sourceany'* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 63 | w300 number (default 23) *'w300'* |
| 64 | w1200 number (default 23) *'w1200'* |
| 65 | w9600 number (default 23) *'w9600'* |
| 66 | |
| 67 | ============================================================================== |
| 68 | 3. Limits *limits* |
| 69 | |
| 70 | Vim has only a few limits for the files that can be edited {Vi: can not handle |
| 71 | <Nul> characters and characters above 128, has limited line length, many other |
| 72 | limits}. |
| 73 | *E340* |
| 74 | Maximum line length On machines with 16-bit ints (Amiga and MS-DOS real |
| 75 | mode): 32767, otherwise 2147483647 characters. |
| 76 | Longer lines are split. |
| 77 | Maximum number of lines 2147483647 lines. |
| 78 | Maximum file size 2147483647 bytes (2 Gbyte) when a long integer is |
| 79 | 32 bits. Much more for 64 bit longs. Also limited |
| 80 | by available disk space for the |swap-file|. |
| 81 | *E75* |
| 82 | Length of a file path Unix and Win32: 1024 characters, otherwise 256 |
| 83 | characters (or as much as the system supports). |
| 84 | Length of an expanded string option |
| 85 | Unix and Win32: 1024 characters, otherwise 256 |
| 86 | characters |
| 87 | Maximum display width Unix and Win32: 1024 characters, otherwise 255 |
| 88 | characters |
| 89 | Maximum lhs of a mapping 50 characters. |
Bram Moolenaar | 4770d09 | 2006-01-12 23:22:24 +0000 | [diff] [blame] | 90 | Number of different highlighting types: over 30000 |
| 91 | Range of a Number variable: -2147483648 to 2147483647 (more on 64 bit |
| 92 | systems) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 93 | |
| 94 | Information for undo and text in registers is kept in memory, thus when making |
| 95 | (big) changes the amount of (virtual) memory available limits the number of |
| 96 | undo levels and the text that can be kept in registers. Other things are also |
| 97 | kept in memory: Command-line history, error messages for Quickfix mode, etc. |
| 98 | |
| 99 | Memory usage limits |
| 100 | ------------------- |
| 101 | |
| 102 | The option 'maxmem' ('mm') is used to set the maximum memory used for one |
| 103 | buffer (in kilobytes). 'maxmemtot' is used to set the maximum memory used for |
| 104 | all buffers (in kilobytes). The defaults depend on the system used. For the |
| 105 | Amiga and MS-DOS, 'maxmemtot' is set depending on the amount of memory |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 106 | available. |
| 107 | These are not hard limits, but tell Vim when to move text into a swap file. |
| 108 | If you don't like Vim to swap to a file, set 'maxmem' and 'maxmemtot' to a |
| 109 | very large value. The swap file will then only be used for recovery. If you |
| 110 | don't want a swap file at all, set 'updatecount' to 0, or use the "-n" |
| 111 | argument when starting Vim. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 112 | |
| 113 | ============================================================================== |
| 114 | 4. The most interesting additions *vim-additions* |
| 115 | |
| 116 | Vi compatibility. |'compatible'| |
| 117 | Although Vim is 99% Vi compatible, some things in Vi can be |
| 118 | considered to be a bug, or at least need improvement. But still, Vim |
| 119 | starts in a mode which behaves like the "real" Vi as much as possible. |
| 120 | To make Vim behave a little bit better, try resetting the 'compatible' |
| 121 | option: |
| 122 | :set nocompatible |
| 123 | Or start Vim with the "-N" argument: |
| 124 | vim -N |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 125 | Vim starts with 'nocompatible' automatically if you have a .vimrc |
| 126 | file. See |startup|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 127 | The 'cpoptions' option can be used to set Vi compatibility on/off for |
| 128 | a number of specific items. |
| 129 | |
| 130 | Support for different systems. |
| 131 | Vim can be used on: |
| 132 | - All Unix systems (it works on all systems it was tested on, although |
| 133 | the GUI and Perl interface may not work everywhere). |
| 134 | - Amiga (500, 1000, 1200, 2000, 3000, 4000, ...). |
| 135 | - MS-DOS in real-mode (no additional drivers required). |
| 136 | - In protected mode on Windows 3.1 and MS-DOS (DPMI driver required). |
| 137 | - Windows 95 and Windows NT, with support for long file names. |
| 138 | - OS/2 (needs emx.dll) |
| 139 | - Atari MiNT |
| 140 | - VMS |
| 141 | - BeOS |
| 142 | - Macintosh |
| 143 | - Risc OS |
| 144 | - IBM OS/390 |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 145 | Note that on some systems features need to be disabled to reduce |
| 146 | resource usage, esp. on MS-DOS. For some outdated systems you need to |
| 147 | use an older Vim version. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 148 | |
| 149 | Multi level undo. |undo| |
| 150 | 'u' goes backward in time, 'CTRL-R' goes forward again. Set option |
| 151 | 'undolevels' to the number of changes to be remembered (default 1000). |
Bram Moolenaar | 4499d2e | 2005-04-15 20:41:38 +0000 | [diff] [blame] | 152 | Set 'undolevels' to 0 for a vi-compatible one level undo. Set it to |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 153 | -1 for no undo at all. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 154 | When all changes in a buffer have been undone, the buffer is not |
| 155 | considered changed anymore. You can exit it with :q, without <!>. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 156 | When undoing a few changes and then making a new change Vim will |
| 157 | create a branch in the undo tree. This means you can go back to any |
Bram Moolenaar | 143c38c | 2007-05-10 16:41:10 +0000 | [diff] [blame] | 158 | state of the text, there is no risk of a change causing text to be |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 159 | lost forever. |undo-tree| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 160 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 161 | Graphical User Interface (GUI). |gui| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 162 | Included support for GUI: menu's, mouse, scrollbars, etc. You can |
| 163 | define your own menus. Better support for CTRL/SHIFT/ALT keys in |
| 164 | combination with special keys and mouse. Supported for various |
| 165 | platforms, such as X11 (with Motif and Athena interfaces), GTK, Win32 |
| 166 | (Windows 95 and later), BeOS, Amiga and Macintosh. |
| 167 | |
| 168 | Multiple windows and buffers. |windows.txt| |
| 169 | Vim can split the screen into several windows, each editing a |
| 170 | different buffer or the same buffer at a different location. Buffers |
| 171 | can still be loaded (and changed) but not displayed in a window. This |
| 172 | is called a hidden buffer. Many commands and options have been added |
| 173 | for this facility. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 174 | Vim can also use multiple tab pages, each with one or more windows. A |
| 175 | line with tab labels can be used to quickly switch between these pages. |
| 176 | |tab-page| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 177 | |
| 178 | Syntax highlighting. |:syntax| |
| 179 | Vim can highlight keywords, patterns and other things. This is |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 180 | defined by a number of |:syntax| commands, and can be made to |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 181 | highlight most languages and file types. A number of files are |
| 182 | included for highlighting the most common languages, like C, C++, |
| 183 | Java, Pascal, Makefiles, shell scripts, etc. The colors used for |
| 184 | highlighting can be defined for ordinary terminals, color terminals |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 185 | and the GUI with the |:highlight| command. A convenient way to do |
| 186 | this is using a |:colorscheme| command. |
| 187 | The highlighted text can be exported as HTML. |convert-to-HTML| |
| 188 | Other items that can be highlighted are matches with the search string |
| 189 | |'hlsearch'|, matching parens |matchparen| and the cursor line and |
| 190 | column |'cursorline'| |'cursorcolumn'|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 191 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 192 | Spell checking. |spell| |
| 193 | When the 'spell' option is set Vim will highlight spelling mistakes. |
| 194 | About 40 languages are currently supported, selected with the |
| 195 | 'spellang' option. In source code only comments and strings are |
| 196 | checked for spelling. |
| 197 | |
| 198 | Folding. |folding| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 199 | A range of lines can be shown as one "folded" line. This allows |
| 200 | overviewing a file and moving blocks of text around quickly. |
| 201 | Folds can be created manually, from the syntax of the file, by indent, |
| 202 | etc. |
| 203 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 204 | Diff mode. |diff| |
| 205 | Vim can show two versions of a file with the differences highlighted. |
| 206 | Parts of the text that are equal are folded away. Commands can be |
| 207 | used to move text from one version to the other. |
| 208 | |
| 209 | Plugins. |add-plugin| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 210 | The functionality can be extended by dropping a plugin file in the |
| 211 | right directory. That's an easy way to start using Vim scripts |
| 212 | written by others. Plugins can be for all kind of files, or |
| 213 | specifically for a filetype. |
| 214 | |
| 215 | Repeat a series of commands. |q| |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 216 | "q{c}" starts recording typed characters into named register {c}. |
| 217 | A subsequent "q" stops recording. The register can then be executed |
| 218 | with the "@{c}" command. This is very useful to repeat a complex |
| 219 | action. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 220 | |
| 221 | Flexible insert mode. |ins-special-special| |
| 222 | The arrow keys can be used in insert mode to move around in the file. |
| 223 | This breaks the insert in two parts as far as undo and redo is |
| 224 | concerned. |
| 225 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 226 | CTRL-O can be used to execute a single Normal mode command. This is |
| 227 | almost the same as hitting <Esc>, typing the command and doing |a|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 228 | |
| 229 | Visual mode. |Visual-mode| |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 230 | Visual mode can be used to first highlight a piece of text and then |
| 231 | give a command to do something with it. This is an (easy to use) |
| 232 | alternative to first giving the operator and then moving to the end of |
| 233 | the text to be operated upon. |
| 234 | |v| and |V| are used to start Visual mode. |v| works on characters |
| 235 | and |V| on lines. Move the cursor to extend the Visual area. It is |
| 236 | shown highlighted on the screen. By typing "o" the other end of the |
| 237 | Visual area can be moved. The Visual area can be affected by an |
| 238 | operator: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 239 | d delete |
| 240 | c change |
| 241 | y yank |
| 242 | > or < insert or delete indent |
| 243 | ! filter through external program |
| 244 | = filter through indent |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 245 | : start |:| command for the Visual lines. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 246 | gq format text to 'textwidth' columns |
| 247 | J join lines |
| 248 | ~ swap case |
| 249 | u make lowercase |
| 250 | U make uppercase |
| 251 | |
| 252 | Block operators. |visual-block| |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 253 | With Visual mode a rectangular block of text can be selected. Start |
| 254 | Visual mode with CTRL-V. The block can be deleted ("d"), yanked ("y") |
| 255 | or its case can be changed ("~", "u" and "U"). A deleted or yanked |
| 256 | block can be put into the text with the "p" and "P" commands. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 257 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 258 | Help system. |:help| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 259 | Help is displayed in a window. The usual commands can be used to |
| 260 | move around, search for a string, etc. Tags can be used to jump |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 261 | around in the help files, just like hypertext links. The |:help| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 262 | command takes an argument to quickly jump to the info on a subject. |
| 263 | <F1> is the quick access to the help system. The name of the help |
| 264 | index file can be set with the 'helpfile' option. |
| 265 | |
| 266 | Command-line editing and history. |cmdline-editing| |
| 267 | You can insert or delete at any place in the command-line using the |
| 268 | cursor keys. The right/left cursor keys can be used to move |
| 269 | forward/backward one character. The shifted right/left cursor keys |
| 270 | can be used to move forward/backward one word. CTRL-B/CTRL-E can be |
| 271 | used to go to the begin/end of the command-line. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 272 | |cmdline-history| |
| 273 | The command-lines are remembered. The up/down cursor keys can be used |
| 274 | to recall previous command-lines. The 'history' option can be set to |
| 275 | the number of lines that will be remembered. There is a separate |
| 276 | history for commands and for search patterns. |
| 277 | |
| 278 | Command-line completion. |cmdline-completion| |
| 279 | While entering a command-line (on the bottom line of the screen) |
| 280 | <Tab> can be typed to complete |
| 281 | what example ~ |
| 282 | - command :e<Tab> |
| 283 | - tag :ta scr<Tab> |
| 284 | - option :set sc<Tab> |
| 285 | - option value :set hf=<Tab> |
| 286 | - file name :e ve<Tab> |
| 287 | - etc. |
| 288 | |
| 289 | If there are multiple matches, CTRL-N (next) and CTRL-P (previous) |
| 290 | will walk through the matches. <Tab> works like CTRL-N, but wraps |
| 291 | around to the first match. |
| 292 | |
| 293 | The 'wildchar' option can be set to the character for command-line |
| 294 | completion, <Tab> is the default. CTRL-D can be typed after an |
| 295 | (incomplete) wildcard; all matches will be listed. CTRL-A will insert |
| 296 | all matches. CTRL-L will insert the longest common part of the |
| 297 | matches. |
| 298 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 299 | Insert-mode completion. |ins-completion| |
| 300 | In Insert mode the CTRL-N and CTRL-P keys can be used to complete a |
| 301 | word that appears elsewhere. |i_CTRL-N| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 302 | With CTRL-X another mode is entered, through which completion can be |
| 303 | done for: |
| 304 | |i_CTRL-X_CTRL-F| file names |
| 305 | |i_CTRL-X_CTRL-K| words from 'dictionary' files |
| 306 | |i_CTRL-X_CTRL-T| words from 'thesaurus' files |
| 307 | |i_CTRL-X_CTRL-I| words from included files |
| 308 | |i_CTRL-X_CTRL-L| whole lines |
| 309 | |i_CTRL-X_CTRL-]| words from the tags file |
| 310 | |i_CTRL-X_CTRL-D| definitions or macros |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 311 | |i_CTRL-X_CTRL-O| Omni completion: clever completion |
| 312 | specifically for a file type |
| 313 | etc. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 314 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 315 | Long line support. |'wrap'| |'linebreak'| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 316 | If the 'wrap' option is off, long lines will not wrap and only part |
| 317 | of them will be shown. When the cursor is moved to a part that is not |
| 318 | shown, the screen will scroll horizontally. The minimum number of |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 319 | columns to scroll can be set with the 'sidescroll' option. The |zh| |
| 320 | and |zl| commands can be used to scroll sideways. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 321 | Alternatively, long lines are broken in between words when the |
| 322 | 'linebreak' option is set. This allows editing a single-line |
| 323 | paragraph conveniently (e.g. when the text is later read into a DTP |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 324 | program). Move the cursor up/down with the |gk| and |gj| commands. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 325 | |
| 326 | Text formatting. |formatting| |
| 327 | The 'textwidth' option can be used to automatically limit the line |
| 328 | length. This supplements the 'wrapmargin' option of Vi, which was not |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 329 | very useful. The |gq| operator can be used to format a piece of text |
| 330 | (for example, |gqap| formats the current paragraph). Commands for |
| 331 | text alignment: |:center|, |:left| and |:right|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 332 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 333 | Extended search patterns. |pattern| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 334 | There are many extra items to match various text items. Examples: |
| 335 | A "\n" can be used in a search pattern to match a line break. |
| 336 | "x\{2,4}" matches "x" 2 to 4 times. |
| 337 | "\s" matches a white space character. |
| 338 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 339 | Directory, remote and archive browsing. |netrw| |
| 340 | Vim can browse the file system. Simply edit a directory. Move around |
| 341 | in the list with the usual commands and press <Enter> to go to the |
| 342 | directory or file under the cursor. |
| 343 | This also works for remote files over ftp, http, ssh, etc. |
| 344 | Zip and tar archives can also be browsed. |tar| |zip| |
| 345 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 346 | Edit-compile-edit speedup. |quickfix| |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 347 | The |:make| command can be used to run the compilation and jump to the |
| 348 | first error. A file with compiler error messages is interpreted. Vim |
| 349 | jumps to the first error. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 350 | |
| 351 | Each line in the error file is scanned for the name of a file, line |
| 352 | number and error message. The 'errorformat' option can be set to a |
| 353 | list of scanf-like strings to handle output from many compilers. |
| 354 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 355 | The |:cn| command can be used to jump to the next error. |
| 356 | |:cl| lists all the error messages. Other commands are available. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 357 | The 'makeef' option has the name of the file with error messages. |
| 358 | The 'makeprg' option contains the name of the program to be executed |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 359 | with the |:make| command. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 360 | The 'shellpipe' option contains the string to be used to put the |
| 361 | output of the compiler into the errorfile. |
| 362 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 363 | Finding matches in files. |:vimgrep| |
| 364 | Vim can search for a pattern in multiple files. This uses the |
| 365 | advanced Vim regexp pattern, works on all systems and also works to |
| 366 | search in compressed files. |
| 367 | |
| 368 | Improved indenting for programs. |'cindent'| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 369 | When the 'cindent' option is on the indent of each line is |
| 370 | automatically adjusted. C syntax is mostly recognized. The indent |
| 371 | for various styles can be set with 'cinoptions'. The keys to trigger |
| 372 | indenting can be set with 'cinkeys'. |
| 373 | |
| 374 | Comments can be automatically formatted. The 'comments' option can be |
| 375 | set to the characters that start and end a comment. This works best |
| 376 | for C code, but also works for e-mail (">" at start of the line) and |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 377 | other types of text. The |=| operator can be used to re-indent |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 378 | lines. |
| 379 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 380 | For many other languages an indent plugin is present to support |
| 381 | automatic indenting. |30.3| |
| 382 | |
| 383 | Searching for words in included files. |include-search| |
| 384 | The |[i| command can be used to search for a match of the word under |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 385 | the cursor in the current and included files. The 'include' option |
| 386 | can be set the a pattern that describes a command to include a file |
| 387 | (the default is for C programs). |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 388 | The |[I| command lists all matches, the |[_CTRL-I| command jumps to |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 389 | a match. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 390 | The |[d|, |[D| and |[_CTRL-D| commands do the same, but only for |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 391 | lines where the pattern given with the 'define' option matches. |
| 392 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 393 | Automatic commands. |autocommand| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 394 | Commands can be automatically executed when reading a file, writing a |
| 395 | file, jumping to another buffer, etc., depending on the file name. |
| 396 | This is useful to set options and mappings for C programs, |
| 397 | documentation, plain text, e-mail, etc. This also makes it possible |
| 398 | to edit compressed files. |
| 399 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 400 | Scripts and Expressions. |expression| |
| 401 | Commands have been added to form up a powerful script language. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 402 | |:if| Conditional execution, which can be used for example |
| 403 | to set options depending on the value of $TERM. |
| 404 | |:while| Repeat a number of commands. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 405 | |:for| Loop over a list. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 406 | |:echo| Print the result of an expression. |
| 407 | |:let| Assign a value to an internal variable, option, etc. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 408 | Variable types are Number, String, List and Dictionary. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 409 | |:execute| Execute a command formed by an expression. |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 410 | |:try| Catch exceptions. |
| 411 | etc., etc. See |eval|. |
| 412 | Debugging and profiling are supported. |debug-scripts| |profile| |
| 413 | If this is not enough, an interface is provided to |Python|, |Ruby|, |
| 414 | |Tcl|, |Perl| and |MzScheme|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 415 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 416 | Viminfo. |viminfo-file| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 417 | The command-line history, marks and registers can be stored in a file |
| 418 | that is read on startup. This can be used to repeat a search command |
| 419 | or command-line command after exiting and restarting Vim. It is also |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 420 | possible to jump right back to where the last edit stopped with |'0|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 421 | The 'viminfo' option can be set to select which items to store in the |
| 422 | .viminfo file. This is off by default. |
| 423 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 424 | Printing. |printing| |
| 425 | The |:hardcopy| command sends text to the printer. This can include |
| 426 | syntax highlighting. |
| 427 | |
| 428 | Mouse support. |mouse-using| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 429 | The mouse is supported in the GUI version, in an xterm for Unix, for |
| 430 | Linux with gpm, for MS-DOS, and Win32. It can be used to position the |
| 431 | cursor, select the visual area, paste a register, etc. |
| 432 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 433 | Usage of key names. |<>| |key-notation| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 434 | Special keys now all have a name like <Up>, <End>, etc. |
| 435 | This name can be used in mappings, to make it easy to edit them. |
| 436 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 437 | Editing binary files. |edit-binary| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 438 | Vim can edit binary files. You can change a few characters in an |
| 439 | executable file, without corrupting it. Vim doesn't remove NUL |
| 440 | characters (they are represented as <NL> internally). |
| 441 | |-b| command-line argument to start editing a binary file |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 442 | |'binary'| Option set by |-b|. Prevents adding an <EOL> for the |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 443 | last line in the file. |
| 444 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 445 | Multi-language support. |multi-lang| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 446 | Files in double-byte or multi-byte encodings can be edited. There is |
| 447 | UTF-8 support to be able to edit various languages at the same time, |
| 448 | without switching fonts. |UTF-8| |
| 449 | Messages and menus are available in different languages. |
| 450 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 451 | Move cursor beyond lines. |
| 452 | When the 'virtualedit' option is set the cursor can move all over the |
| 453 | screen, also where there is no text. This is useful to edit tables |
| 454 | and figures easily. |
| 455 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 456 | ============================================================================== |
| 457 | 5. Other vim features *other-features* |
| 458 | |
| 459 | A random collection of nice extra features. |
| 460 | |
| 461 | |
| 462 | When Vim is started with "-s scriptfile", the characters read from |
| 463 | "scriptfile" are treated as if you typed them. If end of file is reached |
| 464 | before the editor exits, further characters are read from the console. |
| 465 | |
| 466 | The "-w" option can be used to record all typed characters in a script file. |
| 467 | This file can then be used to redo the editing, possibly on another file or |
| 468 | after changing some commands in the script file. |
| 469 | |
| 470 | The "-o" option opens a window for each argument. "-o4" opens four windows. |
| 471 | |
| 472 | Vi requires several termcap entries to be able to work full-screen. Vim only |
| 473 | requires the "cm" entry (cursor motion). |
| 474 | |
| 475 | |
| 476 | In command mode: |
| 477 | |
| 478 | When the 'showcmd' option is set, the command characters are shown in the last |
| 479 | line of the screen. They are removed when the command is finished. |
| 480 | |
| 481 | If the 'ruler' option is set, the current cursor position is shown in the |
| 482 | last line of the screen. |
| 483 | |
| 484 | "U" still works after having moved off the last changed line and after "u". |
| 485 | |
| 486 | Characters with the 8th bit set are displayed. The characters between '~' and |
| 487 | 0xa0 are displayed as "~?", "~@", "~A", etc., unless they are included in the |
| 488 | 'isprint' option. |
| 489 | |
| 490 | "][" goes to the next ending of a C function ('}' in column 1). |
| 491 | "[]" goes to the previous ending of a C function ('}' in column 1). |
| 492 | |
| 493 | "]f", "[f" and "gf" start editing the file whose name is under the cursor. |
| 494 | CTRL-W f splits the window and starts editing the file whose name is under |
| 495 | the cursor. |
| 496 | |
| 497 | "*" searches forward for the identifier under the cursor, "#" backward. |
| 498 | "K" runs the program defined by the 'keywordprg' option, with the identifier |
| 499 | under the cursor as argument. |
| 500 | |
| 501 | "%" can be preceded with a count. The cursor jumps to the line that |
| 502 | percentage down in the file. The normal "%" function to jump to the matching |
| 503 | brace skips braces inside quotes. |
| 504 | |
| 505 | With the CTRL-] command, the cursor may be in the middle of the identifier. |
| 506 | |
| 507 | The used tags are remembered. Commands that can be used with the tag stack |
| 508 | are CTRL-T, ":pop" and ":tag". ":tags" lists the tag stack. |
| 509 | |
| 510 | The 'tags' option can be set to a list of tag file names. Thus multiple |
| 511 | tag files can be used. For file names that start with "./", the "./" is |
| 512 | replaced with the path of the current file. This makes it possible to use a |
| 513 | tags file in the same directory as the file being edited. |
| 514 | |
| 515 | Previously used file names are remembered in the alternate file name list. |
| 516 | CTRL-^ accepts a count, which is an index in this list. |
| 517 | ":files" command shows the list of alternate file names. |
| 518 | "#<N>" is replaced with the <N>th alternate file name in the list. |
| 519 | "#<" is replaced with the current file name without extension. |
| 520 | |
| 521 | Search patterns have more features. The <NL> character is seen as part of the |
| 522 | search pattern and the substitute string of ":s". Vi sees it as the end of |
| 523 | the command. |
| 524 | |
| 525 | Searches can put the cursor on the end of a match and may include a character |
| 526 | offset. |
| 527 | |
| 528 | Count added to "~", ":next", ":Next", "n" and "N". |
| 529 | |
| 530 | The command ":next!" with 'autowrite' set does not write the file. In vi the |
| 531 | file was written, but this is considered to be a bug, because one does not |
| 532 | expect it and the file is not written with ":rewind!". |
| 533 | |
| 534 | In Vi when entering a <CR> in replace mode deletes a character only when 'ai' |
| 535 | is set (but does not show it until you hit <Esc>). Vim always deletes a |
| 536 | character (and shows it immediately). |
| 537 | |
| 538 | Added :wnext command. Same as ":write" followed by ":next". |
| 539 | |
| 540 | The ":w!" command always writes, also when the file is write protected. In Vi |
| 541 | you would have to do ":!chmod +w %" and ":set noro". |
| 542 | |
| 543 | When 'tildeop' has been set, "~" is an operator (must be followed by a |
| 544 | movement command). |
| 545 | |
| 546 | With the "J" (join) command you can reset the 'joinspaces' option to have only |
| 547 | one space after a period (Vi inserts two spaces). |
| 548 | |
| 549 | "cw" can be used to change white space formed by several characters (Vi is |
| 550 | confusing: "cw" only changes one space, while "dw" deletes all white space). |
| 551 | |
| 552 | "o" and "O" accept a count for repeating the insert (Vi clears a part of |
| 553 | display). |
| 554 | |
| 555 | Flags after Ex commands not supported (no plans to include it). |
| 556 | |
| 557 | On non-UNIX systems ":cd" command shows current directory instead of going to |
| 558 | the home directory (there isn't one). ":pwd" prints the current directory on |
| 559 | all systems. |
| 560 | |
| 561 | After a ":cd" command the file names (in the argument list, opened files) |
| 562 | still point to the same files. In Vi ":cd" is not allowed in a changed file; |
| 563 | otherwise the meaning of file names change. |
| 564 | |
| 565 | ":source!" command reads Vi commands from a file. |
| 566 | |
| 567 | ":mkexrc" command writes current modified options and mappings to a ".exrc" |
| 568 | file. ":mkvimrc" writes to a ".vimrc" file. |
| 569 | |
| 570 | No check for "tail recursion" with mappings. This allows things like |
| 571 | ":map! foo ^]foo". |
| 572 | |
| 573 | When a mapping starts with number, vi loses the count typed before it (e.g. |
| 574 | when using the mapping ":map g 4G" the command "7g" goes to line 4). This is |
| 575 | considered a vi bug. Vim concatenates the counts (in the example it becomes |
| 576 | "74G"), as most people would expect. |
| 577 | |
| 578 | The :put! command inserts the contents of a register above the current line. |
| 579 | |
| 580 | The "p" and "P" commands of vi cannot be repeated with "." when the putted |
| 581 | text is less than a line. In Vim they can always be repeated. |
| 582 | |
| 583 | ":noremap" command can be used to enter a mapping that will not be remapped. |
| 584 | This is useful to exchange the meaning of two keys. ":cmap", ":cunmap" and |
| 585 | ":cnoremap" can be used for mapping in command-line editing only. ":imap", |
| 586 | ":iunmap" and ":inoremap" can be used for mapping in insert mode only. |
| 587 | Similar commands exist for abbreviations: ":noreabbrev", ":iabbrev" |
| 588 | ":cabbrev", ":iunabbrev", ":cunabbrev", ":inoreabbrev", ":cnoreabbrev". |
| 589 | |
| 590 | In Vi the command ":map foo bar" would remove a previous mapping |
| 591 | ":map bug foo". This is considered a bug, so it is not included in Vim. |
| 592 | ":unmap! foo" does remove ":map! bug foo", because unmapping would be very |
| 593 | difficult otherwise (this is vi compatible). |
| 594 | |
| 595 | The ':' register contains the last command-line. |
| 596 | The '%' register contains the current file name. |
| 597 | The '.' register contains the last inserted text. |
| 598 | |
| 599 | ":dis" command shows the contents of the yank registers. |
| 600 | |
| 601 | CTRL-O/CTRL-I can be used to jump to older/newer positions. These are the |
| 602 | same positions as used with the '' command, but may be in another file. The |
| 603 | ":jumps" command lists the older positions. |
| 604 | |
| 605 | If the 'shiftround' option is set, an indent is rounded to a multiple of |
| 606 | 'shiftwidth' with ">" and "<" commands. |
| 607 | |
| 608 | The 'scrolljump' option can be set to the minimum number of lines to scroll |
| 609 | when the cursor gets off the screen. Use this when scrolling is slow. |
| 610 | |
| 611 | The 'scrolloff' option can be set to the minimum number of lines to keep |
| 612 | above and below the cursor. This gives some context to where you are |
| 613 | editing. When set to a large number the cursor line is always in the middle |
| 614 | of the window. |
| 615 | |
| 616 | Uppercase marks can be used to jump between files. The ":marks" command lists |
| 617 | all currently set marks. The commands "']" and "`]" jump to the end of the |
| 618 | previous operator or end of the text inserted with the put command. "'[" and |
| 619 | "`[" do jump to the start. |
| 620 | |
| 621 | The 'shelltype' option can be set to reflect the type of shell used on the |
| 622 | Amiga. |
| 623 | |
| 624 | The 'highlight' option can be set for the highlight mode to be used for |
| 625 | several commands. |
| 626 | |
| 627 | The CTRL-A (add) and CTRL-X (subtract) commands are new. The count to the |
| 628 | command (default 1) is added to/subtracted from the number at or after the |
| 629 | cursor. That number may be decimal, octal (starts with a '0') or hexadecimal |
| 630 | (starts with '0x'). Very useful in macros. |
| 631 | |
| 632 | With the :set command the prefix "inv" can be used to invert boolean options. |
| 633 | |
| 634 | In both Vi and Vim you can create a line break with the ":substitute" command |
| 635 | by using a CTRL-M. For Vi this means you cannot insert a real CTRL-M in the |
| 636 | text. With Vim you can put a real CTRL-M in the text by preceding it with a |
| 637 | CTRL-V. |
| 638 | |
| 639 | |
| 640 | In Insert mode: |
| 641 | |
| 642 | If the 'revins' option is set, insert happens backwards. This is for typing |
| 643 | Hebrew. When inserting normal characters the cursor will not be shifted and |
| 644 | the text moves rightwards. Backspace, CTRL-W and CTRL-U will also work in |
| 645 | the opposite direction. CTRL-B toggles the 'revins' option. In replace mode |
| 646 | 'revins' has no effect. Only when enabled at compile time. |
| 647 | |
| 648 | The backspace key can be used just like CTRL-D to remove auto-indents. |
| 649 | |
| 650 | You can backspace, CTRL-U and CTRL-W over line breaks if the 'backspace' (bs) |
| 651 | option includes "eol". You can backspace over the start of insert if the |
| 652 | 'backspace' option includes "start". |
| 653 | |
| 654 | When the 'paste' option is set, a few option are reset and mapping in insert |
| 655 | mode and abbreviation are disabled. This allows for pasting text in windowing |
| 656 | systems without unexpected results. When the 'paste' option is reset, the old |
| 657 | option values are restored. |
| 658 | |
| 659 | CTRL-T/CTRL-D always insert/delete an indent in the current line, no matter |
| 660 | what column the cursor is in. |
| 661 | |
| 662 | CTRL-@ (insert previously inserted text) works always (Vi: only when typed as |
| 663 | first character). |
| 664 | |
| 665 | CTRL-A works like CTRL-@ but does not leave insert mode. |
| 666 | |
| 667 | CTRL-R {0-9a-z..} can be used to insert the contents of a register. |
| 668 | |
| 669 | When the 'smartindent' option is set, C programs will be better auto-indented. |
| 670 | With 'cindent' even more. |
| 671 | |
| 672 | CTRL-Y and CTRL-E can be used to copy a character from above/below the |
| 673 | current cursor position. |
| 674 | |
| 675 | After CTRL-V you can enter a three digit decimal number. This byte value is |
| 676 | inserted in the text as a single character. Useful for international |
| 677 | characters that are not on your keyboard. |
| 678 | |
| 679 | When the 'expandtab' (et) option is set, a <Tab> is expanded to the |
| 680 | appropriate number of spaces. |
| 681 | |
| 682 | The window always reflects the contents of the buffer (Vi does not do this |
| 683 | when changing text and in some other cases). |
| 684 | |
| 685 | If Vim is compiled with DIGRAPHS defined, digraphs are supported. A set of |
| 686 | normal digraphs is included. They are shown with the ":digraph" command. |
| 687 | More can be added with ":digraph {char1}{char2} {number}". A digraph is |
| 688 | entered with "CTRL-K {char1} {char2}" or "{char1} BS {char2}" (only when |
| 689 | 'digraph' option is set). |
| 690 | |
| 691 | When repeating an insert, e.g. "10atest <Esc>" vi would only handle wrapmargin |
| 692 | for the first insert. Vim does it for all. |
| 693 | |
| 694 | A count to the "i" or "a" command is used for all the text. Vi uses the count |
| 695 | only for one line. "3iabc<NL>def<Esc>" would insert "abcabcabc<NL>def" in Vi |
| 696 | but "abc<NL>defabc<NL>defabc<NL>def" in Vim. |
| 697 | |
| 698 | |
| 699 | In Command-line mode: |
| 700 | |
Bram Moolenaar | 4499d2e | 2005-04-15 20:41:38 +0000 | [diff] [blame] | 701 | <Esc> terminates the command-line without executing it. In vi the command |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 702 | line would be executed, which is not what most people expect (hitting <Esc> |
| 703 | should always get you back to command mode). To avoid problems with some |
| 704 | obscure macros, an <Esc> in a macro will execute the command. If you want a |
| 705 | typed <Esc> to execute the command like vi does you can fix this with |
| 706 | ":cmap ^V<Esc> ^V<CR>" |
| 707 | |
| 708 | General: |
| 709 | |
| 710 | The 'ttimeout' option is like 'timeout', but only works for cursor and |
| 711 | function keys, not for ordinary mapped characters. The 'timeoutlen' option |
| 712 | gives the number of milliseconds that is waited for. If the 'esckeys' option |
| 713 | is not set, cursor and function keys that start with <Esc> are not recognized |
| 714 | in insert mode. |
| 715 | |
| 716 | There is an option for each terminal string. Can be used when termcap is not |
| 717 | supported or to change individual strings. |
| 718 | |
| 719 | The 'fileformat' option can be set to select the <EOL>: "dos" <CR><NL>, "unix" |
| 720 | <NL> or "mac" <CR>. |
| 721 | When the 'fileformats' option is not empty, Vim tries to detect the type of |
| 722 | <EOL> automatically. The 'fileformat' option is set accordingly. |
| 723 | |
| 724 | On systems that have no job control (older Unix systems and non-Unix systems) |
| 725 | the CTRL-Z, ":stop" or ":suspend" command starts a new shell. |
| 726 | |
| 727 | If Vim is started on the Amiga without an interactive window for output, a |
| 728 | window is opened (and :sh still works). You can give a device to use for |
| 729 | editing with the |-d| argument, e.g. "-d con:20/20/600/150". |
| 730 | |
| 731 | The 'columns' and 'lines' options are used to set or get the width and height |
| 732 | of the display. |
| 733 | |
| 734 | Option settings are read from the first and last few lines of the file. |
| 735 | Option 'modelines' determines how many lines are tried (default is 5). Note |
| 736 | that this is different from the Vi versions that can execute any Ex command |
| 737 | in a modeline (a major security problem). |trojan-horse| |
| 738 | |
| 739 | If the 'insertmode' option is set (e.g. in .exrc), Vim starts in insert mode. |
| 740 | And it comes back there, when pressing <Esc>. |
| 741 | |
| 742 | Undo information is kept in memory. Available memory limits the number and |
| 743 | size of change that can be undone. This may be a problem with MS-DOS, is |
| 744 | hardly a problem on the Amiga and almost never with Unix and Win32. |
| 745 | |
| 746 | If the 'backup' or 'writebackup' option is set: Before a file is overwritten, |
| 747 | a backup file (.bak) is made. If the "backup" option is set it is left |
| 748 | behind. |
| 749 | |
| 750 | Vim creates a file ending in ".swp" to store parts of the file that have been |
| 751 | changed or that do not fit in memory. This file can be used to recover from |
| 752 | an aborted editing session with "vim -r file". Using the swap file can be |
| 753 | switched off by setting the 'updatecount' option to 0 or starting Vim with |
| 754 | the "-n" option. Use the 'directory' option for placing the .swp file |
| 755 | somewhere else. |
| 756 | |
| 757 | Vim is able to work correctly on filesystems with 8.3 file names, also when |
| 758 | using messydos or crossdos filesystems on the Amiga, or any 8.3 mounted |
| 759 | filesystem under Unix. See |'shortname'|. |
| 760 | |
| 761 | Error messages are shown at least one second (Vi overwrites error messages). |
| 762 | |
| 763 | If Vim gives the |hit-enter| prompt, you can hit any key. Characters other |
| 764 | than <CR>, <NL> and <Space> are interpreted as the (start of) a command. (Vi |
| 765 | only accepts a command starting with ':'). |
| 766 | |
| 767 | The contents of the numbered and unnamed registers is remembered when |
| 768 | changing files. |
| 769 | |
| 770 | The "No lines in buffer" message is a normal message instead of an error |
| 771 | message, since that may cause a mapping to be aborted. |
| 772 | |
| 773 | The AUX: device of the Amiga is supported. |
| 774 | |
| 775 | ============================================================================== |
| 776 | 6. Command-line arguments *cmdline-arguments* |
| 777 | |
| 778 | Different versions of Vi have different command-line arguments. This can be |
| 779 | confusing. To help you, this section gives an overview of the differences. |
| 780 | |
| 781 | Five variants of Vi will be considered here: |
| 782 | Elvis Elvis version 2.1b |
| 783 | Nvi Nvi version 1.79 |
| 784 | Posix Posix 1003.2 |
| 785 | Vi Vi version 3.7 (for Sun 4.1.x) |
| 786 | Vile Vile version 7.4 (incomplete) |
| 787 | Vim Vim version 5.2 |
| 788 | |
| 789 | Only Vim is able to accept options in between and after the file names. |
| 790 | |
| 791 | +{command} Elvis, Nvi, Posix, Vi, Vim: Same as "-c {command}". |
| 792 | |
| 793 | - Nvi, Posix, Vi: Run Ex in batch mode. |
| 794 | Vim: Read file from stdin (use -s for batch mode). |
| 795 | |
| 796 | -- Vim: End of options, only file names are following. |
| 797 | |
| 798 | --cmd {command} Vim: execute {command} before sourcing vimrc files. |
| 799 | |
| 800 | --echo-wid Vim: GTK+ echoes the Window ID on stdout |
| 801 | |
| 802 | --help Vim: show help message and exit. |
| 803 | |
| 804 | --literal Vim: take file names literally, don't expand wildcards. |
| 805 | |
| 806 | --nofork Vim: same as |-f| |
| 807 | |
| 808 | --noplugin[s] Vim: Skip loading plugins. |
| 809 | |
| 810 | --remote Vim: edit the files in another Vim server |
| 811 | |
| 812 | --remote-expr {expr} Vim: evaluate {expr} in another Vim server |
| 813 | |
| 814 | --remote-send {keys} Vim: send {keys} to a Vim server and exit |
| 815 | |
| 816 | --remote-silent {file} Vim: edit the files in another Vim server if possible |
| 817 | |
| 818 | --remote-wait Vim: edit the files in another Vim server and wait for it |
| 819 | |
| 820 | --remote-wait-silent Vim: like --remote-wait, no complaints if not possible |
| 821 | |
| 822 | --role {role} Vim: GTK+ 2: set role of main window |
| 823 | |
| 824 | --serverlist Vim: Output a list of Vim servers and exit |
| 825 | |
| 826 | --servername {name} Vim: Specify Vim server name |
| 827 | |
| 828 | --socketid {id} Vim: GTK window socket to run Vim in |
| 829 | |
| 830 | --version Vim: show version message and exit. |
| 831 | |
| 832 | -? Vile: print usage summary and exit. |
| 833 | |
| 834 | -a Elvis: Load all specified file names into a window (use -o for |
| 835 | Vim). |
| 836 | |
| 837 | -A Vim: Start in Arabic mode (when compiled with Arabic). |
| 838 | |
| 839 | -b {blksize} Elvis: Use {blksize} blocksize for the session file. |
| 840 | -b Vim: set 'binary' mode. |
| 841 | |
| 842 | -C Vim: Compatible mode. |
| 843 | |
| 844 | -c {command} Elvis, Nvi, Posix, Vim: run {command} as an Ex command after |
| 845 | loading the edit buffer. |
| 846 | Vim: allow up to 10 "-c" arguments |
| 847 | |
| 848 | -d {device} Vim: Use {device} for I/O (Amiga only). {only when compiled |
| 849 | without the |+diff| feature} |
| 850 | -d Vim: start with 'diff' set. |vimdiff| |
| 851 | |
| 852 | -dev {device} Vim: Use {device} for I/O (Amiga only). |
| 853 | |
| 854 | -D Vim: debug mode. |
| 855 | |
| 856 | -e Elvis, Nvi, Vim: Start in Ex mode, as if the executable is |
| 857 | called "ex". |
| 858 | |
| 859 | -E Vim: Start in improved Ex mode |gQ|, like "exim". |
| 860 | |
| 861 | -f Vim: Run GUI in foreground (Amiga: don't open new window). |
| 862 | -f {session} Elvis: Use {session} as the session file. |
| 863 | |
| 864 | -F Vim: Start in Farsi mode (when compiled with Farsi). |
| 865 | Nvi: Fast start, don't read the entire file when editing |
| 866 | starts. |
| 867 | |
| 868 | -G {gui} Elvis: Use the {gui} as user interface. |
| 869 | |
| 870 | -g Vim: Start GUI. |
| 871 | -g N Vile: start editing at line N |
| 872 | |
| 873 | -h Vim: Give help message. |
| 874 | Vile: edit the help file |
| 875 | |
| 876 | -H Vim: start Hebrew mode (when compiled with it). |
| 877 | |
| 878 | -i Elvis: Start each window in Insert mode. |
| 879 | -i {viminfo} Vim: Use {viminfo} for viminfo file. |
| 880 | |
| 881 | -L Vim: Same as "-r" (also in some versions of Vi). |
| 882 | |
| 883 | -l Nvi, Vi, Vim: Set 'lisp' and 'showmatch' options. |
| 884 | |
| 885 | -m Vim: Modifications not allowed to be written, resets 'write' |
| 886 | option. |
| 887 | |
| 888 | -M Vim: Modifications not allowed, resets 'modifiable' and the |
| 889 | 'write' option. |
| 890 | |
| 891 | -N Vim: No-compatible mode. |
| 892 | |
| 893 | -n Vim: No swap file used. |
| 894 | |
| 895 | -nb[args] Vim: open a NetBeans interface connection |
| 896 | |
| 897 | -O[N] Vim: Like -o, but use vertically split windows. |
| 898 | |
| 899 | -o[N] Vim: Open [N] windows, or one for each file. |
| 900 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 901 | -p[N] Vim: Open [N] tab pages, or one for each file. |
| 902 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 903 | -P {parent-title} Win32 Vim: open Vim inside a parent application window |
| 904 | |
| 905 | -q {name} Vim: Use {name} for quickfix error file. |
| 906 | -q{name} Vim: Idem. |
| 907 | |
| 908 | -R Elvis, Nvi, Posix, Vile, Vim: Set the 'readonly' option. |
| 909 | |
| 910 | -r Elvis, Nvi, Posix, Vi, Vim: Recovery mode. |
| 911 | |
| 912 | -S Nvi: Set 'secure' option. |
| 913 | -S {script} Vim: source script after starting up. |
| 914 | |
| 915 | -s Nvi, Posix, Vim: Same as "-" (silent mode), when in Ex mode. |
| 916 | Elvis: Sets the 'safer' option. |
| 917 | -s {scriptin} Vim: Read from script file {scriptin}; only when not in Ex |
| 918 | mode. |
| 919 | -s {pattern} Vile: search for {pattern} |
| 920 | |
| 921 | -t {tag} Elvis, Nvi, Posix, Vi, Vim: Edit the file containing {tag}. |
| 922 | -t{tag} Vim: Idem. |
| 923 | |
| 924 | -T {term} Vim: Set terminal name to {term}. |
| 925 | |
| 926 | -u {vimrc} Vim: Read initializations from {vimrc} file. |
| 927 | |
| 928 | -U {gvimrc} Vim: Read GUI initializations from {gvimrc} file. |
| 929 | |
| 930 | -v Nvi, Posix, Vi, Vim: Begin in Normal mode (visual mode, in Vi |
| 931 | terms). |
| 932 | Vile: View mode, no changes possible. |
| 933 | |
| 934 | -V Elvis, Vim: Verbose mode. |
| 935 | -V{nr} Vim: Verbose mode with specified level. |
| 936 | |
| 937 | -w {size} Elvis, Posix, Nvi, Vi, Vim: Set value of 'window' to {size}. |
| 938 | -w{size} Nvi, Vi: Same as "-w {size}". |
| 939 | -w {name} Vim: Write to script file {name} (must start with non-digit). |
| 940 | |
| 941 | -W {name} Vim: Append to script file {name}. |
| 942 | |
| 943 | -x Vi, Vim: Ask for encryption key. See |encryption|. |
| 944 | |
| 945 | -X Vim: Don't connect to the X server. |
| 946 | |
| 947 | -y Vim: Start in easy mode, like |evim|. |
| 948 | |
| 949 | -Z Vim: restricted mode |
| 950 | |
| 951 | @{cmdfile} Vile: use {cmdfile} as startup file. |
| 952 | |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 953 | ============================================================================== |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 954 | 7. POSIX compliance *posix* *posix-compliance* |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 955 | |
Bram Moolenaar | dd2a3cd | 2007-05-05 17:10:09 +0000 | [diff] [blame] | 956 | In 2005 the POSIX test suite was run to check the compatibility of Vim. Most |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 957 | of the test was executed properly. There are the few things where Vim |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 958 | is not POSIX compliant, even when run in Vi compatibility mode. |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 959 | |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 960 | Set the $VIM_POSIX environment variable to have 'cpoptions' include the POSIX |
| 961 | flags when Vim starts up. This makes Vim run as POSIX as it can. That's |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 962 | a bit different from being Vi compatible. |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 963 | |
| 964 | This is where Vim does not behave as POSIX specifies and why: |
| 965 | |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 966 | *posix-screen-size* |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 967 | The $COLUMNS and $LINES environment variables are ignored by Vim if |
| 968 | the size can be obtained from the terminal in a more reliable way. |
| 969 | Add the '|' flag to 'cpoptions' to have $COLUMNS and $LINES overrule |
| 970 | sizes obtained in another way. |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 971 | |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 972 | The "{" and "}" commands don't stop at a "{" in the original Vi, but |
| 973 | POSIX specifies it does. Add the '{' flag to 'cpoptions' if you want |
| 974 | it the POSIX way. |
| 975 | |
| 976 | The "D", "o" and "O" commands accept a count. Also when repeated. |
| 977 | Add the '#' flag to 'cpoptions' if you want to ignore the count. |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 978 | |
Bram Moolenaar | 6bdcfc0 | 2005-02-22 08:28:13 +0000 | [diff] [blame] | 979 | The ":cd" command fails if the current buffer is modified when the '.' |
| 980 | flag is present in 'cpoptions'. |
| 981 | |
| 982 | There is no ATTENTION message, the "A" flag is added to 'shortmess'. |
| 983 | |
| 984 | These are remarks about running the POSIX test suite: |
| 985 | - vi test 33 sometimes fails for unknown reasons |
| 986 | - vi test 250 fails; behavior will be changed in a new revision |
| 987 | http://www.opengroup.org/austin/mailarchives/ag-review/msg01710.html |
| 988 | - vi test 310 fails; exit code non-zero when any error occurred? |
| 989 | - ex test 24 fails because test is wrong. Changed between SUSv2 and SUSv3. |
| 990 | - ex tests 47, 48, 49, 72, 73 fail because .exrc file isn't read in silent |
| 991 | mode and $EXINIT isn't used. |
| 992 | - ex tests 76, 78 fail because echo is used instead of printf. (fixed) |
| 993 | Also: problem with \s not changed to space. |
| 994 | - ex test 355 fails because 'window' isn't used for "30z". |
| 995 | - ex test 368 fails because shell command isn't echoed in silent mode. |
| 996 | - ex test 394 fails because "=" command output isn't visible in silent mode. |
| 997 | - ex test 411 fails because test file is wrong, contains stray ':'. |
| 998 | - ex test 475 and 476 fail because reprint output isn't visible in silent mode. |
| 999 | - ex test 480 and 481 fail because the tags file has spaces instead of a tab. |
| 1000 | - ex test 502 fails because .exrc isn't read in silent mode. |
| 1001 | - ex test 509 fails because .exrc isn't read in silent mode. and exit code is |
| 1002 | 1 instead of 2. |
| 1003 | - ex test 534 fails because .exrc isn't read in silent mode. |
| 1004 | |
Bram Moolenaar | f97ca8f | 2005-02-07 21:49:25 +0000 | [diff] [blame] | 1005 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1006 | vim:tw=78:ts=8:ft=help:norl: |