summaryrefslogtreecommitdiffstats
path: root/runtime/doc/vi_diff.txt
blob: 8e1f543477c8e923705bc3e5ba9897e4b76c3566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
*vi_diff.txt*   For Vim version 7.3.  Last change: 2010 Oct 11


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Differences between Vim and Vi				*vi-differences*

Throughout the help files differences between Vim and Vi/Ex are given in
curly braces, like "{not in Vi}".  This file only lists what has not been
mentioned in other files and gives an overview.

Vim is mostly POSIX 1003.2-1 compliant.  The only command known to be missing
is ":open".  There are probably a lot of small differences (either because Vim
is missing something or because Posix is beside the mark).

1. Simulated command			|simulated-command|
2. Missing options			|missing-options|
3. Limits				|limits|
4. The most interesting additions	|vim-additions|
5. Other vim features			|other-features|
6. Command-line arguments		|cmdline-arguments|
7. POSIX compliance			|posix-compliance|

==============================================================================
1. Simulated command					*simulated-command*

This command is in Vi, but Vim only simulates it:

							*:o* *:op* *:open*
:[range]o[pen]			Works like |:visual|: end Ex mode.
				{Vi: start editing in open mode}

:[range]o[pen] /pattern/	As above, additionally move the cursor to the
				column where "pattern" matches in the cursor
				line.

Vim does not support open mode, since it's not really useful.  For those
situations where ":open" would start open mode Vim will leave Ex mode, which
allows executing the same commands, but updates the whole screen instead of
only one line.

==============================================================================
2. Missing options					*missing-options*

These options are in the Unix Vi, but not in Vim.  If you try to set one of
them you won't get an error message, but the value is not used and cannot be
printed.

autoprint (ap)		boolean	(default on)		*'autoprint'* *'ap'*
beautify (bf)		boolean	(default off)		*'beautify'* *'bf'*
flash (fl)		boolean	(default ??)		*'flash'* *'fl'*
graphic (gr)		boolean	(default off)		*'graphic'* *'gr'*
hardtabs (ht)		number	(default 8)		*'hardtabs'* *'ht'*
	number of spaces that a <Tab> moves on the display
mesg			boolean	(default on)		*'mesg'*
novice			boolean	(default off)		*'novice'*
open			boolean	(default on)		*'open'*
optimize (op)		boolean	(default off)		*'optimize'* *'op'*
redraw			boolean	(default off)		*'redraw'*
slowopen (slow)		boolean	(default off)		*'slowopen'* *'slow'*
sourceany		boolean	(default off)		*'sourceany'*
w300			number	(default 23)		*'w300'*
w1200			number	(default 23)		*'w1200'*
w9600			number	(default 23)		*'w9600'*

==============================================================================
3. Limits						*limits*

Vim has only a few limits for the files that can be edited {Vi: can not handle
<Nul> characters and characters above 128, has limited line length, many other
limits}.
							*E340*
Maximum line length	   On machines with 16-bit ints (Amiga and MS-DOS real
			   mode): 32767, otherwise 2147483647 characters.
			   Longer lines are split.
Maximum number of lines	   2147483647 lines.
Maximum file size	   2147483647 bytes (2 Gbyte) when a long integer is
			   32 bits.  Much more for 64 bit longs.  Also limited
			   by available disk space for the |swap-file|.
							*E75*
Length of a file path	   Unix and Win32: 1024 characters, otherwise 256
			   characters (or as much as the system supports).
Length of an expanded string option
			   Unix and Win32: 1024 characters, otherwise 256
			   characters
Maximum display width	   Unix and Win32: 1024 characters, otherwise 255
			   characters
Maximum lhs of a mapping   50 characters.
Number of different highlighting types: over 30000
Range of a Number variable:  -2147483648 to 2147483647 (more on 64 bit
			   systems)
Maximum length of a line in a tags file: 512 bytes.

Information for undo and text in registers is kept in memory, thus when making
(big) changes the amount of (virtual) memory available limits the number of
undo levels and the text that can be kept in registers.  Other things are also
kept in memory:  Command-line history, error messages for Quickfix mode, etc.

Memory usage limits
-------------------

The option 'maxmem' ('mm') is used to set the maximum memory used for one
buffer (in kilobytes).  'maxmemtot' is used to set the maximum memory used for
all buffers (in kilobytes).  The defaults depend on the system used.  For the
Amiga and MS-DOS, 'maxmemtot' is set depending on the amount of memory
available.
These are not hard limits, but tell Vim when to move text into a swap file.
If you don't like Vim to swap to a file, set 'maxmem' and 'maxmemtot' to a
very large value.  The swap file will then only be used for recovery.  If you
don't want a swap file at all, set 'updatecount' to 0, or use the "-n"
argument when starting Vim.

==============================================================================
4. The most interesting additions			*vim-additions*

Vi compatibility.					|'compatible'|
	Although Vim is 99% Vi compatible, some things in Vi can be
	considered to be a bug, or at least need improvement.  But still, Vim
	starts in a mode which behaves like the "real" Vi as much as possible.
	To make Vim behave a little bit better, try resetting the 'compatible'
	option:
		:set nocompatible
	Or start Vim with the "-N" argument:
		vim -N
	Vim starts with 'nocompatible' automatically if you have a .vimrc
	file.  See |startup|.
	The 'cpoptions' option can be used to set Vi compatibility on/off for
	a number of specific items.

Support for different systems.
	Vim can be used on:
	- All Unix systems (it works on all systems it was tested on, although
	  the GUI and Perl interface may not work everywhere).
	- Amiga (500, 1000, 1200, 2000, 3000, 4000, ...).
	- MS-DOS in real-mode (no additional drivers required).
	- In protected mode on Windows 3.1 and MS-DOS (DPMI driver required).
	- Windows 95 and Windows NT, with support for long file names.
	- OS/2 (needs emx.dll)
	- Atari MiNT
	- VMS
	- BeOS
	- Macintosh
	- Risc OS
	- IBM OS/390
	Note that on some systems features need to be disabled to reduce
	resource usage, esp. on MS-DOS.  For some outdated systems you need to
	use an older Vim version.

Multi level undo.					|undo|
	'u' goes backward in time, 'CTRL-R' goes forward again.  Set option
	'undolevels' to the number of changes to be remembered (default 1000).
	Set 'undolevels' to 0 for a vi-compatible one level undo.  Set it to
	-1 for no undo at all.
	When all changes in a buffer have been undone, the buffer is not
	considered changed anymore.  You can exit it with :q, without <!>.
	When undoing a few changes and then making a new change Vim will
	create a branch in the undo tree.  This means you can go back to any
	state of the text, there is no risk of a change causing text to be
	lost forever. |undo-tree|

Graphical User Interface (GUI).				|gui|
	Included support for GUI: menu's, mouse, scrollbars, etc.  You can
	define your own menus.  Better support for CTRL/SHIFT/ALT keys in
	combination with special keys and mouse.  Supported for various
	platforms, such as X11 (with Motif and Athena interfaces), GTK, Win32
	(Windows 95 and later), BeOS, Amiga and Macintosh.

Multiple windows and buffers.				|windows.txt|
	Vim can split the screen into several windows, each editing a
	different buffer or the same buffer at a different location.  Buffers
	can still be loaded (and changed) but not displayed in a window.  This
	is called a hidden buffer.  Many commands and options have been added
	for this facility.
	Vim can also use multiple tab pages, each with one or more windows.  A
	line with tab labels can be used to quickly switch between these pages.
	|tab-page|

Syntax highlighting.					|:syntax|
	Vim can highlight keywords, patterns and other things.  This is
	defined by a number of |:syntax| commands, and can be made to
	highlight most languages and file types.  A number of files are
	included for highlighting the most common languages, like C, C++,
	Java, Pascal, Makefiles, shell scripts, etc.  The colors used for
	highlighting can be defined for ordinary terminals, color terminals
	and the GUI with the |:highlight| command.  A convenient way to do
	this is using a |:colorscheme| command.
	The highlighted text can be exported as HTML. |convert-to-HTML|
	Other items that can be highlighted are matches with the search string
	|'hlsearch'|, matching parens |matchparen| and the cursor line and
	column |'cursorline'| |'cursorcolumn'|.

Spell checking.						|spell|
	When the 'spell' option is set Vim will highlight spelling mistakes.
	About 40 languages are currently supported, selected with the
	'spelllang' option.  In source code only comments and strings are
	checked for spelling.

Folding.						|folding|
	A range of lines can be shown as one "folded" line.  This allows
	overviewing a file and moving blocks of text around quickly.
	Folds can be created manually, from the syntax of the file, by indent,
	etc.

Diff mode.						|diff|
	Vim can show two versions of a file with the differences highlighted.
	Parts of the text that are equal are folded away.  Commands can be
	used to move text from one version to the other.

Plugins.						|add-plugin|
	The functionality can be extended by dropping a plugin file in the
	right directory.  That's an easy way to start using Vim scripts
	written by others.  Plugins can be for all kind of files, or
	specifically for a filetype.

Repeat a series of commands.				|q|
	"q{c}" starts recording typed characters into named register {c}.
	A subsequent "q" stops recording.  The register can then be executed
	with the "@{c}" command.  This is very useful to repeat a complex
	action.

Flexible insert mode.					|ins-special-special|
	The arrow keys can be used in insert mode to move around in the file.
	This breaks the insert in two parts as far as undo and redo is
	concerned.

	CTRL-O can be used to execute a single Normal mode command.  This is
	almost the same as hitting <Esc>, typing the command and doing |a|.

Visual mode.						|Visual-mode|
	Visual mode can be used to first highlight a piece of text and then
	give a command to do something with it.  This is an (easy to use)
	alternative to first giving the operator and then moving to the end of
	the text to be operated upon.
	|v| and |V| are used to start Visual mode.  |v| works on characters
	and |V| on lines.  Move the cursor to extend the Visual area.  It is
	shown highlighted on the screen.  By typing "o" the other end of the
	Visual area can be moved.  The Visual area can be affected by an
	operator:
		d	delete
		c	change
		y	yank
		> or <	insert or delete indent
		!	filter through external program
		=	filter through indent
		:	start |:| command for the Visual lines.
		gq	format text to 'textwidth' columns
		J	join lines
		~	swap case
		u	make lowercase
		U	make uppercase

Block operators.					|visual-block|
	With Visual mode a rectangular block of text can be selected.  Start
	Visual mode with CTRL-V.  The block can be deleted ("d"), yanked ("y")
	or its case can be changed ("~", "u" and "U").  A deleted or yanked
	block can be put into the text with the "p" and "P" commands.

Help system.						|:help|
	Help is displayed in a window.  The usual commands can be used to
	move around, search for a string, etc.  Tags can be used to jump
	around in the help files, just like hypertext links.  The |:help|
	command takes an argument to quickly jump to the info on a subject.
	<F1> is the quick access to the help system.  The name of the help
	index file can be set with the 'helpfile' option.

Command-line editing and history.			|cmdline-editing|
	You can insert or delete at any place in the command-line using the
	cursor keys.  The right/left cursor keys can be used to move
	forward/backward one character.  The shifted right/left cursor keys
	can be used to move forward/backward one word.  CTRL-B/CTRL-E can be
	used to go to the begin/end of the command-line.
							|cmdline-history|
	The command-lines are remembered.  The up/down cursor keys can be used
	to recall previous command-lines.  The 'history' option can be set to
	the number of lines that will be remembered.  There is a separate
	history for commands and for search patterns.

Command-line completion.				|cmdline-completion|
	While entering a command-line (on the bottom line of the screen)
	<Tab> can be typed to complete
	   what		example		~
	- command	:e<Tab>
	- tag		:ta scr<Tab>
	- option	:set sc<Tab>
	- option value  :set hf=<Tab>
	- file name	:e ve<Tab>
	- etc.

	If there are multiple matches, CTRL-N (next) and CTRL-P (previous)
	will walk through the matches.  <Tab> works like CTRL-N, but wraps
	around to the first match.

	The 'wildchar' option can be set to the character for command-line
	completion, <Tab> is the default.  CTRL-D can be typed after an
	(incomplete) wildcard; all matches will be listed.  CTRL-A will insert
	all matches.  CTRL-L will insert the longest common part of the
	matches.

Insert-mode completion.					|ins-completion|
	In Insert mode the CTRL-N and CTRL-P keys can be used to complete a
	word that appears elsewhere.	|i_CTRL-N|
	With CTRL-X another mode is entered, through which completion can be
	done for:
	|i_CTRL-X_CTRL-F|	file names
	|i_CTRL-X_CTRL-K|	words from 'dictionary' files
	|i_CTRL-X_CTRL-T|	words from 'thesaurus' files
	|i_CTRL-X_CTRL-I|	words from included files
	|i_CTRL-X_CTRL-L|	whole lines
	|i_CTRL-X_CTRL-]|	words from the tags file
	|i_CTRL-X_CTRL-D|	definitions or macros
	|i_CTRL-X_CTRL-O|	Omni completion: clever completion
				specifically for a file type
	etc.

Long line support.					|'wrap'| |'linebreak'|
	If the 'wrap' option is off, long lines will not wrap and only part
	of them will be shown.  When the cursor is moved to a part that is not
	shown, the screen will scroll horizontally.  The minimum number of
	columns to scroll can be set with the 'sidescroll' option.  The |zh|
	and |zl| commands can be used to scroll sideways.
	Alternatively, long lines are broken in between words when the
	'linebreak' option is set.  This allows editing a single-line
	paragraph conveniently (e.g. when the text is later read into a DTP
	program).  Move the cursor up/down with the |gk| and |gj| commands.

Text formatting.					|formatting|
	The 'textwidth' option can be used to automatically limit the line
	length.  This supplements the 'wrapmargin' option of Vi, which was not
	very useful.  The |gq| operator can be used to format a piece of text
	(for example, |gqap| formats the current paragraph).  Commands for
	text alignment: |:center|, |:left| and |:right|.

Extended search patterns.				|pattern|
	There are many extra items to match various text items.  Examples:
	A "\n" can be used in a search pattern to match a line break.
	"x\{2,4}" matches "x" 2 to 4 times.
	"\s" matches a white space character.

Directory, remote and archive browsing.			|netrw|
	Vim can browse the file system.  Simply edit a directory.  Move around
	in the list with the usual commands and press <Enter> to go to the
	directory or file under the cursor.
	This also works for remote files over ftp, http, ssh, etc.
	Zip and tar archives can also be browsed. |tar| |zip|

Edit-compile-edit speedup.				|quickfix|
	The |:make| command can be used to run the compilation and jump to the
	first error.  A file with compiler error messages is interpreted.  Vim
	jumps to the first error.

	Each line in the error file is scanned for the name of a file, line
	number and error message.  The 'errorformat' option can be set to a
	list of scanf-like strings to handle output from many compilers.

	The |:cn| command can be used to jump to the next error.
	|:cl| lists all the error messages.  Other commands are available.
	The 'makeef' option has the name of the file with error messages.
	The 'makeprg' option contains the name of the program to be executed
	with the |:make| command.
	The 'shellpipe' option contains the string to be used to put the
	output of the compiler into the errorfile.

Finding matches in files.				|:vimgrep|
	Vim can search for a pattern in multiple files.  This uses the
	advanced Vim regexp pattern, works on all systems and also works to
	search in compressed files.

Improved indenting for programs.			|'cindent'|
	When the 'cindent' option is on the indent of each line is
	automatically adjusted.  C syntax is mostly recognized.  The indent
	for various styles can be set with 'cinoptions'.  The keys to trigger
	indenting can be set with 'cinkeys'.

	Comments can be automatically formatted.  The 'comments' option can be
	set to the characters that start and end a comment.  This works best
	for C code, but also works for e-mail (">" at start of the line) and
	other types of text.  The |=| operator can be used to re-indent
	lines.

	For many other languages an indent plugin is present to support
	automatic indenting. |30.3|

Searching for words in included files.			|include-search|
	The |[i| command can be used to search for a match of the word under
	the cursor in the current and included files.  The 'include' option
	can be set to a pattern that describes a command to include a file
	(the default is for C programs).
	The |[I| command lists all matches, the |[_CTRL-I| command jumps to
	a match.
	The |[d|, |[D| and |[_CTRL-D| commands do the same, but only for
	lines where the pattern given with the 'define' option matches.

Automatic commands.					|autocommand|
	Commands can be automatically executed when reading a file, writing a
	file, jumping to another buffer, etc., depending on the file name.
	This is useful to set options and mappings for C programs,
	documentation, plain text, e-mail, etc.  This also makes it possible
	to edit compressed files.

Scripts and Expressions.				|expression|
	Commands have been added to form up a powerful script language.
	|:if|		Conditional execution, which can be used for example
			to set options depending on the value of $TERM.
	|:while|	Repeat a number of commands.
	|:for|		Loop over a list.
	|:echo|		Print the result of an expression.
	|:let|		Assign a value to an internal variable, option, etc.
			Variable types are Number, String, List and Dictionary.
	|:execute|	Execute a command formed by an expression.
	|:try|		Catch exceptions.
	etc., etc.  See |eval|.
	Debugging and profiling are supported. |debug-scripts| |profile|
	If this is not enough, an interface is provided to |Python|, |Ruby|,
	|Tcl|, |Lua|, |Perl| and |MzScheme|.

Viminfo.						|viminfo-file|
	The command-line history, marks and registers can be stored in a file
	that is read on startup.  This can be used to repeat a search command
	or command-line command after exiting and restarting Vim.  It is also
	possible to jump right back to where the last edit stopped with |'0|.
	The 'viminfo' option can be set to select which items to store in the
	.viminfo file.  This is off by default.

Printing.						|printing|
	The |:hardcopy| command sends text to the printer.  This can include
	syntax highlighting.

Mouse support.						|mouse-using|
	The mouse is supported in the GUI version, in an xterm for Unix, for
	BSDs with sysmouse, for Linux with gpm, for MS-DOS, and Win32.  It
	can be used to position the cursor, select the visual area, paste a
	register, etc.

Usage of key names.					|<>| |key-notation|
	Special keys now all have a name like <Up>, <End>, etc.
	This name can be used in mappings, to make it easy to edit them.

Editing binary files.					|edit-binary|
	Vim can edit binary files.  You can change a few characters in an
	executable file, without corrupting it.  Vim doesn't remove NUL
	characters (they are represented as <NL> internally).
	|-b|		command-line argument to start editing a binary file
	|'binary'|	Option set by |-b|.  Prevents adding an <EOL> for the
			last line in the file.

Multi-language support.					|multi-lang|
	Files in double-byte or multi-byte encodings can be edited.  There is
	UTF-8 support to be able to edit various languages at the same time,
	without switching fonts. |UTF-8|
	Messages and menus are available in different languages.

Move cursor beyond lines.
	When the 'virtualedit' option is set the cursor can move all over the
	screen, also where there is no text.  This is useful to edit tables
	and figures easily.

==============================================================================
5. Other vim features					*other-features*

A random collection of nice extra features.


When Vim is started with "-s scriptfile", the characters read from
"scriptfile" are treated as if you typed them.  If end of file is reached
before the editor exits, further characters are read from the console.

The "-w" option can be used to record all typed characters in a script file.
This file can then be used to redo the editing, possibly on another file or
after changing some commands in the script file.

The "-o" option opens a window for each argument.  "-o4" opens four windows.

Vi requires several termcap entries to be able to work full-screen.  Vim only
requires the "cm" entry (cursor motion).


In command mode:

When the 'showcmd' option is set, the command characters are shown in the last
line of the screen.  They are removed when the command is finished.

If the 'ruler' option is set, the current cursor position is shown in the
last line of the screen.

"U" still works after having moved off the last changed line and after "u".

Characters with the 8th bit set