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