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