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