blob: 106245b838fa06b87e5964db83fb2069a261a97a [file] [log] [blame]
Bram Moolenaard09091d2019-01-17 16:07:22 +01001*intro.txt* For Vim version 8.1. Last change: 2019 Jan 07
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
Bram Moolenaar4c05fa02019-01-01 15:32:17 +010055 *book* *books*
56Most books on Vi and Vim contain a section for beginners. Others are spending
57more words on specific functionality. You can find an overview of Vim books
58here:
59 http://iccf-holland.org/vim_books.html
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
61==============================================================================
622. Vim on the internet *internet*
63
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000064 *www* *WWW* *faq* *FAQ* *distribution* *download*
Bram Moolenaar071d4272004-06-13 20:20:40 +000065The Vim pages contain the most recent information about Vim. They also
66contain links to the most recent version of Vim. The FAQ is a list of
67Frequently Asked Questions. Read this if you have problems.
68
Bram Moolenaar4c05fa02019-01-01 15:32:17 +010069 Vim home page: https://www.vim.org/
70 Vim FAQ: https://vimhelp.appspot.com/vim_faq.txt.html
71 Downloading: https://www.vim.org/download.php
Bram Moolenaar071d4272004-06-13 20:20:40 +000072
73
74Usenet News group where Vim is discussed: *news* *usenet*
75 comp.editors
76This group is also for other editors. If you write about Vim, don't forget to
77mention that.
78
79 *mail-list* *maillist*
80There are several mailing lists for Vim:
Bram Moolenaar68563932017-01-10 13:31:15 +010081<vim@vim.org> *vim-use* *vim_use*
Bram Moolenaar071d4272004-06-13 20:20:40 +000082 For discussions about using existing versions of Vim: Useful mappings,
Bram Moolenaarc6fe9192006-04-09 21:54:49 +000083 questions, answers, where to get a specific version, etc. There are
84 quite a few people watching this list and answering questions, also
85 for beginners. Don't hesitate to ask your question here.
Bram Moolenaar68563932017-01-10 13:31:15 +010086<vim-dev@vim.org> *vim-dev* *vim_dev* *vimdev*
Bram Moolenaar071d4272004-06-13 20:20:40 +000087 For discussions about changing Vim: New features, porting, patches,
88 beta-test versions, etc.
Bram Moolenaar68563932017-01-10 13:31:15 +010089<vim-announce@vim.org> *vim-announce* *vim_announce*
Bram Moolenaar071d4272004-06-13 20:20:40 +000090 Announcements about new versions of Vim; also for beta-test versions
Bram Moolenaarc6fe9192006-04-09 21:54:49 +000091 and ports to different systems. This is a read-only list.
Bram Moolenaar68563932017-01-10 13:31:15 +010092<vim-mac@vim.org> *vim-mac* *vim_mac*
Bram Moolenaar071d4272004-06-13 20:20:40 +000093 For discussions about using and improving the Macintosh version of
94 Vim.
95
96See http://www.vim.org/maillist.php for the latest information.
97
98NOTE:
Bram Moolenaar4c05fa02019-01-01 15:32:17 +010099- Anyone can see the archive, e.g. on Google groups. Search this if you have
100 questions.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101- You can only send messages to these lists if you have subscribed!
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100102- The first message is moderated, thus it may take a few hours to show up.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103- You need to send the messages from the same location as where you subscribed
104 from (to avoid spam mail).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105
106 *subscribe-maillist*
107If you want to join, send a message to
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000108 <vim-subscribe@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109Make sure that your "From:" address is correct. Then the list server will
110give you help on how to subscribe.
111
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000112 *maillist-archive*
113For more information and archives look on the Vim maillist page:
114http://www.vim.org/maillist.php
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115
116
117Bug reports: *bugs* *bug-reports* *bugreport.vim*
118
Bram Moolenaar3e496b02016-09-25 22:11:48 +0200119There are two ways to report bugs, both work:
1201. Send bug reports to: Vim Developers <vim-dev@vim.org>
121 This is a maillist, you need to become a member first and many people will
122 see the message. If you don't want that, e.g. because it is a security
123 issue, send it to <bugs@vim.org>, this only goes to the Vim maintainer
124 (that's Bram).
Bram Moolenaar40962ec2018-01-28 22:47:25 +01001252. Open an issue on GitHub: https://github.com/vim/vim/issues
Bram Moolenaar3e496b02016-09-25 22:11:48 +0200126 The text will be forwarded to the vim-dev maillist.
Bram Moolenaar822ff862014-06-12 21:46:14 +0200127
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128Please be brief; all the time that is spent on answering mail is subtracted
129from the time that is spent on improving Vim! Always give a reproducible
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200130example and try to find out which settings or other things trigger the bug.
131
132Preferably start Vim with: >
133 vim --clean -u reproduce.vim
134Where reproduce.vim is a script that reproduces the problem. Try different
135machines, if relevant (is this an MS-Windows specific bug perhaps?).
136
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100137Send me patches if you can! If you create a pull request on
138https://github.com/vim/vim then the automated checks will run and report any
139obvious problems. But you can also send the patch by email (use an attachment
140to avoid white space changes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141
Bram Moolenaare344bea2005-09-01 20:46:49 +0000142It will help to include information about the version of Vim you are using and
143your setup. You can get the information with this command: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144 :so $VIMRUNTIME/bugreport.vim
145This will create a file "bugreport.txt" in the current directory, with a lot
146of information of your environment. Before sending this out, check if it
147doesn't contain any confidential information!
148
Bram Moolenaare344bea2005-09-01 20:46:49 +0000149If Vim crashes, please try to find out where. You can find help on this here:
150|debug.txt|.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151
Bram Moolenaare344bea2005-09-01 20:46:49 +0000152In case of doubt or when you wonder if the problem has already been fixed but
153you can't find a fix for it, become a member of the vim-dev maillist and ask
154your question there. |maillist|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000155
156 *year-2000* *Y2K*
157Since Vim internally doesn't use dates for editing, there is no year 2000
158problem to worry about. Vim does use the time in the form of seconds since
159January 1st 1970. It is used for a time-stamp check of the edited file and
160the swap file, which is not critical and should only cause warning messages.
161
162There might be a year 2038 problem, when the seconds don't fit in a 32 bit int
163anymore. This depends on the compiler, libraries and operating system.
164Specifically, time_t and the ctime() function are used. And the time_t is
165stored in four bytes in the swap file. But that's only used for printing a
166file date/time for recovery, it will never affect normal editing.
167
168The Vim strftime() function directly uses the strftime() system function.
169localtime() uses the time() system function. getftime() uses the time
170returned by the stat() system function. If your system libraries are year
1712000 compliant, Vim is too.
172
173The user may create scripts for Vim that use external commands. These might
174introduce Y2K problems, but those are not really part of Vim itself.
175
176==============================================================================
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001773. Credits *credits* *author* *Bram* *Moolenaar*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000178
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100179Most of Vim was created by Bram Moolenaar <Bram@vim.org>.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180
181Parts of the documentation come from several Vi manuals, written by:
182 W.N. Joy
183 Alan P.W. Hewett
184 Mark Horton
185
186The Vim editor is based on Stevie and includes (ideas from) other software,
187worked on by the people mentioned here. Other people helped by sending me
188patches, suggestions and giving feedback about what is good and bad in Vim.
189
190Vim would never have become what it is now, without the help of these people!
191
192 Ron Aaron Win32 GUI changes
Bram Moolenaar91604412010-06-03 20:25:18 +0200193 Mohsin Ahmed encryption
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194 Zoltan Arpadffy work on VMS port
195 Tony Andrews Stevie
196 Gert van Antwerpen changes for DJGPP on MS-DOS
197 Berkeley DB(3) ideas for swap file implementation
198 Keith Bostic Nvi
199 Walter Briscoe Makefile updates, various patches
200 Ralf Brown SPAWNO library for MS-DOS
201 Robert Colon many useful remarks
202 Marcin Dalecki GTK+ GUI port, toolbar icons, gettext()
203 Kayhan Demirel sent me news in Uganda
204 Chris & John Downey xvi (ideas for multi-windows version)
205 Henk Elbers first VMS port
Bram Moolenaar7b0294c2004-10-11 10:16:09 +0000206 Daniel Elstner GTK+ 2 port
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207 Eric Fischer Mac port, 'cindent', and other improvements
208 Benji Fisher Answering lots of user questions
209 Bill Foster Athena GUI port
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000210 Google Lets me work on Vim one day a week
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211 Loic Grenie xvim (ideas for multi windows version)
Bram Moolenaarc236c162008-07-13 17:41:49 +0000212 Sven Guckes Vim promoter and previous WWW page maintainer
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213 Darren Hiebert Exuberant ctags
Bram Moolenaar7b0294c2004-10-11 10:16:09 +0000214 Jason Hildebrand GTK+ 2 port
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215 Bruce Hunsaker improvements for VMS port
216 Andy Kahn Cscope support, GTK+ GUI port
217 Oezguer Kesim Maintainer of Vim Mailing Lists
218 Axel Kielhorn work on the Macintosh port
219 Steve Kirkendall Elvis
220 Roger Knobbe original port to Windows NT
221 Sergey Laskavy Vim's help from Moscow
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000222 Felix von Leitner Previous maintainer of Vim Mailing Lists
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223 David Leonard Port of Python extensions to Unix
224 Avner Lottem Edit in right-to-left windows
225 Flemming Madsen X11 client-server, various features and patches
Bram Moolenaar91604412010-06-03 20:25:18 +0200226 Tony Mechelynck answers many user questions
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227 Paul Moore Python interface extensions, many patches
228 Katsuhito Nagano Work on multi-byte versions
229 Sung-Hyun Nam Work on multi-byte versions
230 Vince Negri Win32 GUI and generic console enhancements
231 Steve Oualline Author of the first Vim book |frombook|
Bram Moolenaar91604412010-06-03 20:25:18 +0200232 Dominique Pelle valgrind reports and many fixes
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000233 A.Politz Many bug reports and some fixes
Bram Moolenaar071d4272004-06-13 20:20:40 +0000234 George V. Reilly Win32 port, Win32 GUI start-off
235 Stephen Riehm bug collector
236 Stefan Roemer various patches and help to users
237 Ralf Schandl IBM OS/390 port
238 Olaf Seibert DICE and BeBox version, regexp improvements
239 Mortaza Shiran Farsi patches
240 Peter da Silva termlib
241 Paul Slootman OS/2 port
242 Henry Spencer regular expressions
243 Dany St-Amant Macintosh port
244 Tim Thompson Stevie
245 G. R. (Fred) Walter Stevie
246 Sven Verdoolaege Perl interface
247 Robert Webb Command-line completion, GUI versions, and
248 lots of patches
249 Ingo Wilken Tcl interface
250 Mike Williams PostScript printing
251 Juergen Weigert Lattice version, AUX improvements, UNIX and
252 MS-DOS ports, autoconf
253 Stefan 'Sec' Zehl Maintainer of vim.org
Bram Moolenaar37c64c72017-09-19 22:06:03 +0200254 Yasuhiro Matsumoto many MS-Windows improvements
255 Ken Takata fixes and features
256 Kazunobu Kuriyama GTK 3
257 Christian Brabandt many fixes, features, user support, etc.
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100258 Yegappan Lakshmanan many quickfix features
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259
260I wish to thank all the people that sent me bug reports and suggestions. The
261list is too long to mention them all here. Vim would not be the same without
262the ideas from all these people: They keep Vim alive!
Bram Moolenaar56b45b92013-06-24 22:22:18 +0200263*love* *peace* *friendship* *gross-national-happiness*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264
265
266In this documentation there are several references to other versions of Vi:
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000267 *Vi* *vi*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268Vi "the original". Without further remarks this is the version
269 of Vi that appeared in Sun OS 4.x. ":version" returns
270 "Version 3.7, 6/7/85". Sometimes other versions are referred
Bram Moolenaard09091d2019-01-17 16:07:22 +0100271 to. Only runs under Unix. Source code is now available under a
272 BSD-style license. More information on Vi can be found through:
273 http://ex-vi.sourceforge.net/
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274 *Posix*
275Posix From the IEEE standard 1003.2, Part 2: Shell and utilities.
276 Generally known as "Posix". This is a textual description of
277 how Vi is supposed to work.
Bram Moolenaar7c626922005-02-07 22:01:03 +0000278 See |posix-compliance|.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279 *Nvi*
280Nvi The "New" Vi. The version of Vi that comes with BSD 4.4 and FreeBSD.
281 Very good compatibility with the original Vi, with a few extensions.
282 The version used is 1.79. ":version" returns "Version 1.79
283 (10/23/96)". There has been no release the last few years, although
284 there is a development version 1.81.
285 Source code is freely available.
286 *Elvis*
287Elvis Another Vi clone, made by Steve Kirkendall. Very compact but isn't
Bram Moolenaard09091d2019-01-17 16:07:22 +0100288 as flexible as Vim. Development has stalled, Elvis has left the
289 building! Source code is freely available.
290 *Neovim*
291Neovim A Vim clone. Forked the Vim source in 2014 and went a different way.
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100292 Very much bound to github and has many more dependencies, making
293 development more complex and limiting portability. Code has been
294 refactored, resulting in patches not being exchangeable with Vim.
295 Supports a remote GUI and integration with scripting languages.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000296
297==============================================================================
2984. Notation *notation*
299
300When syntax highlighting is used to read this, text that is not typed
301literally is often highlighted with the Special group. These are items in [],
302{} and <>, and CTRL-X.
303
304Note that Vim uses all possible characters in commands. Sometimes the [], {}
305and <> are part of what you type, the context should make this clear.
306
307
308[] Characters in square brackets are optional.
309
Bram Moolenaar4a748032010-09-30 21:47:56 +0200310 *count* *[count]*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311[count] An optional number that may precede the command to multiply
312 or iterate the command. If no number is given, a count of one
313 is used, unless otherwise noted. Note that in this manual the
314 [count] is not mentioned in the description of the command,
315 but only in the explanation. This was done to make the
316 commands easier to look up. If the 'showcmd' option is on,
317 the (partially) entered count is shown at the bottom of the
318 window. You can use <Del> to erase the last digit (|N<Del>|).
319
320 *[quotex]*
321["x] An optional register designation where text can be stored.
322 See |registers|. The x is a single character between 'a' and
323 'z' or 'A' and 'Z' or '"', and in some cases (with the put
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000324 command) between '0' and '9', '%', '#', or others. The
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325 uppercase and lowercase letter designate the same register,
326 but the lowercase letter is used to overwrite the previous
327 register contents, while the uppercase letter is used to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000328 append to the previous register contents. Without the ""x" or
Bram Moolenaar071d4272004-06-13 20:20:40 +0000329 with """" the stored text is put into the unnamed register.
330
331 *{}*
332{} Curly braces denote parts of the command which must appear,
333 but which can take a number of different values. The
334 differences between Vim and Vi are also given in curly braces
335 (this will be clear from the context).
336
337 *{char1-char2}*
338{char1-char2} A single character from the range char1 to char2. For
339 example: {a-z} is a lowercase letter. Multiple ranges may be
340 concatenated. For example, {a-zA-Z0-9} is any alphanumeric
341 character.
342
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000343 *{motion}* *movement*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000344{motion} A command that moves the cursor. These are explained in
345 |motion.txt|. Examples:
346 w to start of next word
347 b to begin of current word
348 4j four lines down
349 /The<CR> to next occurrence of "The"
350 This is used after an |operator| command to move over the text
351 that is to be operated upon.
352 - If the motion includes a count and the operator also has a
353 count, the two counts are multiplied. For example: "2d3w"
354 deletes six words.
355 - The motion can be backwards, e.g. "db" to delete to the
356 start of the word.
357 - The motion can also be a mouse click. The mouse is not
358 supported in every terminal though.
359 - The ":omap" command can be used to map characters while an
360 operator is pending.
361 - Ex commands can be used to move the cursor. This can be
362 used to call a function that does some complicated motion.
363 The motion is always characterwise exclusive, no matter
364 what ":" command is used. This means it's impossible to
365 include the last character of a line without the line break
366 (unless 'virtualedit' is set).
367 If the Ex command changes the text before where the operator
368 starts or jumps to another buffer the result is
369 unpredictable. It is possible to change the text further
370 down. Jumping to another buffer is possible if the current
371 buffer is not unloaded.
372
373 *{Visual}*
374{Visual} A selected text area. It is started with the "v", "V", or
375 CTRL-V command, then any cursor movement command can be used
376 to change the end of the selected text.
377 This is used before an |operator| command to highlight the
378 text that is to be operated upon.
379 See |Visual-mode|.
380
381 *<character>*
382<character> A special character from the table below, optionally with
383 modifiers, or a single ASCII character with modifiers.
384
385 *'character'*
386'c' A single ASCII character.
387
388 *CTRL-{char}*
389CTRL-{char} {char} typed as a control character; that is, typing {char}
390 while holding the CTRL key down. The case of {char} does not
391 matter; thus CTRL-A and CTRL-a are equivalent. But on some
392 terminals, using the SHIFT key will produce another code,
393 don't use it then.
394
395 *'option'*
396'option' An option, or parameter, that can be set to a value, is
397 enclosed in single quotes. See |options|.
398
399 *quotecommandquote*
400"command" A reference to a command that you can type is enclosed in
401 double quotes.
Bram Moolenaar00154502013-02-13 16:15:55 +0100402`command` New style command, this distinguishes it from other quoted
403 text and strings.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404
405 *key-notation* *key-codes* *keycodes*
406These names for keys are used in the documentation. They can also be used
407with the ":map" command (insert the key name by pressing CTRL-K and then the
408key you want the name for).
409
410notation meaning equivalent decimal value(s) ~
411-----------------------------------------------------------------------
412<Nul> zero CTRL-@ 0 (stored as 10) *<Nul>*
413<BS> backspace CTRL-H 8 *backspace*
414<Tab> tab CTRL-I 9 *tab* *Tab*
415 *linefeed*
416<NL> linefeed CTRL-J 10 (used for <Nul>)
417<FF> formfeed CTRL-L 12 *formfeed*
418<CR> carriage return CTRL-M 13 *carriage-return*
419<Return> same as <CR> *<Return>*
420<Enter> same as <CR> *<Enter>*
421<Esc> escape CTRL-[ 27 *escape* *<Esc>*
422<Space> space 32 *space*
423<lt> less-than < 60 *<lt>*
424<Bslash> backslash \ 92 *backslash* *<Bslash>*
425<Bar> vertical bar | 124 *<Bar>*
426<Del> delete 127
427<CSI> command sequence intro ALT-Esc 155 *<CSI>*
428<xCSI> CSI when typed in the GUI *<xCSI>*
429
430<EOL> end-of-line (can be <CR>, <LF> or <CR><LF>,
431 depends on system and 'fileformat') *<EOL>*
432
433<Up> cursor-up *cursor-up* *cursor_up*
434<Down> cursor-down *cursor-down* *cursor_down*
435<Left> cursor-left *cursor-left* *cursor_left*
436<Right> cursor-right *cursor-right* *cursor_right*
437<S-Up> shift-cursor-up
438<S-Down> shift-cursor-down
439<S-Left> shift-cursor-left
440<S-Right> shift-cursor-right
441<C-Left> control-cursor-left
442<C-Right> control-cursor-right
443<F1> - <F12> function keys 1 to 12 *function_key* *function-key*
444<S-F1> - <S-F12> shift-function keys 1 to 12 *<S-F1>*
445<Help> help key
446<Undo> undo key
447<Insert> insert key
448<Home> home *home*
449<End> end *end*
450<PageUp> page-up *page_up* *page-up*
451<PageDown> page-down *page_down* *page-down*
452<kHome> keypad home (upper left) *keypad-home*
453<kEnd> keypad end (lower left) *keypad-end*
454<kPageUp> keypad page-up (upper right) *keypad-page-up*
455<kPageDown> keypad page-down (lower right) *keypad-page-down*
456<kPlus> keypad + *keypad-plus*
457<kMinus> keypad - *keypad-minus*
458<kMultiply> keypad * *keypad-multiply*
459<kDivide> keypad / *keypad-divide*
460<kEnter> keypad Enter *keypad-enter*
461<kPoint> keypad Decimal point *keypad-point*
462<k0> - <k9> keypad 0 to 9 *keypad-0* *keypad-9*
463<S-...> shift-key *shift* *<S-*
464<C-...> control-key *control* *ctrl* *<C-*
465<M-...> alt-key or meta-key *meta* *alt* *<M-*
466<A-...> same as <M-...> *<A-*
467<D-...> command-key (Macintosh only) *<D-*
468<t_xx> key with "xx" entry in termcap
469-----------------------------------------------------------------------
470
471Note: The shifted cursor keys, the help key, and the undo key are only
472available on a few terminals. On the Amiga, shifted function key 10 produces
473a code (CSI) that is also used by key sequences. It will be recognized only
474after typing another key.
475
476Note: There are two codes for the delete key. 127 is the decimal ASCII value
477for the delete key, which is always recognized. Some delete keys send another
478value, in which case this value is obtained from the termcap entry "kD". Both
479values have the same effect. Also see |:fixdel|.
480
481Note: The keypad keys are used in the same way as the corresponding "normal"
482keys. For example, <kHome> has the same effect as <Home>. If a keypad key
483sends the same raw key code as its non-keypad equivalent, it will be
484recognized as the non-keypad code. For example, when <kHome> sends the same
485code as <Home>, when pressing <kHome> Vim will think <Home> was pressed.
486Mapping <kHome> will not work then.
487
488 *<>*
489Examples are often given in the <> notation. Sometimes this is just to make
490clear what you need to type, but often it can be typed literally, e.g., with
491the ":map" command. The rules are:
492 1. Any printable characters are typed directly, except backslash and '<'
493 2. A backslash is represented with "\\", double backslash, or "<Bslash>".
494 3. A real '<' is represented with "\<" or "<lt>". When there is no
495 confusion possible, a '<' can be used directly.
496 4. "<key>" means the special key typed. This is the notation explained in
497 the table above. A few examples:
498 <Esc> Escape key
499 <C-G> CTRL-G
500 <Up> cursor up key
501 <C-LeftMouse> Control- left mouse click
502 <S-F11> Shifted function key 11
503 <M-a> Meta- a ('a' with bit 8 set)
504 <M-A> Meta- A ('A' with bit 8 set)
505 <t_kd> "kd" termcap entry (cursor down key)
506
507If you want to use the full <> notation in Vim, you have to make sure the '<'
508flag is excluded from 'cpoptions' (when 'compatible' is not set, it already is
509by default). >
510 :set cpo-=<
511The <> notation uses <lt> to escape the special meaning of key names. Using a
512backslash also works, but only when 'cpoptions' does not include the 'B' flag.
513
514Examples for mapping CTRL-H to the six characters "<Home>": >
515 :imap <C-H> \<Home>
516 :imap <C-H> <lt>Home>
517The first one only works when the 'B' flag is not in 'cpoptions'. The second
518one always works.
519To get a literal "<lt>" in a mapping: >
520 :map <C-L> <lt>lt>
521
522For mapping, abbreviation and menu commands you can then copy-paste the
523examples and use them directly. Or type them literally, including the '<' and
524'>' characters. This does NOT work for other commands, like ":set" and
525":autocmd"!
526
527==============================================================================
5285. Modes, introduction *vim-modes-intro* *vim-modes*
529
Bram Moolenaar1ccd8ff2017-08-11 19:50:37 +0200530Vim has seven BASIC modes:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531
532 *Normal* *Normal-mode* *command-mode*
533Normal mode In Normal mode you can enter all the normal editor
534 commands. If you start the editor you are in this
535 mode (unless you have set the 'insertmode' option,
536 see below). This is also known as command mode.
537
538Visual mode This is like Normal mode, but the movement commands
539 extend a highlighted area. When a non-movement
540 command is used, it is executed for the highlighted
541 area. See |Visual-mode|.
542 If the 'showmode' option is on "-- VISUAL --" is shown
543 at the bottom of the window.
544
545Select mode This looks most like the MS-Windows selection mode.
546 Typing a printable character deletes the selection
547 and starts Insert mode. See |Select-mode|.
548 If the 'showmode' option is on "-- SELECT --" is shown
549 at the bottom of the window.
550
551Insert mode In Insert mode the text you type is inserted into the
552 buffer. See |Insert-mode|.
553 If the 'showmode' option is on "-- INSERT --" is shown
554 at the bottom of the window.
555
556Command-line mode In Command-line mode (also called Cmdline mode) you
557Cmdline mode can enter one line of text at the bottom of the
558 window. This is for the Ex commands, ":", the pattern
559 search commands, "?" and "/", and the filter command,
560 "!". |Cmdline-mode|
561
562Ex mode Like Command-line mode, but after entering a command
563 you remain in Ex mode. Very limited editing of the
564 command line. |Ex-mode|
565
Bram Moolenaar1ccd8ff2017-08-11 19:50:37 +0200566Terminal-Job mode Interacting with a job in a terminal window. Typed
567 keys go to the job and the job output is displayed in
568 the terminal window. See |terminal| about how to
569 switch to other modes.
570
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200571There are seven ADDITIONAL modes. These are variants of the BASIC modes:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572
573 *Operator-pending* *Operator-pending-mode*
574Operator-pending mode This is like Normal mode, but after an operator
575 command has started, and Vim is waiting for a {motion}
576 to specify the text that the operator will work on.
577
578Replace mode Replace mode is a special case of Insert mode. You
579 can do the same things as in Insert mode, but for
580 each character you enter, one character of the existing
581 text is deleted. See |Replace-mode|.
582 If the 'showmode' option is on "-- REPLACE --" is
583 shown at the bottom of the window.
584
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000585Virtual Replace mode Virtual Replace mode is similar to Replace mode, but
586 instead of file characters you are replacing screen
587 real estate. See |Virtual-Replace-mode|.
588 If the 'showmode' option is on "-- VREPLACE --" is
589 shown at the bottom of the window.
590
Bram Moolenaard473c8c2018-08-11 18:00:22 +0200591Insert Normal mode Entered when CTRL-O is typed in Insert mode (see
592 |i_CTRL-O|). This is like Normal mode, but after
593 executing one command Vim returns to Insert mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 If the 'showmode' option is on "-- (insert) --" is
595 shown at the bottom of the window.
596
Bram Moolenaar1ccd8ff2017-08-11 19:50:37 +0200597Terminal-Normal mode Using Normal mode in a terminal window. Making
598 changes is impossible. Use an insert command, such as
599 "a" or "i", to return to Terminal-Job mode.
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200600
Bram Moolenaar071d4272004-06-13 20:20:40 +0000601Insert Visual mode Entered when starting a Visual selection from Insert
602 mode, e.g., by using CTRL-O and then "v", "V" or
603 CTRL-V. When the Visual selection ends, Vim returns
604 to Insert mode.
605 If the 'showmode' option is on "-- (insert) VISUAL --"
606 is shown at the bottom of the window.
607
608Insert Select mode Entered when starting Select mode from Insert mode.
609 E.g., by dragging the mouse or <S-Right>.
610 When the Select mode ends, Vim returns to Insert mode.
611 If the 'showmode' option is on "-- (insert) SELECT --"
612 is shown at the bottom of the window.
613
614==============================================================================
6156. Switching from mode to mode *mode-switching*
616
617If for any reason you do not know which mode you are in, you can always get
618back to Normal mode by typing <Esc> twice. This doesn't work for Ex mode
619though, use ":visual".
620You will know you are back in Normal mode when you see the screen flash or
621hear the bell after you type <Esc>. However, when pressing <Esc> after using
622CTRL-O in Insert mode you get a beep but you are still in Insert mode, type
623<Esc> again.
624
625 *i_esc*
626 TO mode ~
627 Normal Visual Select Insert Replace Cmd-line Ex ~
628FROM mode ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000629Normal v V ^V *4 *1 R gR : / ? ! Q
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630Visual *2 ^G c C -- : --
631Select *5 ^O ^G *6 -- -- --
632Insert <Esc> -- -- <Insert> -- --
633Replace <Esc> -- -- <Insert> -- --
634Command-line *3 -- -- :start -- --
635Ex :vi -- -- -- -- --
636
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637-- not possible
638
639*1 Go from Normal mode to Insert mode by giving the command "i", "I", "a",
640 "A", "o", "O", "c", "C", "s" or S".
641*2 Go from Visual mode to Normal mode by giving a non-movement command, which
642 causes the command to be executed, or by hitting <Esc> "v", "V" or "CTRL-V"
643 (see |v_v|), which just stops Visual mode without side effects.
644*3 Go from Command-line mode to Normal mode by:
645 - Hitting <CR> or <NL>, which causes the entered command to be executed.
646 - Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>.
647 - Hitting CTRL-C or <Esc>, which quits the command-line without executing
648 the command.
649 In the last case <Esc> may be the character defined with the 'wildchar'
650 option, in which case it will start command-line completion. You can
651 ignore that and type <Esc> again. {Vi: when hitting <Esc> the command-line
652 is executed. This is unexpected for most people; therefore it was changed
653 in Vim. But when the <Esc> is part of a mapping, the command-line is
654 executed. If you want the Vi behaviour also when typing <Esc>, use ":cmap
655 ^V<Esc> ^V^M"}
656*4 Go from Normal to Select mode by:
657 - use the mouse to select text while 'selectmode' contains "mouse"
658 - use a non-printable command to move the cursor while keeping the Shift
659 key pressed, and the 'selectmode' option contains "key"
660 - use "v", "V" or "CTRL-V" while 'selectmode' contains "cmd"
661 - use "gh", "gH" or "g CTRL-H" |g_CTRL-H|
662*5 Go from Select mode to Normal mode by using a non-printable command to move
663 the cursor, without keeping the Shift key pressed.
664*6 Go from Select mode to Insert mode by typing a printable character. The
665 selection is deleted and the character is inserted.
666
667If the 'insertmode' option is on, editing a file will start in Insert mode.
668
669 *CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N* *v_CTRL-\_CTRL-N*
670Additionally the command CTRL-\ CTRL-N or <C-\><C-N> can be used to go to
671Normal mode from any other mode. This can be used to make sure Vim is in
672Normal mode, without causing a beep like <Esc> would. However, this does not
673work in Ex mode. When used after a command that takes an argument, such as
674|f| or |m|, the timeout set with 'ttimeoutlen' applies.
Bram Moolenaar1ccd8ff2017-08-11 19:50:37 +0200675When focus is in a terminal window, CTRL-\ CTRL-N goes to Normal mode for only
676one command, see |t_CTRL-\_CTRL-N|.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000677
678 *CTRL-\_CTRL-G* *i_CTRL-\_CTRL-G* *c_CTRL-\_CTRL-G* *v_CTRL-\_CTRL-G*
679The command CTRL-\ CTRL-G or <C-\><C-G> can be used to go to Insert mode when
680'insertmode' is set. Otherwise it goes to Normal mode. This can be used to
681make sure Vim is in the mode indicated by 'insertmode', without knowing in
682what mode Vim currently is.
683
684 *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
685Q Switch to "Ex" mode. This is a bit like typing ":"
686 commands one after another, except:
687 - You don't have to keep pressing ":".
688 - The screen doesn't get updated after each command.
689 - There is no normal command-line editing.
690 - Mappings and abbreviations are not used.
691 In fact, you are editing the lines with the "standard"
692 line-input editing commands (<Del> or <BS> to erase,
693 CTRL-U to kill the whole line).
694 Vim will enter this mode by default if it's invoked as
695 "ex" on the command-line.
696 Use the ":vi" command |:visual| to exit "Ex" mode.
697 Note: In older versions of Vim "Q" formatted text,
698 that is now done with |gq|. But if you use the
699 |vimrc_example.vim| script "Q" works like "gq".
700
701 *gQ*
Bram Moolenaar7c626922005-02-07 22:01:03 +0000702gQ Switch to "Ex" mode like with "Q", but really behave
703 like typing ":" commands after another. All command
704 line editing, completion etc. is available.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705 Use the ":vi" command |:visual| to exit "Ex" mode.
706 {not in Vi}
707
708==============================================================================
7097. The window contents *window-contents*
710
711In Normal mode and Insert/Replace mode the screen window will show the current
712contents of the buffer: What You See Is What You Get. There are two
713exceptions:
714- When the 'cpoptions' option contains '$', and the change is within one line,
715 the text is not directly deleted, but a '$' is put at the last deleted
716 character.
717- When inserting text in one window, other windows on the same text are not
718 updated until the insert is finished.
719{Vi: The screen is not always updated on slow terminals}
720
721Lines longer than the window width will wrap, unless the 'wrap' option is off
722(see below). The 'linebreak' option can be set to wrap at a blank character.
723
724If the window has room after the last line of the buffer, Vim will show '~' in
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100725the first column of the last lines in the window, like this:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000726
727 +-----------------------+
728 |some line |
729 |last line |
730 |~ |
731 |~ |
732 +-----------------------+
733
734Thus the '~' lines indicate that the end of the buffer was reached.
735
736If the last line in a window doesn't fit, Vim will indicate this with a '@' in
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100737the first column of the last lines in the window, like this:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000738
739 +-----------------------+
740 |first line |
741 |second line |
742 |@ |
743 |@ |
744 +-----------------------+
745
746Thus the '@' lines indicate that there is a line that doesn't fit in the
747window.
748
749When the "lastline" flag is present in the 'display' option, you will not see
750'@' characters at the left side of window. If the last line doesn't fit
751completely, only the part that fits is shown, and the last three characters of
Bram Moolenaar81af9252010-12-10 20:35:50 +0100752the last line are replaced with "@@@", like this:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000753
754 +-----------------------+
755 |first line |
756 |second line |
757 |a very long line that d|
758 |oesn't fit in the wi@@@|
759 +-----------------------+
760
761If there is a single line that is too long to fit in the window, this is a
762special situation. Vim will show only part of the line, around where the
763cursor is. There are no special characters shown, so that you can edit all
764parts of this line.
765{Vi: gives an "internal error" on lines that do not fit in the window}
766
767The '@' occasion in the 'highlight' option can be used to set special
768highlighting for the '@' and '~' characters. This makes it possible to
769distinguish them from real characters in the buffer.
770
771The 'showbreak' option contains the string to put in front of wrapped lines.
772
773 *wrap-off*
774If the 'wrap' option is off, long lines will not wrap. Only the part that
775fits on the screen is shown. If the cursor is moved to a part of the line
776that is not shown, the screen is scrolled horizontally. The advantage of
777this method is that columns are shown as they are and lines that cannot fit
778on the screen can be edited. The disadvantage is that you cannot see all the
779characters of a line at once. The 'sidescroll' option can be set to the
780minimal number of columns to scroll. {Vi: has no 'wrap' option}
781
782All normal ASCII characters are displayed directly on the screen. The <Tab>
783is replaced with the number of spaces that it represents. Other non-printing
784characters are replaced with "^{char}", where {char} is the non-printing
785character with 64 added. Thus character 7 (bell) will be shown as "^G".
786Characters between 127 and 160 are replaced with "~{char}", where {char} is
787the character with 64 subtracted. These characters occupy more than one
788position on the screen. The cursor can only be positioned on the first one.
789
790If you set the 'number' option, all lines will be preceded with their
791number. Tip: If you don't like wrapping lines to mix with the line numbers,
792set the 'showbreak' option to eight spaces:
793 ":set showbreak=\ \ \ \ \ \ \ \ "
794
795If you set the 'list' option, <Tab> characters will not be shown as several
796spaces, but as "^I". A '$' will be placed at the end of the line, so you can
797find trailing blanks.
798
799In Command-line mode only the command-line itself is shown correctly. The
800display of the buffer contents is updated as soon as you go back to Command
801mode.
802
803The last line of the window is used for status and other messages. The
804status messages will only be used if an option is on:
805
806status message option default Unix default ~
807current mode 'showmode' on on
808command characters 'showcmd' on off
809cursor position 'ruler' off off
810
811The current mode is "-- INSERT --" or "-- REPLACE --", see |'showmode'|. The
812command characters are those that you typed but were not used yet. {Vi: does
813not show the characters you typed or the cursor position}
814
815If you have a slow terminal you can switch off the status messages to speed
816up editing:
817 :set nosc noru nosm
818
819If there is an error, an error message will be shown for at least one second
820(in reverse video). {Vi: error messages may be overwritten with other
821messages before you have a chance to read them}
822
823Some commands show how many lines were affected. Above which threshold this
824happens can be controlled with the 'report' option (default 2).
825
826On the Amiga Vim will run in a CLI window. The name Vim and the full name of
827the current file name will be shown in the title bar. When the window is
828resized, Vim will automatically redraw the window. You may make the window as
829small as you like, but if it gets too small not a single line will fit in it.
830Make it at least 40 characters wide to be able to read most messages on the
831last line.
832
833On most Unix systems, resizing the window is recognized and handled correctly
834by Vim. {Vi: not ok}
835
836==============================================================================
8378. Definitions *definitions*
838
Bram Moolenaarc572da52017-08-27 16:52:01 +0200839 buffer Contains lines of text, usually read from a file.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840 screen The whole area that Vim uses to work in. This can be
841 a terminal emulator window. Also called "the Vim
842 window".
Bram Moolenaarc572da52017-08-27 16:52:01 +0200843 window A view on a buffer. There can be multiple windows for
844 one buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000845
846A screen contains one or more windows, separated by status lines and with the
847command line at the bottom.
848
849 +-------------------------------+
850screen | window 1 | window 2 |
851 | | |
852 | | |
853 |= status line =|= status line =|
854 | window 3 |
855 | |
856 | |
857 |==== status line ==============|
858 |command line |
859 +-------------------------------+
860
861The command line is also used for messages. It scrolls up the screen when
862there is not enough room in the command line.
863
864A difference is made between four types of lines:
865
866 buffer lines The lines in the buffer. This is the same as the
867 lines as they are read from/written to a file. They
868 can be thousands of characters long.
869 logical lines The buffer lines with folding applied. Buffer lines
870 in a closed fold are changed to a single logical line:
871 "+-- 99 lines folded". They can be thousands of
872 characters long.
873 window lines The lines displayed in a window: A range of logical
874 lines with wrapping, line breaks, etc. applied. They
875 can only be as long as the width of the window allows,
876 longer lines are wrapped or truncated.
877 screen lines The lines of the screen that Vim uses. Consists of
878 the window lines of all windows, with status lines
879 and the command line added. They can only be as long
880 as the width of the screen allows. When the command
881 line gets longer it wraps and lines are scrolled to
882 make room.
883
884buffer lines logical lines window lines screen lines ~
885
8861. one 1. one 1. +-- folded 1. +-- folded
8872. two 2. +-- folded 2. five 2. five
8883. three 3. five 3. six 3. six
8894. four 4. six 4. seven 4. seven
8905. five 5. seven 5. === status line ===
8916. six 6. aaa
8927. seven 7. bbb
893 8. ccc ccc c
8941. aaa 1. aaa 1. aaa 9. cc
8952. bbb 2. bbb 2. bbb 10. ddd
8963. ccc ccc ccc 3. ccc ccc ccc 3. ccc ccc c 11. ~
8974. ddd 4. ddd 4. cc 12. === status line ===
898 5. ddd 13. (command line)
899 6. ~
900
901==============================================================================
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200902 vim:tw=78:ts=8:noet:ft=help:norl: