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