Christian Brabandt | 9c3330d | 2024-12-17 20:24:24 +0100 | [diff] [blame] | 1 | *usr_01.txt* For Vim version 9.1. Last change: 2024 Dec 17 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | VIM USER MANUAL - by Bram Moolenaar |
| 4 | |
| 5 | About the manuals |
| 6 | |
| 7 | |
| 8 | This chapter introduces the manuals available with Vim. Read this to know the |
| 9 | conditions under which the commands are explained. |
| 10 | |
| 11 | |01.1| Two manuals |
| 12 | |01.2| Vim installed |
| 13 | |01.3| Using the Vim tutor |
| 14 | |01.4| Copyright |
| 15 | |
| 16 | Next chapter: |usr_02.txt| The first steps in Vim |
| 17 | Table of contents: |usr_toc.txt| |
| 18 | |
| 19 | ============================================================================== |
| 20 | *01.1* Two manuals |
| 21 | |
| 22 | The Vim documentation consists of two parts: |
| 23 | |
| 24 | 1. The User manual |
| 25 | Task oriented explanations, from simple to complex. Reads from start to |
| 26 | end like a book. |
| 27 | |
| 28 | 2. The Reference manual |
| 29 | Precise description of how everything in Vim works. |
| 30 | |
| 31 | The notation used in these manuals is explained here: |notation| |
| 32 | |
| 33 | |
| 34 | JUMPING AROUND |
| 35 | |
| 36 | The text contains hyperlinks between the two parts, allowing you to quickly |
| 37 | jump between the description of an editing task and a precise explanation of |
| 38 | the commands and options used for it. Use these two commands: |
| 39 | |
| 40 | Press CTRL-] to jump to a subject under the cursor. |
| 41 | Press CTRL-O to jump back (repeat to go further back). |
| 42 | |
Bram Moolenaar | 166af9b | 2010-11-16 20:34:40 +0100 | [diff] [blame] | 43 | Many links are in vertical bars, like this: |bars|. The bars themselves may |
Bram Moolenaar | 0c0734d | 2019-11-26 21:44:46 +0100 | [diff] [blame] | 44 | be hidden or invisible; see below. An option name, like 'number', a command |
Bram Moolenaar | 166af9b | 2010-11-16 20:34:40 +0100 | [diff] [blame] | 45 | in double quotes like ":write" and any other word can also be used as a link. |
| 46 | Try it out: Move the cursor to CTRL-] and press CTRL-] on it. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 47 | |
Bram Moolenaar | 0c0734d | 2019-11-26 21:44:46 +0100 | [diff] [blame] | 48 | Other subjects can be found with the ":help" command; see |help.txt|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 49 | |
Bram Moolenaar | 166af9b | 2010-11-16 20:34:40 +0100 | [diff] [blame] | 50 | The bars and stars are usually hidden with the |conceal| feature. They also |
| 51 | use |hl-Ignore|, using the same color for the text as the background. You can |
| 52 | make them visible with: > |
| 53 | :set conceallevel=0 |
| 54 | :hi link HelpBar Normal |
| 55 | :hi link HelpStar Normal |
| 56 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 57 | ============================================================================== |
| 58 | *01.2* Vim installed |
| 59 | |
| 60 | Most of the manuals assume that Vim has been properly installed. If you |
| 61 | didn't do that yet, or if Vim doesn't run properly (e.g., files can't be found |
| 62 | or in the GUI the menus do not show up) first read the chapter on |
| 63 | installation: |usr_90.txt|. |
| 64 | *not-compatible* |
| 65 | The manuals often assume you are using Vim with Vi-compatibility switched |
| 66 | off. For most commands this doesn't matter, but sometimes it is important, |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 67 | e.g., for multi-level undo. An easy way to make sure you are using a nice |
| 68 | setup is to copy the example vimrc file. By doing this inside Vim you don't |
| 69 | have to check out where it is located. How to do this depends on the system |
| 70 | you are using: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 71 | |
| 72 | Unix: > |
| 73 | :!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc |
Bram Moolenaar | 6f345a1 | 2019-12-17 21:27:18 +0100 | [diff] [blame] | 74 | MS-Windows: > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 75 | :!copy $VIMRUNTIME/vimrc_example.vim $VIM/_vimrc |
| 76 | Amiga: > |
| 77 | :!copy $VIMRUNTIME/vimrc_example.vim $VIM/.vimrc |
| 78 | |
| 79 | If the file already exists you probably want to keep it. |
| 80 | |
| 81 | If you start Vim now, the 'compatible' option should be off. You can check it |
| 82 | with this command: > |
| 83 | |
| 84 | :set compatible? |
| 85 | |
| 86 | If it responds with "nocompatible" you are doing well. If the response is |
| 87 | "compatible" you are in trouble. You will have to find out why the option is |
| 88 | still set. Perhaps the file you wrote above is not found. Use this command |
| 89 | to find out: > |
| 90 | |
| 91 | :scriptnames |
| 92 | |
| 93 | If your file is not in the list, check its location and name. If it is in the |
| 94 | list, there must be some other place where the 'compatible' option is switched |
| 95 | back on. |
| 96 | |
| 97 | For more info see |vimrc| and |compatible-default|. |
| 98 | |
| 99 | Note: |
| 100 | This manual is about using Vim in the normal way. There is an |
| 101 | alternative called "evim" (easy Vim). This is still Vim, but used in |
| 102 | a way that resembles a click-and-type editor like Notepad. It always |
| 103 | stays in Insert mode, thus it feels very different. It is not |
Bram Moolenaar | 0c0734d | 2019-11-26 21:44:46 +0100 | [diff] [blame] | 104 | explained in the user manual, since it should be mostly |
| 105 | self-explanatory. See |evim-keys| for details. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 106 | |
| 107 | ============================================================================== |
| 108 | *01.3* Using the Vim tutor *tutor* *vimtutor* |
| 109 | |
Yegappan Lakshmanan | a54816b | 2024-11-03 10:49:23 +0100 | [diff] [blame] | 110 | For the interactive tutor, see |vim-tutor-mode| |
| 111 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 112 | Instead of reading the text (boring!) you can use the vimtutor to learn your |
Christian Brabandt | 3f7d584 | 2024-12-16 20:11:04 +0100 | [diff] [blame] | 113 | first Vim commands. This is a 30-minute tutorial provided in 2 chapters, that |
| 114 | teaches the most basic Vim functionality hands-on. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 115 | |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 116 | On Unix, if Vim has been properly installed, you can start it from the shell: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 117 | > |
| 118 | vimtutor |
| 119 | |
Christian Brabandt | 9c3330d | 2024-12-17 20:24:24 +0100 | [diff] [blame] | 120 | On MS-Windows you can find it in the "Program/Vim 9.1" menu. Or execute |
| 121 | vimtutor.bat from the installation directory (You can use `:echo $VIMRUNTIME` |
| 122 | from within Vim to find this directory). |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 123 | |
Paul Desmond Parker | 17c71da | 2024-11-03 20:47:53 +0100 | [diff] [blame] | 124 | This will make a copy of chapter 1 tutor file, so that you can edit it without |
| 125 | the risk of damaging the original. To continue with chapter 2, you can use |
| 126 | the following command: > |
| 127 | vimtutor -c 2 |
| 128 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | There are a few translated versions of the tutor. To find out if yours is |
| 130 | available, use the two-letter language code. For French: > |
| 131 | |
| 132 | vimtutor fr |
| 133 | |
Bram Moolenaar | c1a11ed | 2008-06-24 22:09:24 +0000 | [diff] [blame] | 134 | On Unix, if you prefer using the GUI version of Vim, use "gvimtutor" or |
| 135 | "vimtutor -g" instead of "vimtutor". |
| 136 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 137 | For OpenVMS, if Vim has been properly installed, you can start vimtutor from a |
| 138 | VMS prompt with: > |
| 139 | |
| 140 | @VIM:vimtutor |
| 141 | |
| 142 | Optionally add the two-letter language code as above. |
| 143 | |
| 144 | |
| 145 | On other systems, you have to do a little work: |
| 146 | |
| 147 | 1. Copy the tutor file. You can do this with Vim (it knows where to find it): |
| 148 | > |
RestorerZ | 6fa304f | 2024-12-02 20:19:52 +0100 | [diff] [blame] | 149 | vim --clean -c 'e $VIMRUNTIME/tutor/tutor1' -c 'w! TUTORCOPY' -c 'q' |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 150 | < |
| 151 | This will write the file "TUTORCOPY" in the current directory. To use a |
| 152 | translated version of the tutor, append the two-letter language code to the |
| 153 | filename. For French: |
| 154 | > |
RestorerZ | 6fa304f | 2024-12-02 20:19:52 +0100 | [diff] [blame] | 155 | vim --clean -c 'e $VIMRUNTIME/tutor/tutor1.fr' -c 'w! TUTORCOPY' -c 'q' |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 156 | < |
| 157 | 2. Edit the copied file with Vim: |
| 158 | > |
Bram Moolenaar | c4da113 | 2017-07-15 19:39:43 +0200 | [diff] [blame] | 159 | vim --clean TUTORCOPY |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 160 | < |
Bram Moolenaar | c4da113 | 2017-07-15 19:39:43 +0200 | [diff] [blame] | 161 | The --clean argument makes sure Vim is started with nice defaults. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 162 | |
| 163 | 3. Delete the copied file when you are finished with it: |
| 164 | > |
| 165 | del TUTORCOPY |
| 166 | < |
| 167 | ============================================================================== |
| 168 | *01.4* Copyright *manual-copyright* |
| 169 | |
Bram Moolenaar | b7398fe | 2023-05-14 18:50:25 +0100 | [diff] [blame] | 170 | The Vim user manual and reference manual are Copyright (c) 1988 by Bram |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 171 | Moolenaar. This material may be distributed only subject to the terms and |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 172 | conditions set forth in the Open Publication License, v1.0 or later. The |
| 173 | latest version is presently available at: |
Christian Brabandt | 1c5728e | 2024-05-11 11:12:40 +0200 | [diff] [blame] | 174 | https://opencontent.org/openpub/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 175 | |
| 176 | People who contribute to the manuals must agree with the above copyright |
| 177 | notice. |
| 178 | *frombook* |
| 179 | Parts of the user manual come from the book "Vi IMproved - Vim" by Steve |
| 180 | Oualline (published by New Riders Publishing, ISBN: 0735710015). The Open |
| 181 | Publication License applies to this book. Only selected parts are included |
| 182 | and these have been modified (e.g., by removing the pictures, updating the |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 183 | text for Vim 6.0 and later, fixing mistakes). The omission of the |frombook| |
| 184 | tag does not mean that the text does not come from the book. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 185 | |
| 186 | Many thanks to Steve Oualline and New Riders for creating this book and |
| 187 | publishing it under the OPL! It has been a great help while writing the user |
| 188 | manual. Not only by providing literal text, but also by setting the tone and |
| 189 | style. |
| 190 | |
| 191 | If you make money through selling the manuals, you are strongly encouraged to |
| 192 | donate part of the profit to help AIDS victims in Uganda. See |iccf|. |
| 193 | |
| 194 | ============================================================================== |
| 195 | |
| 196 | Next chapter: |usr_02.txt| The first steps in Vim |
| 197 | |
Bram Moolenaar | d473c8c | 2018-08-11 18:00:22 +0200 | [diff] [blame] | 198 | Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: |