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