intro.txt 38 KB

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