xref: /vim-8.2.3635/runtime/doc/intro.txt (revision 6e649224)
1*intro.txt*     For Vim version 8.2.  Last change: 2021 Sep 29
2
3
4		  VIM REFERENCE MANUAL    by Bram Moolenaar
5
6
7Introduction to Vim					*ref* *reference*
8
91. Introduction			|intro|
102. Vim on the internet		|internet|
113. Credits			|credits|
124. Notation			|notation|
135. Modes, introduction		|vim-modes-intro|
146. Switching from mode to mode	|mode-switching|
157. The window contents		|window-contents|
168. Definitions			|definitions|
17
18==============================================================================
191. Introduction						*intro*
20
21Vim stands for Vi IMproved.  It used to be Vi IMitation, but there are so many
22improvements that a name change was appropriate.  Vim is a text editor which
23includes almost all the commands from the Unix program "Vi" and a lot of new
24ones.  It is very useful for editing programs and other plain text.
25   All commands are given with the keyboard.  This has the advantage that you
26can keep your fingers on the keyboard and your eyes on the screen.  For those
27who want it, there is mouse support and a GUI version with scrollbars and
28menus (see |gui.txt|).
29
30An overview of this manual can be found in the file "help.txt", |help.txt|.
31It can be accessed from within Vim with the <Help> or <F1> key and with the
32|:help| command (just type ":help", without the bars or quotes).
33   The 'helpfile' option can be set to the name of the help file, in case it
34is not located in the default place.  You can jump to subjects like with tags:
35Use CTRL-] to jump to a subject under the cursor, use CTRL-T to jump back.
36
37The differences between Vi and Vim are mentioned in |vi_diff.txt|.
38
39This manual refers to Vim on various machines.  There may be small differences
40between different computers and terminals.  Besides the remarks given in this
41document, there is a separate document for each supported system, see
42|sys-file-list|.
43
44							*pronounce*
45Vim is pronounced as one word, like Jim, not vi-ai-em.  It's written with a
46capital, since it's a name, again like Jim.
47
48This manual is a reference for all the Vim commands and options.  This is not
49an introduction to the use of Vi or Vim, it gets a bit complicated here and
50there.  For beginners, there is a hands-on |tutor|.  To learn using Vim, read
51the user manual |usr_toc.txt|.
52
53							*book* *books*
54Most books on Vi and Vim contain a section for beginners.  Others are spending
55more words on specific functionality.  You can find an overview of Vim books
56here:
57	http://iccf-holland.org/vim_books.html
58
59==============================================================================
602. Vim on the internet					*internet*
61
62			*www* *WWW*  *faq* *FAQ* *distribution* *download*
63The Vim pages contain the most recent information about Vim.  They also
64contain links to the most recent version of Vim.  The FAQ is a list of
65Frequently Asked Questions.  Read this if you have problems.
66
67	Vim home page:	  https://www.vim.org/
68	Vim FAQ:	  https://vimhelp.org/vim_faq.txt.html
69	Downloading:	  https://www.vim.org/download.php
70
71
72Asking questions, finding answers: https://vi.stackexchange.com/
73"Vi and Vim Stack Exchange is a question and answer site for people using the
74vi and Vim families of text editors"
75
76
77Usenet News group where Vim is discussed:		*news* *usenet*
78	comp.editors
79This group is also for other editors.  If you write about Vim, don't forget to
80mention that.
81You can access it here:
82https://groups.google.com/forum/#!topic/comp.editors
83
84						*mail-list* *maillist*
85There are several mailing lists for Vim:
86<[email protected]>					*vim-use* *vim_use*
87	For discussions about using existing versions of Vim: Useful mappings,
88	questions, answers, where to get a specific version, etc.  There are
89	quite a few people watching this list and answering questions, also
90	for beginners.  Don't hesitate to ask your question here.
91<[email protected]>				*vim-dev* *vim_dev* *vimdev*
92	For discussions about changing Vim: New features, porting, patches,
93	beta-test versions, etc.
94<[email protected]>				*vim-announce* *vim_announce*
95	Announcements about new versions of Vim; also for beta-test versions
96	and ports to different systems.  This is a read-only list.
97<[email protected]>				*vim-mac* *vim_mac*
98	For discussions about using and improving the Macintosh version of
99	Vim.
100
101See http://www.vim.org/maillist.php for the latest information.
102
103NOTE:
104- Anyone can see the archive, e.g. on Google groups.  Search this if you have
105  questions.
106- You can only send messages to these lists if you have subscribed!
107- The first message is moderated, thus it may take a few hours to show up.
108- You need to send the messages from the same location as where you subscribed
109  from (to avoid spam mail).
110
111						*subscribe-maillist*
112If you want to join, send a message to
113	<[email protected]>
114Make sure that your "From:" address is correct.  Then the list server will
115give you help on how to subscribe.
116
117						*maillist-archive*
118For more information and archives look on the Vim maillist page:
119http://www.vim.org/maillist.php
120
121
122Bug reports:				*bugs* *bug-reports* *bugreport.vim*
123
124There are three ways to report bugs:
1251. Open an issue on GitHub: https://github.com/vim/vim/issues
126   The text will be forwarded to the vim-dev maillist.
1272. For issues with runtime files, look in the header for an email address or
128   any other way to report it to the maintainer.
1293. Send bug reports to: Vim Developers <[email protected]>
130   This is a maillist, you need to become a member first and many people will
131   see the message.  If you don't want that, e.g. because it is a security
132   issue, send it to <[email protected]>, this only goes to the Vim maintainer
133   (that's Bram).
134
135Please be brief; all the time that is spent on answering mail is subtracted
136from the time that is spent on improving Vim!  Always give a reproducible
137example and try to find out which settings or other things trigger the bug.
138
139Preferably start Vim with: >
140	vim --clean -u reproduce.vim
141Where reproduce.vim is a script that reproduces the problem.  Try different
142machines, if relevant (is this an MS-Windows specific bug perhaps?).
143
144Send me patches if you can!  If you create a pull request on
145https://github.com/vim/vim then the automated checks will run and report any
146obvious problems.  But you can also send the patch by email (use an attachment
147to avoid white space changes).
148
149It will help to include information about the version of Vim you are using and
150your setup.  You can get the information with this command: >
151   :so $VIMRUNTIME/bugreport.vim
152This will create a file "bugreport.txt" in the current directory, with a lot
153of information of your environment.  Before sending this out, check if it
154doesn't contain any confidential information!
155
156If Vim crashes, please try to find out where.  You can find help on this here:
157|debug.txt|.
158
159In case of doubt or when you wonder if the problem has already been fixed but
160you can't find a fix for it, become a member of the vim-dev maillist and ask
161your question there. |maillist|
162
163							*year-2000* *Y2K*
164Since Vim internally doesn't use dates for editing, there is no year 2000
165problem to worry about.  Vim does use the time in the form of seconds since
166January 1st 1970.  It is used for a time-stamp check of the edited file and
167the swap file, which is not critical and should only cause warning messages.
168
169There might be a year 2038 problem, when the seconds don't fit in a 32 bit int
170anymore.  This depends on the compiler, libraries and operating system.
171Specifically, time_t and the ctime() function are used.  And the time_t is
172stored in four bytes in the swap file.  But that's only used for printing a
173file date/time for recovery, it will never affect normal editing.
174
175The Vim strftime() function directly uses the strftime() system function.
176localtime() uses the time() system function.  getftime() uses the time
177returned by the stat() system function.  If your system libraries are year
1782000 compliant, Vim is too.
179
180The user may create scripts for Vim that use external commands.  These might
181introduce Y2K problems, but those are not really part of Vim itself.
182
183==============================================================================
1843. Credits				*credits* *author* *Bram* *Moolenaar*
185
186Most of Vim was created by Bram Moolenaar <[email protected]>.
187
188Parts of the documentation come from several Vi manuals, written by:
189	W.N. Joy
190	Alan P.W. Hewett
191	Mark Horton
192
193The Vim editor is based on Stevie and includes (ideas from) other software,
194worked on by the people mentioned here.  Other people helped by sending me
195patches, suggestions and giving feedback about what is good and bad in Vim.
196
197Vim would never have become what it is now, without the help of these people!
198
199	Ron Aaron		Win32 GUI changes
200	Mohsin Ahmed		encryption
201	Zoltan Arpadffy		work on VMS port
202	Tony Andrews		Stevie
203	Gert van Antwerpen	changes for DJGPP on MS-DOS
204	Berkeley DB(3)		ideas for swap file implementation
205	Keith Bostic		Nvi
206	Walter Briscoe		Makefile updates, various patches
207	Ralf Brown		SPAWNO library for MS-DOS
208	Robert Colon		many useful remarks
209	Marcin Dalecki		GTK+ GUI port, toolbar icons, gettext()
210	Kayhan Demirel		sent me news in Uganda
211	Chris & John Downey	xvi (ideas for multi-windows version)
212	Henk Elbers		first VMS port
213	Daniel Elstner		GTK+ 2 port
214	Eric Fischer		Mac port, 'cindent', and other improvements
215	Benji Fisher		Answering lots of user questions
216	Bill Foster		Athena GUI port
217	Google			Lets me work on Vim one day a week
218	Loic Grenie		xvim (ideas for multi windows version)
219	Sven Guckes		Vim promoter and previous WWW page maintainer
220	Darren Hiebert		Exuberant ctags
221	Jason Hildebrand	GTK+ 2 port
222	Bruce Hunsaker		improvements for VMS port
223	Andy Kahn		Cscope support, GTK+ GUI port
224	Oezguer Kesim		Maintainer of Vim Mailing Lists
225	Axel Kielhorn		work on the Macintosh port
226	Steve Kirkendall	Elvis
227	Roger Knobbe		original port to Windows NT
228	Sergey Laskavy		Vim's help from Moscow
229	Felix von Leitner	Previous maintainer of Vim Mailing Lists
230	David Leonard		Port of Python extensions to Unix
231	Avner Lottem		Edit in right-to-left windows
232	Flemming Madsen		X11 client-server, various features and patches
233	Tony Mechelynck		answers many user questions
234	Paul Moore		Python interface extensions, many patches
235	Katsuhito Nagano	Work on multibyte versions
236	Sung-Hyun Nam		Work on multibyte versions
237	Vince Negri		Win32 GUI and generic console enhancements
238	Steve Oualline		Author of the first Vim book |frombook|
239	Dominique Pelle		Valgrind reports and many fixes
240	A.Politz		Many bug reports and some fixes
241	George V. Reilly	Win32 port, Win32 GUI start-off
242	Stephen Riehm		bug collector
243	Stefan Roemer		various patches and help to users
244	Ralf Schandl		IBM OS/390 port
245	Olaf Seibert		DICE and BeBox version, regexp improvements
246	Mortaza Shiran		Farsi patches
247	Peter da Silva		termlib
248	Paul Slootman		OS/2 port
249	Henry Spencer		regular expressions
250	Dany St-Amant		Macintosh port
251	Tim Thompson		Stevie
252	G. R. (Fred) Walter	Stevie
253	Sven Verdoolaege	Perl interface
254	Robert Webb		Command-line completion, GUI versions, and
255				lots of patches
256	Ingo Wilken		Tcl interface
257	Mike Williams		PostScript printing
258	Juergen Weigert		Lattice version, AUX improvements, UNIX and
259				MS-DOS ports, autoconf
260	Stefan 'Sec' Zehl	Maintainer of vim.org
261	Yasuhiro Matsumoto	many MS-Windows improvements
262	Ken Takata		fixes and features
263	Kazunobu Kuriyama	GTK 3
264	Christian Brabandt	many fixes, features, user support, etc.
265	Yegappan Lakshmanan	many quickfix features
266
267I wish to thank all the people that sent me bug reports and suggestions.  The
268list is too long to mention them all here.  Vim would not be the same without
269the ideas from all these people: They keep Vim alive!
270*love* *peace* *friendship* *gross-national-happiness*
271
272
273In this documentation there are several references to other versions of Vi:
274							*Vi* *vi*
275Vi	"the original".  Without further remarks this is the version
276	of Vi that appeared in Sun OS 4.x.  ":version" returns
277	"Version 3.7, 6/7/85".  Sometimes other versions are referred
278	to.  Only runs under Unix.  Source code is now available under a
279	BSD-style license.  More information on Vi can be found through:
280		http://ex-vi.sourceforge.net/
281							*Posix*
282Posix	From the IEEE standard 1003.2, Part 2: Shell and utilities.
283	Generally known as "Posix".  This is a textual description of
284	how Vi is supposed to work.
285	See |posix-compliance|.
286							*Nvi*
287Nvi	The "New" Vi.  The version of Vi that comes with BSD 4.4 and FreeBSD.
288	Very good compatibility with the original Vi, with a few extensions.
289	The version used is 1.79.  ":version" returns "Version 1.79
290	(10/23/96)".  There has been no release the last few years, although
291	there is a development version 1.81.
292	Source code is freely available.
293							*Elvis*
294Elvis	Another Vi clone, made by Steve Kirkendall.  Very compact but isn't
295	as flexible as Vim.  Development has stalled, Elvis has left the
296	building!  Source code is freely available.
297							*Neovim*
298Neovim	A Vim clone.  Forked the Vim source in 2014 and went a different way.
299	Very much bound to github and has many more dependencies, making
300	development more complex and limiting portability.  Code has been
301	refactored, resulting in patches not being exchangeable with Vim.
302	Supports a remote GUI and integration with scripting languages.
303
304==============================================================================
3054. Notation						*notation*
306
307When syntax highlighting is used to read this, text that is not typed
308literally is often highlighted with the Special group.  These are items in [],
309{} and <>, and CTRL-X.
310
311Note that Vim uses all possible characters in commands.  Sometimes the [], {}
312and <> are part of what you type, the context should make this clear.
313
314
315[]		Characters in square brackets are optional.
316
317						    *count* *[count]*
318[count]		An optional number that may precede the command to multiply
319		or iterate the command.  If no number is given, a count of one
320		is used, unless otherwise noted.  Note that in this manual the
321		[count] is not mentioned in the description of the command,
322		but only in the explanation.  This was done to make the
323		commands easier to look up.  If the 'showcmd' option is on,
324		the (partially) entered count is shown at the bottom of the
325		window.  You can use <Del> to erase the last digit (|N<Del>|).
326
327							*[quotex]*
328["x]		An optional register designation where text can be stored.
329		See |registers|.  The x is a single character between 'a' and
330		'z' or 'A' and 'Z' or '"', and in some cases (with the put
331		command) between '0' and '9', '%', '#', or others.  The
332		uppercase and lowercase letter designate the same register,
333		but the lowercase letter is used to overwrite the previous
334		register contents, while the uppercase letter is used to
335		append to the previous register contents.  Without the ""x" or
336		with """" the stored text is put into the unnamed register.
337
338							*{}*
339{}		Curly braces denote parts of the command which must appear,
340		but which can take a number of different values.  The
341		differences between Vim and Vi are also given in curly braces
342		(this will be clear from the context).
343
344							*{char1-char2}*
345{char1-char2}	A single character from the range char1 to char2.  For
346		example: {a-z} is a lowercase letter.  Multiple ranges may be
347		concatenated.  For example, {a-zA-Z0-9} is any alphanumeric
348		character.
349
350						*{motion}* *movement*
351{motion}	A command that moves the cursor.  These are explained in
352		|motion.txt|.  Examples:
353			w		to start of next word
354			b		to begin of current word
355			4j		four lines down
356			/The<CR>	to next occurrence of "The"
357		This is used after an |operator| command to move over the text
358		that is to be operated upon.
359		- If the motion includes a count and the operator also has a
360		  count, the two counts are multiplied.  For example: "2d3w"
361		  deletes six words.
362		- The motion can be backwards, e.g. "db" to delete to the
363		  start of the word.
364		- The motion can also be a mouse click.  The mouse is not
365		  supported in every terminal though.
366		- The ":omap" command can be used to map characters while an
367		  operator is pending.
368		- Ex commands can be used to move the cursor.  This can be
369		  used to call a function that does some complicated motion.
370		  The motion is always characterwise exclusive, no matter
371		  what ":" command is used.  This means it's impossible to
372		  include the last character of a line without the line break
373		  (unless 'virtualedit' is set).
374		  If the Ex command changes the text before where the operator
375		  starts or jumps to another buffer the result is
376		  unpredictable.  It is possible to change the text further
377		  down.  Jumping to another buffer is possible if the current
378		  buffer is not unloaded.
379
380							*{Visual}*
381{Visual}	A selected text area.  It is started with the "v", "V", or
382		CTRL-V command, then any cursor movement command can be used
383		to change the end of the selected text.
384		This is used before an |operator| command to highlight the
385		text that is to be operated upon.
386		See |Visual-mode|.
387
388							*<character>*
389<character>	A special character from the table below, optionally with
390		modifiers, or a single ASCII character with modifiers.
391
392							*'character'*
393'c'		A single ASCII character.
394
395							*CTRL-{char}*
396CTRL-{char}	{char} typed as a control character; that is, typing {char}
397		while holding the CTRL key down.  The case of {char} does not
398		matter; thus CTRL-A and CTRL-a are equivalent.  But on some
399		terminals, using the SHIFT key will produce another code,
400		don't use it then.
401
402							*'option'*
403'option'	An option, or parameter, that can be set to a value, is
404		enclosed in single quotes.  See |options|.
405
406							*quotecommandquote*
407"command"	A reference to a command that you can type is enclosed in
408		double quotes.
409`command`	New style command, this distinguishes it from other quoted
410		text and strings.
411
412					*key-notation* *key-codes* *keycodes*
413These names for keys are used in the documentation.  They can also be used
414with the ":map" command (insert the key name by pressing CTRL-K and then the
415key you want the name for).
416
417notation	meaning		    equivalent	decimal value(s)	~
418-----------------------------------------------------------------------
419<Nul>		zero			CTRL-@	  0 (stored as 10) *<Nul>*
420<BS>		backspace		CTRL-H	  8	*backspace*
421<Tab>		tab			CTRL-I	  9	*tab* *Tab*
422							*linefeed*
423<NL>		linefeed		CTRL-J	 10 (used for <Nul>)
424<CR>		carriage return		CTRL-M	 13	*carriage-return*
425<Return>	same as <CR>				*<Return>*
426<Enter>		same as <CR>				*<Enter>*
427<Esc>		escape			CTRL-[	 27	*escape* *<Esc>*
428<Space>		space				 32	*space*
429<lt>		less-than		<	 60	*<lt>*
430<Bslash>	backslash		\	 92	*backslash* *<Bslash>*
431<Bar>		vertical bar		|	124	*<Bar>*
432<Del>		delete				127
433<CSI>		command sequence intro  ALT-Esc 155	*<CSI>*
434<xCSI>		CSI when typed in the GUI		*<xCSI>*
435
436<EOL>		end-of-line (can be <CR>, <NL> or <CR><NL>,
437		depends on system and 'fileformat')	*<EOL>*
438
439<Up>		cursor-up			*cursor-up* *cursor_up*
440<Down>		cursor-down			*cursor-down* *cursor_down*
441<Left>		cursor-left			*cursor-left* *cursor_left*
442<Right>		cursor-right			*cursor-right* *cursor_right*
443<S-Up>		shift-cursor-up
444<S-Down>	shift-cursor-down
445<S-Left>	shift-cursor-left
446<S-Right>	shift-cursor-right
447<C-Left>	control-cursor-left
448<C-Right>	control-cursor-right
449<F1> - <F12>	function keys 1 to 12		*function_key* *function-key*
450<S-F1> - <S-F12> shift-function keys 1 to 12	*<S-F1>*
451<Help>		help key
452<Undo>		undo key
453<Insert>	insert key
454<Home>		home				*home*
455<End>		end				*end*
456<PageUp>	page-up				*page_up* *page-up*
457<PageDown>	page-down			*page_down* *page-down*
458<kHome>		keypad home (upper left)	*keypad-home*
459<kEnd>		keypad end (lower left)		*keypad-end*
460<kPageUp>	keypad page-up (upper right)	*keypad-page-up*
461<kPageDown>	keypad page-down (lower right)	*keypad-page-down*
462<kPlus>		keypad +			*keypad-plus*
463<kMinus>	keypad -			*keypad-minus*
464<kMultiply>	keypad *			*keypad-multiply*
465<kDivide>	keypad /			*keypad-divide*
466<kEnter>	keypad Enter			*keypad-enter*
467<kPoint>	keypad Decimal point		*keypad-point*
468<k0> - <k9>	keypad 0 to 9			*keypad-0* *keypad-9*
469<S-...>		shift-key			*shift* *<S-*
470<C-...>		control-key			*control* *ctrl* *<C-*
471<M-...>		alt-key or meta-key		*meta* *alt* *<M-*
472<A-...>		same as <M-...>			*<A-*
473<D-...>		command-key (Macintosh only)	*<D-*
474<t_xx>		key with "xx" entry in termcap
475-----------------------------------------------------------------------
476
477Note: The shifted cursor keys, the help key, and the undo key are only
478available on a few terminals.  On the Amiga, shifted function key 10 produces
479a code (CSI) that is also used by key sequences.  It will be recognized only
480after typing another key.
481
482Note: There are two codes for the delete key.  127 is the decimal ASCII value
483for the delete key, which is always recognized.  Some delete keys send another
484value, in which case this value is obtained from the termcap entry "kD".  Both
485values have the same effect.  Also see |:fixdel|.
486
487Note: The keypad keys are used in the same way as the corresponding "normal"
488keys.  For example, <kHome> has the same effect as <Home>.  If a keypad key
489sends the same raw key code as its non-keypad equivalent, it will be
490recognized as the non-keypad code.  For example, when <kHome> sends the same
491code as <Home>, when pressing <kHome> Vim will think <Home> was pressed.
492Mapping <kHome> will not work then.
493
494								*<>*
495Examples are often given in the <> notation.  Sometimes this is just to make
496clear what you need to type, but often it can be typed literally, e.g., with
497the ":map" command.  The rules are:
498 1.  Any printable characters are typed directly, except backslash and '<'
499 2.  A backslash is represented with "\\", double backslash, or "<Bslash>".
500 3.  A real '<' is represented with "\<" or "<lt>".  When there is no
501     confusion possible, a '<' can be used directly.
502 4.  "<key>" means the special key typed.  This is the notation explained in
503     the table above.  A few examples:
504	   <Esc>		Escape key
505	   <C-G>		CTRL-G
506	   <Up>			cursor up key
507	   <C-LeftMouse>	Control- left mouse click
508	   <S-F11>		Shifted function key 11
509	   <M-a>		Meta- a  ('a' with bit 8 set)
510	   <M-A>		Meta- A  ('A' with bit 8 set)
511	   <t_kd>		"kd" termcap entry (cursor down key)
512    Although you can specify <M-{char}> with {char} being a multibyte
513    character, Vim may not be able to know what byte sequence that is and then
514    it won't work.
515
516If you want to use the full <> notation in Vim, you have to make sure the '<'
517flag is excluded from 'cpoptions' (when 'compatible' is not set, it already is
518by default). >
519	:set cpo-=<
520The <> notation uses <lt> to escape the special meaning of key names.  Using a
521backslash also works, but only when 'cpoptions' does not include the 'B' flag.
522
523Examples for mapping CTRL-H to the six characters "<Home>": >
524	:imap <C-H> \<Home>
525	:imap <C-H> <lt>Home>
526The first one only works when the 'B' flag is not in 'cpoptions'.  The second
527one always works.
528To get a literal "<lt>" in a mapping: >
529	:map <C-L> <lt>lt>
530
531For mapping, abbreviation and menu commands you can then copy-paste the
532examples and use them directly.  Or type them literally, including the '<' and
533'>' characters.  This does NOT work for other commands, like ":set" and
534":autocmd"!
535
536==============================================================================
5375. Modes, introduction				*vim-modes-intro* *vim-modes*
538
539Vim has seven BASIC modes:
540
541					*Normal* *Normal-mode* *command-mode*
542Normal mode		In Normal mode you can enter all the normal editor
543			commands.  If you start the editor you are in this
544			mode (unless you have set the 'insertmode' option,
545			see below).  This is also known as command mode.
546
547Visual mode		This is like Normal mode, but the movement commands
548			extend a highlighted area.  When a non-movement
549			command is used, it is executed for the highlighted
550			area.  See |Visual-mode|.
551			If the 'showmode' option is on "-- VISUAL --" is shown
552			at the bottom of the window.
553
554Select mode		This looks most like the MS-Windows selection mode.
555			Typing a printable character deletes the selection
556			and starts Insert mode.  See |Select-mode|.
557			If the 'showmode' option is on "-- SELECT --" is shown
558			at the bottom of the window.
559
560Insert mode		In Insert mode the text you type is inserted into the
561			buffer.  See |Insert-mode|.
562			If the 'showmode' option is on "-- INSERT --" is shown
563			at the bottom of the window.
564
565Command-line mode	In Command-line mode (also called Cmdline mode) you
566Cmdline mode		can enter one line of text at the bottom of the
567			window.  This is for the Ex commands, ":", the pattern
568			search commands, "?" and "/", and the filter command,
569			"!".  |Cmdline-mode|
570
571Ex mode			Like Command-line mode, but after entering a command
572			you remain in Ex mode.  Very limited editing of the
573			command line.  |Ex-mode|
574
575Terminal-Job mode	Interacting with a job in a terminal window.  Typed
576			keys go to the job and the job output is displayed in
577			the terminal window.  See |terminal| about how to
578			switch to other modes.
579
580There are seven ADDITIONAL modes.  These are variants of the BASIC modes:
581
582				*Operator-pending* *Operator-pending-mode*
583Operator-pending mode	This is like Normal mode, but after an operator
584			command has started, and Vim is waiting for a {motion}
585			to specify the text that the operator will work on.
586
587Replace mode		Replace mode is a special case of Insert mode.  You
588			can do the same things as in Insert mode, but for
589			each character you enter, one character of the existing
590			text is deleted.  See |Replace-mode|.
591			If the 'showmode' option is on "-- REPLACE --" is
592			shown at the bottom of the window.
593
594Virtual Replace mode	Virtual Replace mode is similar to Replace mode, but
595			instead of file characters you are replacing screen
596			real estate.  See |Virtual-Replace-mode|.
597			If the 'showmode' option is on "-- VREPLACE --" is
598			shown at the bottom of the window.
599
600Insert Normal mode	Entered when CTRL-O is typed in Insert mode (see
601			|i_CTRL-O|).  This is like Normal mode, but after
602			executing one command Vim returns to Insert mode.
603			If the 'showmode' option is on "-- (insert) --" is
604			shown at the bottom of the window.
605
606Terminal-Normal mode	Using Normal mode in a terminal window.  Making
607			changes is impossible.  Use an insert command, such as
608			"a" or "i", to return to Terminal-Job mode.
609
610Insert Visual mode	Entered when starting a Visual selection from Insert
611			mode, e.g., by using CTRL-O and then "v", "V" or
612			CTRL-V.  When the Visual selection ends, Vim returns
613			to Insert mode.
614			If the 'showmode' option is on "-- (insert) VISUAL --"
615			is shown at the bottom of the window.
616
617Insert Select mode	Entered when starting Select mode from Insert mode.
618			E.g., by dragging the mouse or <S-Right>.
619			When the Select mode ends, Vim returns to Insert mode.
620			If the 'showmode' option is on "-- (insert) SELECT --"
621			is shown at the bottom of the window.
622
623==============================================================================
6246. Switching from mode to mode				*mode-switching*
625
626If for any reason you do not know which mode you are in, you can always get
627back to Normal mode by typing <Esc> twice.  This doesn't work for Ex mode
628though, use ":visual".
629You will know you are back in Normal mode when you see the screen flash or
630hear the bell after you type <Esc>.  However, when pressing <Esc> after using
631CTRL-O in Insert mode you get a beep but you are still in Insert mode, type
632<Esc> again.
633
634							*i_esc*
635		TO mode						    ~
636		Normal	Visual	Select	Insert	  Replace   Cmd-line  Ex ~
637FROM mode								 ~
638Normal			v V ^V	  *4	 *1	   R gR     : / ? !   Q
639Visual		 *2		  ^G	 c C	    --	      :       --
640Select		 *5	^O ^G		 *6	    --	      --      --
641Insert		 <Esc>	  --	  --		  <Insert>    --      --
642Replace		 <Esc>	  --	  --	<Insert>	      --      --
643Command-line	 *3	  --	  --	 :start	    --		      --
644Ex		 :vi	  --	  --	 --	    --	      --
645
646-- not possible
647
648*1 Go from Normal mode to Insert mode by giving the command "i", "I", "a",
649   "A", "o", "O", "c", "C", "s" or S".
650*2 Go from Visual mode to Normal mode by giving a non-movement command, which
651   causes the command to be executed, or by hitting <Esc> "v", "V" or "CTRL-V"
652   (see |v_v|), which just stops Visual mode without side effects.
653*3 Go from Command-line mode to Normal mode by:
654   - Hitting <CR> or <NL>, which causes the entered command to be executed.
655   - Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>.
656   - Hitting CTRL-C or <Esc>, which quits the command-line without executing
657     the command.
658   In the last case <Esc> may be the character defined with the 'wildchar'
659   option, in which case it will start command-line completion.  You can
660   ignore that and type <Esc> again.
661*4 Go from Normal to Select mode by:
662   - use the mouse to select text while 'selectmode' contains "mouse"
663   - use a non-printable command to move the cursor while keeping the Shift
664     key pressed, and the 'selectmode' option contains "key"
665   - use "v", "V" or "CTRL-V" while 'selectmode' contains "cmd"
666   - use "gh", "gH" or "g CTRL-H"  |g_CTRL-H|
667*5 Go from Select mode to Normal mode by using a non-printable command to move
668   the cursor, without keeping the Shift key pressed.
669*6 Go from Select mode to Insert mode by typing a printable character.  The
670   selection is deleted and the character is inserted.
671
672If the 'insertmode' option is on, editing a file will start in Insert mode.
673
674	*CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N* *v_CTRL-\_CTRL-N*
675Additionally the command CTRL-\ CTRL-N or <C-\><C-N> can be used to go to
676Normal mode from any other mode.  This can be used to make sure Vim is in
677Normal mode, without causing a beep like <Esc> would.  However, this does not
678work in Ex mode.  When used after a command that takes an argument, such as
679|f| or |m|, the timeout set with 'ttimeoutlen' applies.
680When focus is in a terminal window, CTRL-\ CTRL-N goes to Normal mode until an
681edit command is entered, see |t_CTRL-\_CTRL-N|.
682
683	*CTRL-\_CTRL-G* *i_CTRL-\_CTRL-G* *c_CTRL-\_CTRL-G* *v_CTRL-\_CTRL-G*
684The command CTRL-\ CTRL-G or <C-\><C-G> can be used to go to Insert mode when
685'insertmode' is set.  Otherwise it goes to Normal mode.  This can be used to
686make sure Vim is in the mode indicated by 'insertmode', without knowing in
687what mode Vim currently is.
688
689				    *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
690Q			Switch to "Ex" mode.  This is a bit like typing ":"
691			commands one after another, except:
692			- You don't have to keep pressing ":".
693			- The screen doesn't get updated after each command.
694			- There is no normal command-line editing.
695			- Mappings and abbreviations are not used.
696			In fact, you are editing the lines with the "standard"
697			line-input editing commands (<Del> or <BS> to erase,
698			CTRL-U to kill the whole line).
699			Vim will enter this mode by default if it's invoked as
700			"ex" on the command-line.
701			Use the ":vi" command |:visual| to exit "Ex" mode.
702			Note: In older versions of Vim "Q" formatted text,
703			that is now done with |gq|.  But if you use the
704			|vimrc_example.vim| script "Q" works like "gq".
705
706					*gQ*
707gQ			Switch to "Ex" mode like with "Q", but really behave
708			like typing ":" commands after another.  All command
709			line editing, completion etc. is available.
710			Use the ":vi" command |:visual| to exit "Ex" mode.
711
712==============================================================================
7137. The window contents					*window-contents*
714
715In Normal mode and Insert/Replace mode the screen window will show the current
716contents of the buffer: What You See Is What You Get.  There are two
717exceptions:
718- When the 'cpoptions' option contains '$', and the change is within one line,
719  the text is not directly deleted, but a '$' is put at the last deleted
720  character.
721- When inserting text in one window, other windows on the same text are not
722  updated until the insert is finished.
723
724Lines longer than the window width will wrap, unless the 'wrap' option is off
725(see below).  The 'linebreak' option can be set to wrap at a blank character.
726
727If the window has room after the last line of the buffer, Vim will show '~' in
728the first column of the last lines in the window, like this:
729
730	+-----------------------+
731	|some line		|
732	|last line		|
733	|~			|
734	|~			|
735	+-----------------------+
736
737Thus the '~' lines indicate that the end of the buffer was reached.
738
739If the last line in a window doesn't fit, Vim will indicate this with a '@' in
740the first column of the last lines in the window, like this:
741
742	+-----------------------+
743	|first line		|
744	|second line		|
745	|@			|
746	|@			|
747	+-----------------------+
748
749Thus the '@' lines indicate that there is a line that doesn't fit in the
750window.
751
752When the "lastline" flag is present in the 'display' option, you will not see
753'@' characters at the left side of window.  If the last line doesn't fit
754completely, only the part that fits is shown, and the last three characters of
755the last line are replaced with "@@@", like this:
756
757	+-----------------------+
758	|first line		|
759	|second line		|
760	|a very long line that d|
761	|oesn't fit in the wi@@@|
762	+-----------------------+
763
764If there is a single line that is too long to fit in the window, this is a
765special situation.  Vim will show only part of the line, around where the
766cursor is.  There are no special characters shown, so that you can edit all
767parts of this line.
768
769The '@' occasion in the 'highlight' option can be used to set special
770highlighting for the '@' and '~' characters.  This makes it possible to
771distinguish them from real characters in the buffer.
772
773The 'showbreak' option contains the string to put in front of wrapped lines.
774
775							*wrap-off*
776If the 'wrap' option is off, long lines will not wrap.  Only the part that
777fits on the screen is shown.  If the cursor is moved to a part of the line
778that is not shown, the screen is scrolled horizontally.  The advantage of
779this method is that columns are shown as they are and lines that cannot fit
780on the screen can be edited.  The disadvantage is that you cannot see all the
781characters of a line at once.  The 'sidescroll' option can be set to the
782minimal number of columns to scroll.
783
784All normal ASCII characters are displayed directly on the screen.  The <Tab>
785is replaced with the number of spaces that it represents.  Other non-printing
786characters are replaced with "^{char}", where {char} is the non-printing
787character with 64 added.  Thus character 7 (bell) will be shown as "^G".
788Characters between 127 and 160 are replaced with "~{char}", where {char} is
789the character with 64 subtracted.  These characters occupy more than one
790position on the screen.  The cursor can only be positioned on the first one.
791
792If you set the 'number' option, all lines will be preceded with their
793number.  Tip: If you don't like wrapping lines to mix with the line numbers,
794set the 'showbreak' option to eight spaces:
795	":set showbreak=\ \ \ \ \ \ \ \ "
796
797If you set the 'list' option, <Tab> characters will not be shown as several
798spaces, but as "^I".  A '$' will be placed at the end of the line, so you can
799find trailing blanks.
800
801In Command-line mode only the command-line itself is shown correctly.  The
802display of the buffer contents is updated as soon as you go back to Command
803mode.
804
805The last line of the window is used for status and other messages.  The
806status messages will only be used if an option is on:
807
808status message			option	     default	Unix default	~
809current mode			'showmode'	on	    on
810command characters		'showcmd'	on	    off
811cursor position			'ruler'		off	    off
812
813The current mode is "-- INSERT --" or "-- REPLACE --", see |'showmode'|.  The
814command characters are those that you typed but were not used yet.
815
816If you have a slow terminal you can switch off the status messages to speed
817up editing:
818	:set nosc noru nosm
819
820If there is an error, an error message will be shown for at least one second
821(in reverse video).
822
823Some commands show how many lines were affected.  Above which threshold this
824happens can be controlled with the 'report' option (default 2).
825
826On the Amiga Vim will run in a CLI window.  The name Vim and the full name of
827the current file name will be shown in the title bar.  When the window is
828resized, Vim will automatically redraw the window.  You may make the window as
829small as you like, but if it gets too small not a single line will fit in it.
830Make it at least 40 characters wide to be able to read most messages on the
831last line.
832
833On most Unix systems, resizing the window is recognized and handled correctly
834by Vim.
835
836==============================================================================
8378. Definitions						*definitions*
838
839  buffer		Contains lines of text, usually read from a file.
840  screen		The whole area that Vim uses to work in.  This can be
841			a terminal emulator window.  Also called "the Vim
842			window".
843  window		A view on a buffer.  There can be multiple windows for
844			one buffer.
845
846A screen contains one or more windows, separated by status lines and with the
847command line at the bottom.
848
849	+-------------------------------+
850screen	| window 1	| window 2	|
851	|		|		|
852	|		|		|
853	|= status line =|= status line =|
854	| window 3			|
855	|				|
856	|				|
857	|==== status line ==============|
858	|command line			|
859	+-------------------------------+
860
861The command line is also used for messages.  It scrolls up the screen when
862there is not enough room in the command line.
863
864A difference is made between four types of lines:
865
866  buffer lines		The lines in the buffer.  This is the same as the
867			lines as they are read from/written to a file.  They
868			can be thousands of characters long.
869  logical lines		The buffer lines with folding applied.  Buffer lines
870			in a closed fold are changed to a single logical line:
871			"+-- 99 lines folded".  They can be thousands of
872			characters long.
873  window lines		The lines displayed in a window: A range of logical
874			lines with wrapping, line breaks, etc.  applied.  They
875			can only be as long as the width of the window allows,
876			longer lines are wrapped or truncated.
877  screen lines		The lines of the screen that Vim uses.  Consists of
878			the window lines of all windows, with status lines
879			and the command line added.  They can only be as long
880			as the width of the screen allows.  When the command
881			line gets longer it wraps and lines are scrolled to
882			make room.
883
884buffer lines	logical lines	window lines	screen lines ~
885
8861. one		1. one		1. +-- folded   1.  +-- folded
8872. two		2. +-- folded	2. five		2.  five
8883. three	3. five		3. six		3.  six
8894. four		4. six		4. seven	4.  seven
8905. five		5. seven			5.  === status line ===
8916. six						6.  aaa
8927. seven					7.  bbb
893						8.  ccc ccc c
8941. aaa		1. aaa		1. aaa		9.  cc
8952. bbb		2. bbb		2. bbb		10. ddd
8963. ccc ccc ccc	3. ccc ccc ccc	3. ccc ccc c	11. ~
8974. ddd		4. ddd		4. cc		12. === status line ===
898				5. ddd		13. (command line)
899				6. ~
900
901==============================================================================
902 vim:tw=78:ts=8:noet:ft=help:norl:
903