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