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