1 *intro.txt* For Vim version 7.1. Last change: 2008 Jan 10
4 VIM REFERENCE MANUAL by Bram Moolenaar
7 Introduction to Vim *ref* *reference*
9 1. Introduction |intro|
10 2. Vim on the internet |internet|
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
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|.
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
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*
90 This group is also for other editors. If you write about Vim, don't forget to
93 *mail-list* *maillist*
94 There are several mailing lists for Vim:
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
109 <vim-mac@vim.org> *vim-mac*
110 For discussions about using and improving the Macintosh version of
113 See http://www.vim.org/maillist.php for the latest information.
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.
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 For more information and archives look on the Vim maillist page:
128 http://www.vim.org/maillist.php
131 Bug reports: *bugs* *bug-reports* *bugreport.vim*
133 Send bug reports to: Vim bugs <bugs@vim.org>
134 This is not a maillist but the message is redirected to the Vim maintainer.
135 Please be brief; all the time that is spent on answering mail is subtracted
136 from the time that is spent on improving Vim! Always give a reproducible
137 example and try to find out which settings or other things influence the
138 appearance of the bug. Try different machines, if possible. Send me patches
141 It will help to include information about the version of Vim you are using and
142 your setup. You can get the information with this command: >
143 :so $VIMRUNTIME/bugreport.vim
144 This will create a file "bugreport.txt" in the current directory, with a lot
145 of information of your environment. Before sending this out, check if it
146 doesn't contain any confidential information!
148 If Vim crashes, please try to find out where. You can find help on this here:
151 In case of doubt or when you wonder if the problem has already been fixed but
152 you can't find a fix for it, become a member of the vim-dev maillist and ask
153 your question there. |maillist|
156 Since Vim internally doesn't use dates for editing, there is no year 2000
157 problem to worry about. Vim does use the time in the form of seconds since
158 January 1st 1970. It is used for a time-stamp check of the edited file and
159 the swap file, which is not critical and should only cause warning messages.
161 There might be a year 2038 problem, when the seconds don't fit in a 32 bit int
162 anymore. This depends on the compiler, libraries and operating system.
163 Specifically, time_t and the ctime() function are used. And the time_t is
164 stored in four bytes in the swap file. But that's only used for printing a
165 file date/time for recovery, it will never affect normal editing.
167 The Vim strftime() function directly uses the strftime() system function.
168 localtime() uses the time() system function. getftime() uses the time
169 returned by the stat() system function. If your system libraries are year
170 2000 compliant, Vim is too.
172 The user may create scripts for Vim that use external commands. These might
173 introduce Y2K problems, but those are not really part of Vim itself.
175 ==============================================================================
176 3. Credits *credits* *author* *Bram* *Moolenaar*
178 Most of Vim was written by Bram Moolenaar <Bram@vim.org>.
180 Parts of the documentation come from several Vi manuals, written by:
185 The Vim editor is based on Stevie and includes (ideas from) other software,
186 worked on by the people mentioned here. Other people helped by sending me
187 patches, suggestions and giving feedback about what is good and bad in Vim.
189 Vim would never have become what it is now, without the help of these people!
191 Ron Aaron Win32 GUI changes
192 Zoltan Arpadffy work on VMS port
194 Gert van Antwerpen changes for DJGPP on MS-DOS
195 Berkeley DB(3) ideas for swap file implementation
197 Walter Briscoe Makefile updates, various patches
198 Ralf Brown SPAWNO library for MS-DOS
199 Robert Colon many useful remarks
200 Marcin Dalecki GTK+ GUI port, toolbar icons, gettext()
201 Kayhan Demirel sent me news in Uganda
202 Chris & John Downey xvi (ideas for multi-windows version)
203 Henk Elbers first VMS port
204 Daniel Elstner GTK+ 2 port
205 Eric Fischer Mac port, 'cindent', and other improvements
206 Benji Fisher Answering lots of user questions
207 Bill Foster Athena GUI port
208 Google Lets me work on Vim one day a week
209 Loic Grenie xvim (ideas for multi windows version)
210 Sven Guckes Vim promotor and previous WWW page maintainer
211 Darren Hiebert Exuberant ctags
212 Jason Hildebrand GTK+ 2 port
213 Bruce Hunsaker improvements for VMS port
214 Andy Kahn Cscope support, GTK+ GUI port
215 Oezguer Kesim Maintainer of Vim Mailing Lists
216 Axel Kielhorn work on the Macintosh port
217 Steve Kirkendall Elvis
218 Roger Knobbe original port to Windows NT
219 Sergey Laskavy Vim's help from Moscow
220 Felix von Leitner Previous maintainer of Vim Mailing Lists
221 David Leonard Port of Python extensions to Unix
222 Avner Lottem Edit in right-to-left windows
223 Flemming Madsen X11 client-server, various features and patches
224 Microsoft Gave me a copy of DevStudio to compile Vim with
225 Paul Moore Python interface extensions, many patches
226 Katsuhito Nagano Work on multi-byte versions
227 Sung-Hyun Nam Work on multi-byte versions
228 Vince Negri Win32 GUI and generic console enhancements
229 Steve Oualline Author of the first Vim book |frombook|
230 Dominique Pelle figuring out valgrind reports and fixes
231 A.Politz Many bug reports and some fixes
232 George V. Reilly Win32 port, Win32 GUI start-off
233 Stephen Riehm bug collector
234 Stefan Roemer various patches and help to users
235 Ralf Schandl IBM OS/390 port
236 Olaf Seibert DICE and BeBox version, regexp improvements
237 Mortaza Shiran Farsi patches
238 Peter da Silva termlib
239 Paul Slootman OS/2 port
240 Henry Spencer regular expressions
241 Dany St-Amant Macintosh port
243 G. R. (Fred) Walter Stevie
244 Sven Verdoolaege Perl interface
245 Robert Webb Command-line completion, GUI versions, and
247 Ingo Wilken Tcl interface
248 Mike Williams PostScript printing
249 Juergen Weigert Lattice version, AUX improvements, UNIX and
250 MS-DOS ports, autoconf
251 Stefan 'Sec' Zehl Maintainer of vim.org
253 I wish to thank all the people that sent me bug reports and suggestions. The
254 list is too long to mention them all here. Vim would not be the same without
255 the ideas from all these people: They keep Vim alive!
258 In this documentation there are several references to other versions of Vi:
260 Vi "the original". Without further remarks this is the version
261 of Vi that appeared in Sun OS 4.x. ":version" returns
262 "Version 3.7, 6/7/85". Sometimes other versions are referred
263 to. Only runs under Unix. Source code only available with a
264 license. More information on Vi can be found through:
265 http://vi-editor.org [doesn't currently work...]
267 Posix From the IEEE standard 1003.2, Part 2: Shell and utilities.
268 Generally known as "Posix". This is a textual description of
269 how Vi is supposed to work.
270 See |posix-compliance|.
272 Nvi The "New" Vi. The version of Vi that comes with BSD 4.4 and FreeBSD.
273 Very good compatibility with the original Vi, with a few extensions.
274 The version used is 1.79. ":version" returns "Version 1.79
275 (10/23/96)". There has been no release the last few years, although
276 there is a development version 1.81.
277 Source code is freely available.
279 Elvis Another Vi clone, made by Steve Kirkendall. Very compact but isn't
281 The version used is 2.1. It is still being developed. Source code is
284 ==============================================================================
285 4. Notation *notation*
287 When syntax highlighting is used to read this, text that is not typed
288 literally is often highlighted with the Special group. These are items in [],
289 {} and <>, and CTRL-X.
291 Note that Vim uses all possible characters in commands. Sometimes the [], {}
292 and <> are part of what you type, the context should make this clear.
295 [] Characters in square brackets are optional.
297 *count* *[count]* *E489*
298 [count] An optional number that may precede the command to multiply
299 or iterate the command. If no number is given, a count of one
300 is used, unless otherwise noted. Note that in this manual the
301 [count] is not mentioned in the description of the command,
302 but only in the explanation. This was done to make the
303 commands easier to look up. If the 'showcmd' option is on,
304 the (partially) entered count is shown at the bottom of the
305 window. You can use <Del> to erase the last digit (|N<Del>|).
308 ["x] An optional register designation where text can be stored.
309 See |registers|. The x is a single character between 'a' and
310 'z' or 'A' and 'Z' or '"', and in some cases (with the put
311 command) between '0' and '9', '%', '#', or others. The
312 uppercase and lowercase letter designate the same register,
313 but the lowercase letter is used to overwrite the previous
314 register contents, while the uppercase letter is used to
315 append to the previous register contents. Without the ""x" or
316 with """" the stored text is put into the unnamed register.
319 {} Curly braces denote parts of the command which must appear,
320 but which can take a number of different values. The
321 differences between Vim and Vi are also given in curly braces
322 (this will be clear from the context).
325 {char1-char2} A single character from the range char1 to char2. For
326 example: {a-z} is a lowercase letter. Multiple ranges may be
327 concatenated. For example, {a-zA-Z0-9} is any alphanumeric
330 *{motion}* *movement*
331 {motion} A command that moves the cursor. These are explained in
332 |motion.txt|. Examples:
333 w to start of next word
334 b to begin of current word
336 /The<CR> to next occurrence of "The"
337 This is used after an |operator| command to move over the text
338 that is to be operated upon.
339 - If the motion includes a count and the operator also has a
340 count, the two counts are multiplied. For example: "2d3w"
342 - The motion can be backwards, e.g. "db" to delete to the
344 - The motion can also be a mouse click. The mouse is not
345 supported in every terminal though.
346 - The ":omap" command can be used to map characters while an
348 - Ex commands can be used to move the cursor. This can be
349 used to call a function that does some complicated motion.
350 The motion is always characterwise exclusive, no matter
351 what ":" command is used. This means it's impossible to
352 include the last character of a line without the line break
353 (unless 'virtualedit' is set).
354 If the Ex command changes the text before where the operator
355 starts or jumps to another buffer the result is
356 unpredictable. It is possible to change the text further
357 down. Jumping to another buffer is possible if the current
358 buffer is not unloaded.
361 {Visual} A selected text area. It is started with the "v", "V", or
362 CTRL-V command, then any cursor movement command can be used
363 to change the end of the selected text.
364 This is used before an |operator| command to highlight the
365 text that is to be operated upon.
369 <character> A special character from the table below, optionally with
370 modifiers, or a single ASCII character with modifiers.
373 'c' A single ASCII character.
376 CTRL-{char} {char} typed as a control character; that is, typing {char}
377 while holding the CTRL key down. The case of {char} does not
378 matter; thus CTRL-A and CTRL-a are equivalent. But on some
379 terminals, using the SHIFT key will produce another code,
383 'option' An option, or parameter, that can be set to a value, is
384 enclosed in single quotes. See |options|.
387 "command" A reference to a command that you can type is enclosed in
390 *key-notation* *key-codes* *keycodes*
391 These names for keys are used in the documentation. They can also be used
392 with the ":map" command (insert the key name by pressing CTRL-K and then the
393 key you want the name for).
395 notation meaning equivalent decimal value(s) ~
396 -----------------------------------------------------------------------
397 <Nul> zero CTRL-@ 0 (stored as 10) *<Nul>*
398 <BS> backspace CTRL-H 8 *backspace*
399 <Tab> tab CTRL-I 9 *tab* *Tab*
401 <NL> linefeed CTRL-J 10 (used for <Nul>)
402 <FF> formfeed CTRL-L 12 *formfeed*
403 <CR> carriage return CTRL-M 13 *carriage-return*
404 <Return> same as <CR> *<Return>*
405 <Enter> same as <CR> *<Enter>*
406 <Esc> escape CTRL-[ 27 *escape* *<Esc>*
407 <Space> space 32 *space*
408 <lt> less-than < 60 *<lt>*
409 <Bslash> backslash \ 92 *backslash* *<Bslash>*
410 <Bar> vertical bar | 124 *<Bar>*
412 <CSI> command sequence intro ALT-Esc 155 *<CSI>*
413 <xCSI> CSI when typed in the GUI *<xCSI>*
415 <EOL> end-of-line (can be <CR>, <LF> or <CR><LF>,
416 depends on system and 'fileformat') *<EOL>*
418 <Up> cursor-up *cursor-up* *cursor_up*
419 <Down> cursor-down *cursor-down* *cursor_down*
420 <Left> cursor-left *cursor-left* *cursor_left*
421 <Right> cursor-right *cursor-right* *cursor_right*
422 <S-Up> shift-cursor-up
423 <S-Down> shift-cursor-down
424 <S-Left> shift-cursor-left
425 <S-Right> shift-cursor-right
426 <C-Left> control-cursor-left
427 <C-Right> control-cursor-right
428 <F1> - <F12> function keys 1 to 12 *function_key* *function-key*
429 <S-F1> - <S-F12> shift-function keys 1 to 12 *<S-F1>*
435 <PageUp> page-up *page_up* *page-up*
436 <PageDown> page-down *page_down* *page-down*
437 <kHome> keypad home (upper left) *keypad-home*
438 <kEnd> keypad end (lower left) *keypad-end*
439 <kPageUp> keypad page-up (upper right) *keypad-page-up*
440 <kPageDown> keypad page-down (lower right) *keypad-page-down*
441 <kPlus> keypad + *keypad-plus*
442 <kMinus> keypad - *keypad-minus*
443 <kMultiply> keypad * *keypad-multiply*
444 <kDivide> keypad / *keypad-divide*
445 <kEnter> keypad Enter *keypad-enter*
446 <kPoint> keypad Decimal point *keypad-point*
447 <k0> - <k9> keypad 0 to 9 *keypad-0* *keypad-9*
448 <S-...> shift-key *shift* *<S-*
449 <C-...> control-key *control* *ctrl* *<C-*
450 <M-...> alt-key or meta-key *meta* *alt* *<M-*
451 <A-...> same as <M-...> *<A-*
452 <D-...> command-key (Macintosh only) *<D-*
453 <t_xx> key with "xx" entry in termcap
454 -----------------------------------------------------------------------
456 Note: The shifted cursor keys, the help key, and the undo key are only
457 available on a few terminals. On the Amiga, shifted function key 10 produces
458 a code (CSI) that is also used by key sequences. It will be recognized only
459 after typing another key.
461 Note: There are two codes for the delete key. 127 is the decimal ASCII value
462 for the delete key, which is always recognized. Some delete keys send another
463 value, in which case this value is obtained from the termcap entry "kD". Both
464 values have the same effect. Also see |:fixdel|.
466 Note: The keypad keys are used in the same way as the corresponding "normal"
467 keys. For example, <kHome> has the same effect as <Home>. If a keypad key
468 sends the same raw key code as its non-keypad equivalent, it will be
469 recognized as the non-keypad code. For example, when <kHome> sends the same
470 code as <Home>, when pressing <kHome> Vim will think <Home> was pressed.
471 Mapping <kHome> will not work then.
474 Examples are often given in the <> notation. Sometimes this is just to make
475 clear what you need to type, but often it can be typed literally, e.g., with
476 the ":map" command. The rules are:
477 1. Any printable characters are typed directly, except backslash and '<'
478 2. A backslash is represented with "\\", double backslash, or "<Bslash>".
479 3. A real '<' is represented with "\<" or "<lt>". When there is no
480 confusion possible, a '<' can be used directly.
481 4. "<key>" means the special key typed. This is the notation explained in
482 the table above. A few examples:
486 <C-LeftMouse> Control- left mouse click
487 <S-F11> Shifted function key 11
488 <M-a> Meta- a ('a' with bit 8 set)
489 <M-A> Meta- A ('A' with bit 8 set)
490 <t_kd> "kd" termcap entry (cursor down key)
492 If you want to use the full <> notation in Vim, you have to make sure the '<'
493 flag is excluded from 'cpoptions' (when 'compatible' is not set, it already is
496 The <> notation uses <lt> to escape the special meaning of key names. Using a
497 backslash also works, but only when 'cpoptions' does not include the 'B' flag.
499 Examples for mapping CTRL-H to the six characters "<Home>": >
501 :imap <C-H> <lt>Home>
502 The first one only works when the 'B' flag is not in 'cpoptions'. The second
504 To get a literal "<lt>" in a mapping: >
507 For mapping, abbreviation and menu commands you can then copy-paste the
508 examples and use them directly. Or type them literally, including the '<' and
509 '>' characters. This does NOT work for other commands, like ":set" and
512 ==============================================================================
513 5. Modes, introduction *vim-modes-intro* *vim-modes*
515 Vim has six BASIC modes:
517 *Normal* *Normal-mode* *command-mode*
518 Normal mode In Normal mode you can enter all the normal editor
519 commands. If you start the editor you are in this
520 mode (unless you have set the 'insertmode' option,
521 see below). This is also known as command mode.
523 Visual mode This is like Normal mode, but the movement commands
524 extend a highlighted area. When a non-movement
525 command is used, it is executed for the highlighted
526 area. See |Visual-mode|.
527 If the 'showmode' option is on "-- VISUAL --" is shown
528 at the bottom of the window.
530 Select mode This looks most like the MS-Windows selection mode.
531 Typing a printable character deletes the selection
532 and starts Insert mode. See |Select-mode|.
533 If the 'showmode' option is on "-- SELECT --" is shown
534 at the bottom of the window.
536 Insert mode In Insert mode the text you type is inserted into the
537 buffer. See |Insert-mode|.
538 If the 'showmode' option is on "-- INSERT --" is shown
539 at the bottom of the window.
541 Command-line mode In Command-line mode (also called Cmdline mode) you
542 Cmdline mode can enter one line of text at the bottom of the
543 window. This is for the Ex commands, ":", the pattern
544 search commands, "?" and "/", and the filter command,
547 Ex mode Like Command-line mode, but after entering a command
548 you remain in Ex mode. Very limited editing of the
549 command line. |Ex-mode|
551 There are five ADDITIONAL modes. These are variants of the BASIC modes:
553 *Operator-pending* *Operator-pending-mode*
554 Operator-pending mode This is like Normal mode, but after an operator
555 command has started, and Vim is waiting for a {motion}
556 to specify the text that the operator will work on.
558 Replace mode Replace mode is a special case of Insert mode. You
559 can do the same things as in Insert mode, but for
560 each character you enter, one character of the existing
561 text is deleted. See |Replace-mode|.
562 If the 'showmode' option is on "-- REPLACE --" is
563 shown at the bottom of the window.
565 Insert Normal mode Entered when CTRL-O given in Insert mode. This is
566 like Normal mode, but after executing one command Vim
567 returns to Insert mode.
568 If the 'showmode' option is on "-- (insert) --" is
569 shown at the bottom of the window.
571 Insert Visual mode Entered when starting a Visual selection from Insert
572 mode, e.g., by using CTRL-O and then "v", "V" or
573 CTRL-V. When the Visual selection ends, Vim returns
575 If the 'showmode' option is on "-- (insert) VISUAL --"
576 is shown at the bottom of the window.
578 Insert Select mode Entered when starting Select mode from Insert mode.
579 E.g., by dragging the mouse or <S-Right>.
580 When the Select mode ends, Vim returns to Insert mode.
581 If the 'showmode' option is on "-- (insert) SELECT --"
582 is shown at the bottom of the window.
584 ==============================================================================
585 6. Switching from mode to mode *mode-switching*
587 If for any reason you do not know which mode you are in, you can always get
588 back to Normal mode by typing <Esc> twice. This doesn't work for Ex mode
589 though, use ":visual".
590 You will know you are back in Normal mode when you see the screen flash or
591 hear the bell after you type <Esc>. However, when pressing <Esc> after using
592 CTRL-O in Insert mode you get a beep but you are still in Insert mode, type
597 Normal Visual Select Insert Replace Cmd-line Ex ~
599 Normal v V ^V *4 *1 R : / ? ! Q
600 Visual *2 ^G c C -- : --
601 Select *5 ^O ^G *6 -- -- --
602 Insert <Esc> -- -- <Insert> -- --
603 Replace <Esc> -- -- <Insert> -- --
604 Command-line *3 -- -- :start -- --
605 Ex :vi -- -- -- -- --
610 *1 Go from Normal mode to Insert mode by giving the command "i", "I", "a",
611 "A", "o", "O", "c", "C", "s" or S".
612 *2 Go from Visual mode to Normal mode by giving a non-movement command, which
613 causes the command to be executed, or by hitting <Esc> "v", "V" or "CTRL-V"
614 (see |v_v|), which just stops Visual mode without side effects.
615 *3 Go from Command-line mode to Normal mode by:
616 - Hitting <CR> or <NL>, which causes the entered command to be executed.
617 - Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>.
618 - Hitting CTRL-C or <Esc>, which quits the command-line without executing
620 In the last case <Esc> may be the character defined with the 'wildchar'
621 option, in which case it will start command-line completion. You can
622 ignore that and type <Esc> again. {Vi: when hitting <Esc> the command-line
623 is executed. This is unexpected for most people; therefore it was changed
624 in Vim. But when the <Esc> is part of a mapping, the command-line is
625 executed. If you want the Vi behaviour also when typing <Esc>, use ":cmap
627 *4 Go from Normal to Select mode by:
628 - use the mouse to select text while 'selectmode' contains "mouse"
629 - use a non-printable command to move the cursor while keeping the Shift
630 key pressed, and the 'selectmode' option contains "key"
631 - use "v", "V" or "CTRL-V" while 'selectmode' contains "cmd"
632 - use "gh", "gH" or "g CTRL-H" |g_CTRL-H|
633 *5 Go from Select mode to Normal mode by using a non-printable command to move
634 the cursor, without keeping the Shift key pressed.
635 *6 Go from Select mode to Insert mode by typing a printable character. The
636 selection is deleted and the character is inserted.
638 If the 'insertmode' option is on, editing a file will start in Insert mode.
640 *CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N* *v_CTRL-\_CTRL-N*
641 Additionally the command CTRL-\ CTRL-N or <C-\><C-N> can be used to go to
642 Normal mode from any other mode. This can be used to make sure Vim is in
643 Normal mode, without causing a beep like <Esc> would. However, this does not
644 work in Ex mode. When used after a command that takes an argument, such as
645 |f| or |m|, the timeout set with 'ttimeoutlen' applies.
647 *CTRL-\_CTRL-G* *i_CTRL-\_CTRL-G* *c_CTRL-\_CTRL-G* *v_CTRL-\_CTRL-G*
648 The command CTRL-\ CTRL-G or <C-\><C-G> can be used to go to Insert mode when
649 'insertmode' is set. Otherwise it goes to Normal mode. This can be used to
650 make sure Vim is in the mode indicated by 'insertmode', without knowing in
651 what mode Vim currently is.
653 *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
654 Q Switch to "Ex" mode. This is a bit like typing ":"
655 commands one after another, except:
656 - You don't have to keep pressing ":".
657 - The screen doesn't get updated after each command.
658 - There is no normal command-line editing.
659 - Mappings and abbreviations are not used.
660 In fact, you are editing the lines with the "standard"
661 line-input editing commands (<Del> or <BS> to erase,
662 CTRL-U to kill the whole line).
663 Vim will enter this mode by default if it's invoked as
664 "ex" on the command-line.
665 Use the ":vi" command |:visual| to exit "Ex" mode.
666 Note: In older versions of Vim "Q" formatted text,
667 that is now done with |gq|. But if you use the
668 |vimrc_example.vim| script "Q" works like "gq".
671 gQ Switch to "Ex" mode like with "Q", but really behave
672 like typing ":" commands after another. All command
673 line editing, completion etc. is available.
674 Use the ":vi" command |:visual| to exit "Ex" mode.
677 ==============================================================================
678 7. The window contents *window-contents*
680 In Normal mode and Insert/Replace mode the screen window will show the current
681 contents of the buffer: What You See Is What You Get. There are two
683 - When the 'cpoptions' option contains '$', and the change is within one line,
684 the text is not directly deleted, but a '$' is put at the last deleted
686 - When inserting text in one window, other windows on the same text are not
687 updated until the insert is finished.
688 {Vi: The screen is not always updated on slow terminals}
690 Lines longer than the window width will wrap, unless the 'wrap' option is off
691 (see below). The 'linebreak' option can be set to wrap at a blank character.
693 If the window has room after the last line of the buffer, Vim will show '~' in
694 the first column of the last lines in the window, like this: >
696 +-----------------------+
701 +-----------------------+
703 Thus the '~' lines indicate that the end of the buffer was reached.
705 If the last line in a window doesn't fit, Vim will indicate this with a '@' in
706 the first column of the last lines in the window, like this: >
708 +-----------------------+
713 +-----------------------+
715 Thus the '@' lines indicate that there is a line that doesn't fit in the
718 When the "lastline" flag is present in the 'display' option, you will not see
719 '@' characters at the left side of window. If the last line doesn't fit
720 completely, only the part that fits is shown, and the last three characters of
721 the last line are replaced with "@@@", like this: >
723 +-----------------------+
726 |a very long line that d|
727 |oesn't fit in the wi@@@|
728 +-----------------------+
730 If there is a single line that is too long to fit in the window, this is a
731 special situation. Vim will show only part of the line, around where the
732 cursor is. There are no special characters shown, so that you can edit all
734 {Vi: gives an "internal error" on lines that do not fit in the window}
736 The '@' occasion in the 'highlight' option can be used to set special
737 highlighting for the '@' and '~' characters. This makes it possible to
738 distinguish them from real characters in the buffer.
740 The 'showbreak' option contains the string to put in front of wrapped lines.
743 If the 'wrap' option is off, long lines will not wrap. Only the part that
744 fits on the screen is shown. If the cursor is moved to a part of the line
745 that is not shown, the screen is scrolled horizontally. The advantage of
746 this method is that columns are shown as they are and lines that cannot fit
747 on the screen can be edited. The disadvantage is that you cannot see all the
748 characters of a line at once. The 'sidescroll' option can be set to the
749 minimal number of columns to scroll. {Vi: has no 'wrap' option}
751 All normal ASCII characters are displayed directly on the screen. The <Tab>
752 is replaced with the number of spaces that it represents. Other non-printing
753 characters are replaced with "^{char}", where {char} is the non-printing
754 character with 64 added. Thus character 7 (bell) will be shown as "^G".
755 Characters between 127 and 160 are replaced with "~{char}", where {char} is
756 the character with 64 subtracted. These characters occupy more than one
757 position on the screen. The cursor can only be positioned on the first one.
759 If you set the 'number' option, all lines will be preceded with their
760 number. Tip: If you don't like wrapping lines to mix with the line numbers,
761 set the 'showbreak' option to eight spaces:
762 ":set showbreak=\ \ \ \ \ \ \ \ "
764 If you set the 'list' option, <Tab> characters will not be shown as several
765 spaces, but as "^I". A '$' will be placed at the end of the line, so you can
766 find trailing blanks.
768 In Command-line mode only the command-line itself is shown correctly. The
769 display of the buffer contents is updated as soon as you go back to Command
772 The last line of the window is used for status and other messages. The
773 status messages will only be used if an option is on:
775 status message option default Unix default ~
776 current mode 'showmode' on on
777 command characters 'showcmd' on off
778 cursor position 'ruler' off off
780 The current mode is "-- INSERT --" or "-- REPLACE --", see |'showmode'|. The
781 command characters are those that you typed but were not used yet. {Vi: does
782 not show the characters you typed or the cursor position}
784 If you have a slow terminal you can switch off the status messages to speed
788 If there is an error, an error message will be shown for at least one second
789 (in reverse video). {Vi: error messages may be overwritten with other
790 messages before you have a chance to read them}
792 Some commands show how many lines were affected. Above which threshold this
793 happens can be controlled with the 'report' option (default 2).
795 On the Amiga Vim will run in a CLI window. The name Vim and the full name of
796 the current file name will be shown in the title bar. When the window is
797 resized, Vim will automatically redraw the window. You may make the window as
798 small as you like, but if it gets too small not a single line will fit in it.
799 Make it at least 40 characters wide to be able to read most messages on the
802 On most Unix systems, resizing the window is recognized and handled correctly
805 ==============================================================================
806 8. Definitions *definitions*
808 screen The whole area that Vim uses to work in. This can be
809 a terminal emulator window. Also called "the Vim
811 window A view on a buffer.
813 A screen contains one or more windows, separated by status lines and with the
814 command line at the bottom.
816 +-------------------------------+
817 screen | window 1 | window 2 |
820 |= status line =|= status line =|
824 |==== status line ==============|
826 +-------------------------------+
828 The command line is also used for messages. It scrolls up the screen when
829 there is not enough room in the command line.
831 A difference is made between four types of lines:
833 buffer lines The lines in the buffer. This is the same as the
834 lines as they are read from/written to a file. They
835 can be thousands of characters long.
836 logical lines The buffer lines with folding applied. Buffer lines
837 in a closed fold are changed to a single logical line:
838 "+-- 99 lines folded". They can be thousands of
840 window lines The lines displayed in a window: A range of logical
841 lines with wrapping, line breaks, etc. applied. They
842 can only be as long as the width of the window allows,
843 longer lines are wrapped or truncated.
844 screen lines The lines of the screen that Vim uses. Consists of
845 the window lines of all windows, with status lines
846 and the command line added. They can only be as long
847 as the width of the screen allows. When the command
848 line gets longer it wraps and lines are scrolled to
851 buffer lines logical lines window lines screen lines ~
853 1. one 1. one 1. +-- folded 1. +-- folded
854 2. two 2. +-- folded 2. five 2. five
855 3. three 3. five 3. six 3. six
856 4. four 4. six 4. seven 4. seven
857 5. five 5. seven 5. === status line ===
861 1. aaa 1. aaa 1. aaa 9. cc
862 2. bbb 2. bbb 2. bbb 10. ddd
863 3. ccc ccc ccc 3. ccc ccc ccc 3. ccc ccc c 11. ~
864 4. ddd 4. ddd 4. cc 12. === status line ===
865 5. ddd 13. (command line)
868 ==============================================================================
869 vim:tw=78:ts=8:ft=help:norl: