annotate runtime/doc/usr_20.txt @ 3210:767bb493e7d3 v7.3.375

updated for version 7.3.375 Problem: Duplicate return statement. Solution: Remove the superfluous one. (Dominique Pelle)
author Bram Moolenaar <bram@vim.org>
date Wed, 14 Dec 2011 15:07:29 +0100
parents 073ff46fe397
children 6ec6b7ff2d43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2572
ee53a39d5896 Last changes for the 7.3 release!
Bram Moolenaar <bram@vim.org>
parents: 2561
diff changeset
1 *usr_20.txt* For Vim version 7.3. 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 Typing command-line commands quickly
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 Vim has a few generic features that makes it easier to enter commands. Colon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 commands can be abbreviated, edited and repeated. Completion is available for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 nearly everything.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |20.1| Command line editing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |20.2| Command line abbreviations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |20.3| Command line completion
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |20.4| Command line history
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |20.5| Command line window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 Next chapter: |usr_21.txt| Go away and come back
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Previous chapter: |usr_12.txt| Clever tricks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 *20.1* Command line editing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 When you use a colon (:) command or search for a string with / or ?, Vim puts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 the cursor on the bottom of the screen. There you type the command or search
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 pattern. This is called the Command line. Also when it's used for entering a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 search command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 The most obvious way to edit the command you type is by pressing the <BS> key.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 This erases the character before the cursor. To erase another character,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 typed earlier, first move the cursor with the cursor keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 For example, you have typed this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 :s/col/pig/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 Before you hit <Enter>, you notice that "col" should be "cow". To correct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 this, you type <Left> five times. The cursor is now just after "col". Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 <BS> and "w" to correct: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 :s/cow/pig/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 Now you can press <Enter> directly. You don't have to move the cursor to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 end of the line before executing the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 The most often used keys to move around in the command line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 <Left> one character left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 <Right> one character right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 <S-Left> or <C-Left> one word left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 <S-Right> or <C-Right> one word right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 CTRL-B or <Home> to begin of command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 CTRL-E or <End> to end of command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 <S-Left> (cursor left key with Shift key pressed) and <C-Left> (cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 left key with Control pressed) will not work on all keyboards. Same
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 for the other Shift and Control combinations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 You can also use the mouse to move the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 DELETING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 As mentioned, <BS> deletes the character before the cursor. To delete a whole
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 word use CTRL-W.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 /the fine pig ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 CTRL-W
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 /the fine ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 CTRL-U removes all text, thus allows you to start all over again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 OVERSTRIKE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 The <Insert> key toggles between inserting characters and replacing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 existing ones. Start with this text:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 /the fine pig ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 Move the cursor to the start of "fine" with <S-Left> twice (or <Left> eight
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 times, if <S-Left> doesn't work). Now press <Insert> to switch to overstrike
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 and type "great":
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 /the greatpig ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 Oops, we lost the space. Now, don't use <BS>, because it would delete the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 "t" (this is different from Replace mode). Instead, press <Insert> to switch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 from overstrike to inserting, and type the space:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 /the great pig ~
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 CANCELLING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 You thought of executing a : or / command, but changed your mind. To get rid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 of what you already typed, without executing it, press CTRL-C or <Esc>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 <Esc> is the universal "get out" key. Unfortunately, in the good old
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 Vi pressing <Esc> in a command line executed the command! Since that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 might be considered to be a bug, Vim uses <Esc> to cancel the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 But with the 'cpoptions' option it can be made Vi compatible. And
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 when using a mapping (which might be written for Vi) <Esc> also works
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 Vi compatible. Therefore, using CTRL-C is a method that always works.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 If you are at the start of the command line, pressing <BS> will cancel the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 command. It's like deleting the ":" or "/" that the line starts with.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 *20.2* Command line abbreviations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 Some of the ":" commands are really long. We already mentioned that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 ":substitute" can be abbreviated to ":s". This is a generic mechanism, all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 ":" commands can be abbreviated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 How short can a command get? There are 26 letters, and many more commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 For example, ":set" also starts with ":s", but ":s" doesn't start a ":set"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 command. Instead ":set" can be abbreviated to ":se".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 When the shorter form of a command could be used for two commands, it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 stands for only one of them. There is no logic behind which one, you have to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 learn them. In the help files the shortest form that works is mentioned. For
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 :s[ubstitute]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 This means that the shortest form of ":substitute" is ":s". The following
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 characters are optional. Thus ":su" and ":sub" also work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 In the user manual we will either use the full name of command, or a short
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 version that is still readable. For example, ":function" can be abbreviated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 to ":fu". But since most people don't understand what that stands for, we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 will use ":fun". (Vim doesn't have a ":funny" command, otherwise ":fun" would
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 be confusing too.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 It is recommended that in Vim scripts you write the full command name. That
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 makes it easier to read back when you make later changes. Except for some
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 often used commands like ":w" (":write") and ":r" (":read").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 A particularly confusing one is ":end", which could stand for ":endif",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 ":endwhile" or ":endfunction". Therefore, always use the full name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 SHORT OPTION NAMES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 In the user manual the long version of the option names is used. Many options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 also have a short name. Unlike ":" commands, there is only one short name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 that works. For example, the short name of 'autoindent' is 'ai'. Thus these
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 two commands do the same thing: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 :set autoindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 :set ai
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 You can find the full list of long and short names here: |option-list|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 *20.3* Command line completion
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 This is one of those Vim features that, by itself, is a reason to switch from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 Vi to Vim. Once you have used this, you can't do without.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 Suppose you have a directory that contains these files:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 info.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 intro.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 bodyofthepaper.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 To edit the last one, you use the command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 :edit bodyofthepaper.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 It's easy to type this wrong. A much quicker way is: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 :edit b<Tab>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 Which will result in the same command. What happened? The <Tab> key does
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 completion of the word before the cursor. In this case "b". Vim looks in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 directory and finds only one file that starts with a "b". That must be the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 one you are looking for, thus Vim completes the file name for you.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 Now type: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 :edit i<Tab>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 Vim will beep, and give you: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 :edit info.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 The beep means that Vim has found more than one match. It then uses the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 match it found (alphabetically). If you press <Tab> again, you get: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 :edit intro.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 Thus, if the first <Tab> doesn't give you the file you were looking for, press
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 it again. If there are more matches, you will see them all, one at a time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 If you press <Tab> on the last matching entry, you will go back to what you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 first typed: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 :edit i
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 Then it starts all over again. Thus Vim cycles through the list of matches.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 Use CTRL-P to go through the list in the other direction:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 <------------------- <Tab> -------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 <Tab> --> <Tab> -->
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 :edit i :edit info.txt :edit intro.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 <-- CTRL-P <-- CTRL-P
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 +---------------------- CTRL-P ------------------------>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 CONTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 When you type ":set i" instead of ":edit i" and press <Tab> you get: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 :set icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 Hey, why didn't you get ":set info.txt"? That's because Vim has context
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 sensitive completion. The kind of words Vim will look for depends on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 command before it. Vim knows that you cannot use a file name just after a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 ":set" command, but you can use an option name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 Again, if you repeat typing the <Tab>, Vim will cycle through all matches.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 There are quite a few, it's better to type more characters first: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 :set isk<Tab>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 Gives: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 :set iskeyword
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 Now type "=" and press <Tab>: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 :set iskeyword=@,48-57,_,192-255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 What happens here is that Vim inserts the old value of the option. Now you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 can edit it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 What is completed with <Tab> is what Vim expects in that place. Just try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 it out to see how it works. In some situations you will not get what you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 want. That's either because Vim doesn't know what you want, or because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 completion was not implemented for that situation. In that case you will get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 a <Tab> inserted (displayed as ^I).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 LIST MATCHES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 When there are many matches, you would like to see an overview. Do this by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 pressing CTRL-D. For example, pressing CTRL-D after: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 :set is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 results in: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 :set is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 incsearch isfname isident iskeyword isprint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 :set is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 Vim lists the matches and then comes back with the text you typed. You can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 now check the list for the item you wanted. If it isn't there, you can use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 <BS> to correct the word. If there are many matches, type a few more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 characters before pressing <Tab> to complete the rest.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 If you have watched carefully, you will have noticed that "incsearch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 doesn't start with "is". In this case "is" stands for the short name of
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
266 "incsearch". (Many options have a short and a long name.) Vim is clever
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 enough to know that you might have wanted to expand the short name of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 option into the long name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 THERE IS MORE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 The CTRL-L command completes the word to the longest unambiguous string. If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 you type ":edit i" and there are files "info.txt" and "info_backup.txt" you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 will get ":edit info".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 The 'wildmode' option can be used to change the way completion works.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 The 'wildmenu' option can be used to get a menu-like list of matches.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 Use the 'suffixes' option to specify files that are less important and appear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 at the end of the list of files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 The 'wildignore' option specifies files that are not listed at all.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 More about all of this here: |cmdline-completion|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 *20.4* Command line history
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 In chapter 3 we briefly mentioned the history. The basics are that you can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 use the <Up> key to recall an older command line. <Down> then takes you back
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 to newer commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 There are actually four histories. The ones we will mention here are for ":"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 commands and for "/" and "?" search commands. The "/" and "?" commands share
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 the same history, because they are both search commands. The two other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 histories are for expressions and input lines for the input() function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 |cmdline-history|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 Suppose you have done a ":set" command, typed ten more colon commands and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 want to repeat that ":set" command again. You could press ":" and then ten
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 times <Up>. There is a quicker way: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 :se<Up>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 Vim will now go back to the previous command that started with "se". You have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 a good chance that this is the ":set" command you were looking for. At least
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 you should not have to press <Up> very often (unless ":set" commands is all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 you have done).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 The <Up> key will use the text typed so far and compare it with the lines in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 the history. Only matching lines will be used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 If you do not find the line you were looking for, use <Down> to go back to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 what you typed and correct that. Or use CTRL-U to start all over again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 To see all the lines in the history: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 :history
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 That's the history of ":" commands. The search history is displayed with this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 :history /
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 CTRL-P will work like <Up>, except that it doesn't matter what you already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 typed. Similarly for CTRL-N and <Down>. CTRL-P stands for previous, CTRL-N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 for next.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 *20.5* Command line window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 Typing the text in the command line works different from typing text in Insert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 mode. It doesn't allow many commands to change the text. For most commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 that's OK, but sometimes you have to type a complicated command. That's where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 the command line window is useful.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 Open the command line window with this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 q:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 Vim now opens a (small) window at the bottom. It contains the command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 history, and an empty line at the end:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 +-------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 |other window |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 |file.txt=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 |:e c |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 |:e config.h.in |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 |:set path=.,/usr/include,, |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 |:set iskeyword=@,48-57,_,192-255 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 |:set is |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 |:q |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 |: |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 |command-line=========================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 +-------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 You are now in Normal mode. You can use the "hjkl" keys to move around. For
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 example, move up with "5k" to the ":e config.h.in" line. Type "$h" to go to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 the "i" of "in" and type "cwout". Now you have changed the line to:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 :e config.h.out ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 Now press <Enter> and this command will be executed. The command line window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 will close.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 The <Enter> command will execute the line under the cursor. It doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 matter whether Vim is in Insert mode or in Normal mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 Changes in the command line window are lost. They do not result in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 history to be changed. Except that the command you execute will be added to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 the end of the history, like with all executed commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 The command line window is very useful when you want to have overview of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 history, lookup a similar command, change it a bit and execute it. A search
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 command can be used to find something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 In the previous example the "?config" search command could have been used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 to find the previous command that contains "config". It's a bit strange,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 because you are using a command line to search in the command line window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 While typing that search command you can't open another command line window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 there can be only one.
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 Next chapter: |usr_21.txt| Go away and come back
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: