annotate runtime/doc/usr_02.txt @ 1118:2b8ff9e3c520

updated for version 7.1a
author vimboss
date Sat, 05 May 2007 17:10:09 +0000
parents 4bac29d27e2f
children e63691e7c504
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
874
4bac29d27e2f updated for version 7.0
vimboss
parents: 856
diff changeset
1 *usr_02.txt* For Vim version 7.0. Last change: 2006 Apr 24
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 VIM USER MANUAL - by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 The first steps in Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 This chapter provides just enough information to edit a file with Vim. Not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 well or fast, but you can edit. Take some time to practice with these
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 commands, they form the base for what follows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |02.1| Running Vim for the First Time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |02.2| Inserting text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |02.3| Moving around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |02.4| Deleting characters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |02.5| Undo and Redo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 |02.6| Other editing commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 |02.7| Getting out
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 |02.8| Finding help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 Next chapter: |usr_03.txt| Moving around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 Previous chapter: |usr_01.txt| About the manuals
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 *02.1* Running Vim for the First Time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 To start Vim, enter this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 gvim file.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 In UNIX you can type this at any command prompt. If you are running Microsoft
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 Windows, open an MS-DOS prompt window and enter the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 In either case, Vim starts editing a file called file.txt. Because this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 is a new file, you get a blank window. This is what your screen will look
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 like:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 |# |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 |"file.txt" [New file] |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 ('#" is the cursor position.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 The tilde (~) lines indicate lines not in the file. In other words, when Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 runs out of file to display, it displays tilde lines. At the bottom of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 screen, a message line indicates the file is named file.txt and shows that you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 are creating a new file. The message information is temporary and other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 information overwrites it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 THE VIM COMMAND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 The gvim command causes the editor to create a new window for editing. If you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 vim file.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 the editing occurs inside your command window. In other words, if you are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 running inside an xterm, the editor uses your xterm window. If you are using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 an MS-DOS command prompt window under Microsoft Windows, the editing occurs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 inside this window. The text in the window will look the same for both
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 versions, but with gvim you have extra features, like a menu bar. More about
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 that later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 *02.2* Inserting text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 The Vim editor is a modal editor. That means that the editor behaves
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 differently, depending on which mode you are in. The two basic modes are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 called Normal mode and Insert mode. In Normal mode the characters you type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 are commands. In Insert mode the characters are inserted as text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 Since you have just started Vim it will be in Normal mode. To start Insert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 mode you type the "i" command (i for Insert). Then you can enter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 the text. It will be inserted into the file. Do not worry if you make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 mistakes; you can correct them later. To enter the following programmer's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 limerick, this is what you type: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 iA very intelligent turtle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 Found programming UNIX a hurdle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 After typing "turtle" you press the <Enter> key to start a new line. Finally
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 you press the <Esc> key to stop Insert mode and go back to Normal mode. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 now have two lines of text in your Vim window:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 |A very intelligent turtle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 |Found programming UNIX a hurdle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 WHAT IS THE MODE?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 To be able to see what mode you are in, type this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 :set showmode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 You will notice that when typing the colon Vim moves the cursor to the last
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 line of the window. That's where you type colon commands (commands that start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 with a colon). Finish this command by pressing the <Enter> key (all commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 that start with a colon are finished this way).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 Now, if you type the "i" command Vim will display --INSERT-- at the bottom
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 of the window. This indicates you are in Insert mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 |A very intelligent turtle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 |Found programming UNIX a hurdle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 |-- INSERT -- |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 If you press <Esc> to go back to Normal mode the last line will be made blank.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 GETTING OUT OF TROUBLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 One of the problems for Vim novices is mode confusion, which is caused by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 forgetting which mode you are in or by accidentally typing a command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 switches modes. To get back to Normal mode, no matter what mode you are in,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 press the <Esc> key. Sometimes you have to press it twice. If Vim beeps back
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 at you, you already are in Normal mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 *02.3* Moving around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 After you return to Normal mode, you can move around by using these keys:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 h left *hjkl*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 j down
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 k up
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 l right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 At first, it may appear that these commands were chosen at random. After all,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 who ever heard of using l for right? But actually, there is a very good
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 reason for these choices: Moving the cursor is the most common thing you do in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 an editor, and these keys are on the home row of your right hand. In other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 words, these commands are placed where you can type them the fastest
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 (especially when you type with ten fingers).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 You can also move the cursor by using the arrow keys. If you do,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 however, you greatly slow down your editing because to press the arrow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 keys, you must move your hand from the text keys to the arrow keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 Considering that you might be doing it hundreds of times an hour, this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 can take a significant amount of time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 Also, there are keyboards which do not have arrow keys, or which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 locate them in unusual places; therefore, knowing the use of the hjkl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 keys helps in those situations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 One way to remember these commands is that h is on the left, l is on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 right and j points down. In a picture: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 h l
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 j
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 The best way to learn these commands is by using them. Use the "i" command to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 insert some more lines of text. Then use the hjkl keys to move around and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 insert a word somewhere. Don't forget to press <Esc> to go back to Normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 mode. The |vimtutor| is also a nice way to learn by doing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 For Japanese users, Hiroshi Iwatani suggested using this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 Komsomolsk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 ^
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 Huan Ho <--- ---> Los Angeles
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 (Yellow river) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 v
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 Java (the island, not the programming language)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 *02.4* Deleting characters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 To delete a character, move the cursor over it and type "x". (This is a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 throwback to the old days of the typewriter, when you deleted things by typing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 xxxx over them.) Move the cursor to the beginning of the first line, for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 example, and type xxxxxxx (seven x's) to delete "A very ". The result should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 look like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 |intelligent turtle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 |Found programming UNIX a hurdle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 Now you can insert new text, for example by typing: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 iA young <Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 This begins an insert (the i), inserts the words "A young", and then exits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 insert mode (the final <Esc>). The result:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 |A young intelligent turtle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 |Found programming UNIX a hurdle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 DELETING A LINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 To delete a whole line use the "dd" command. The following line will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 then move up to fill the gap:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 |Found programming UNIX a hurdle |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 +---------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 DELETING A LINE BREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 In Vim you can join two lines together, which means that the line break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 between them is deleted. The "J" command does this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 Take these two lines:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 A young intelligent ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 Move the cursor to the first line and press "J":
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 A young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 *02.5* Undo and Redo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 Suppose you delete too much. Well, you can type it in again, but an easier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 way exists. The "u" command undoes the last edit. Take a look at this in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 action: After using "dd" to delete the first line, "u" brings it back.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 Another one: Move the cursor to the A in the first line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 A young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 Now type xxxxxxx to delete "A young". The result is as follows:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 Type "u" to undo the last delete. That delete removed the g, so the undo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 restores the character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 g intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 The next u command restores the next-to-last character deleted:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 ng intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 The next u command gives you the u, and so on:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 ung intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 oung intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 A young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 If you type "u" twice, and the result is that you get the same text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 back, you have Vim configured to work Vi compatible. Look here to fix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 this: |not-compatible|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 This text assumes you work "The Vim Way". You might prefer to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 the good old Vi way, but you will have to watch out for small
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 differences in the text then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 REDO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 If you undo too many times, you can press CTRL-R (redo) to reverse the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 preceding command. In other words, it undoes the undo. To see this in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 action, press CTRL-R twice. The character A and the space after it disappear:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 young intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 There's a special version of the undo command, the "U" (undo line) command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 The undo line command undoes all the changes made on the last line that was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 edited. Typing this command twice cancels the preceding "U".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 A very intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 xxxx Delete very
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 A intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 xxxxxx Delete turtle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 A intelligent ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 Restore line with "U"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 A very intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 Undo "U" with "u"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 A intelligent ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 The "U" command is a change by itself, which the "u" command undoes and CTRL-R
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 redoes. This might be a bit confusing. Don't worry, with "u" and CTRL-R you
799
6beb2c667935 updated for version 7.0b
vimboss
parents: 236
diff changeset
305 can go to any of the situations you had. More about that in section ||.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 *02.6* Other editing commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 Vim has a large number of commands to change the text. See |Q_in| and below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 Here are a few often used ones.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 APPENDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 The "i" command inserts a character before the character under the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 That works fine; but what happens if you want to add stuff to the end of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 line? For that you need to insert text after the cursor. This is done with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 the "a" (append) command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 For example, to change the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 and that's not saying much for the turtle. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 and that's not saying much for the turtle!!! ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 move the cursor over to the dot at the end of the line. Then type "x" to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 delete the period. The cursor is now positioned at the end of the line on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 e in turtle. Now type >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 a!!!<Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 to append three exclamation points after the e in turtle:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 and that's not saying much for the turtle!!! ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 OPENING UP A NEW LINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 The "o" command creates a new, empty line below the cursor and puts Vim in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 Insert mode. Then you can type the text for the new line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 Suppose the cursor is somewhere in the first of these two lines:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 A very intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 Found programming UNIX a hurdle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 If you now use the "o" command and type new text: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 oThat liked using Vim<Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 The result is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 A very intelligent turtle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 That liked using Vim ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 Found programming UNIX a hurdle ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 The "O" command (uppercase) opens a line above the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 USING A COUNT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 Suppose you want to move up nine lines. You can type "kkkkkkkkk" or you can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 enter the command "9k". In fact, you can precede many commands with a number.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 Earlier in this chapter, for instance, you added three exclamation points to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 the end of a line by typing "a!!!<Esc>". Another way to do this is to use the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 command "3a!<Esc>". The count of 3 tells the command that follows to triple
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 its effect. Similarly, to delete three characters, use the command "3x". The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 count always comes before the command it applies to.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 *02.7* Getting out
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 To exit, use the "ZZ" command. This command writes the file and exits.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 Unlike many other editors, Vim does not automatically make a backup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 file. If you type "ZZ", your changes are committed and there's no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 turning back. You can configure the Vim editor to produce backup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 files, see |07.4|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 DISCARDING CHANGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 Sometimes you will make a sequence of changes and suddenly realize you were
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 better off before you started. Not to worry; Vim has a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 quit-and-throw-things-away command. It is: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 :q!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 Don't forget to press <Enter> to finish the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 For those of you interested in the details, the three parts of this command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 are the colon (:), which enters Command-line mode; the q command, which tells
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 the editor to quit; and the override command modifier (!).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 The override command modifier is needed because Vim is reluctant to throw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 away changes. If you were to just type ":q", Vim would display an error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 message and refuse to exit:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 E37: No write since last change (use ! to override) ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 By specifying the override, you are in effect telling Vim, "I know that what
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 I'm doing looks stupid, but I'm a big boy and really want to do this."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 If you want to continue editing with Vim: The ":e!" command reloads the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 original version of the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 *02.8* Finding help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 Everything you always wanted to know can be found in the Vim help files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 Don't be afraid to ask!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 To get generic help use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 :help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 You could also use the first function key <F1>. If your keyboard has a <Help>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 key it might work as well.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 If you don't supply a subject, ":help" displays the general help window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 The creators of Vim did something very clever (or very lazy) with the help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 system: They made the help window a normal editing window. You can use all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 the normal Vim commands to move through the help information. Therefore h, j,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 k, and l move left, down, up and right.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 To get out of the help window, use the same command you use to get out of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 the editor: "ZZ". This will only close the help window, not exit Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 As you read the help text, you will notice some text enclosed in vertical bars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 (for example, |help|). This indicates a hyperlink. If you position the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 cursor anywhere between the bars and press CTRL-] (jump to tag), the help
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 7
diff changeset
428 system takes you to the indicated subject. (For reasons not discussed here,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 the Vim terminology for a hyperlink is tag. So CTRL-] jumps to the location
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 of the tag given by the word under the cursor.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 After a few jumps, you might want to go back. CTRL-T (pop tag) takes you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 back to the preceding position. CTRL-O (jump to older position) also works
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 nicely here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 At the top of the help screen, there is the notation *help.txt*. This name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 between "*" characters is used by the help system to define a tag (hyperlink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 destination).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 See |29.1| for details about using tags.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 To get help on a given subject, use the following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 :help {subject}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 To get help on the "x" command, for example, enter the following: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 :help x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 To find out how to delete text, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 :help deleting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 To get a complete index of all Vim commands, use the following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 :help index
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 When you need to get help for a control character command (for example,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 CTRL-A), you need to spell it with the prefix "CTRL-". >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 :help CTRL-A
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 The Vim editor has many different modes. By default, the help system displays
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 the normal-mode commands. For example, the following command displays help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 for the normal-mode CTRL-H command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 :help CTRL-H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 To identify other modes, use a mode prefix. If you want the help for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 insert-mode version of a command, use "i_". For CTRL-H this gives you the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 :help i_CTRL-H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 When you start the Vim editor, you can use several command-line arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 These all begin with a dash (-). To find what the -t argument does, for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 example, use the command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 :help -t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 The Vim editor has a number of options that enable you to configure and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 customize the editor. If you want help for an option, you need to enclose it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 in single quotation marks. To find out what the 'number' option does, for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 example, use the following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 :help 'number'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 The table with all mode prefixes can be found here: |help-context|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 7
diff changeset
487 Special keys are enclosed in angle brackets. To find help on the up-arrow key
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 in Insert mode, for instance, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 :help i_<Up>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 If you see an error message that you don't understand, for example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 E37: No write since last change (use ! to override) ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 You can use the error ID at the start to find help about it: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 :help E37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 Next chapter: |usr_03.txt| Moving around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: