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