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