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