9
|
1 *insert.txt* For Vim version 7.0aa. Last change: 2004 Jun 16
|
7
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Bram Moolenaar
|
|
5
|
|
6
|
|
7 *Insert* *Insert-mode*
|
|
8 Inserting and replacing text *mode-ins-repl*
|
|
9
|
|
10 Most of this file is about Insert and Replace mode. At the end are a few
|
|
11 commands for inserting text in other ways.
|
|
12
|
|
13 An overview of the most often used commands can be found in chapter 24 of the
|
|
14 user manual |usr_24.txt|.
|
|
15
|
|
16 1. Special keys |ins-special-keys|
|
|
17 2. Special special keys |ins-special-special|
|
|
18 3. 'textwidth' and 'wrapmargin' options |ins-textwidth|
|
|
19 4. 'expandtab', 'smarttab' and 'softtabstop' options |ins-expandtab|
|
|
20 5. Replace mode |Replace-mode|
|
|
21 6. Virtual Replace mode |Virtual-Replace-mode|
|
|
22 7. Insert mode completion |ins-completion|
|
|
23 8. Insert mode commands |inserting|
|
|
24 9. Ex insert commands |inserting-ex|
|
|
25 10. Inserting a file |inserting-file|
|
|
26
|
|
27 Also see 'virtualedit', for moving the cursor to positions where there is no
|
|
28 character. Useful for editing a table.
|
|
29
|
|
30 ==============================================================================
|
|
31 1. Special keys *ins-special-keys*
|
|
32
|
|
33 In Insert and Replace mode, the following characters have a special meaning;
|
|
34 other characters are inserted directly. To insert one of these special
|
|
35 characters into the buffer, precede it with CTRL-V. To insert a <Nul>
|
|
36 character use "CTRL-V CTRL-@" or "CTRL-V 000". On some systems, you have to
|
|
37 use "CTRL-V 003" to insert a CTRL-C. Note: When CTRL-V is mapped you can
|
|
38 often use CTRL-Q instead |i_CTRL-Q|.
|
|
39
|
|
40 If you are working in a special language mode when inserting text, see the
|
|
41 'langmap' option, |'langmap'|, on how to avoid switching this mode on and off
|
|
42 all the time.
|
|
43
|
|
44 If you have 'insertmode' set, <Esc> and a few other keys get another meaning.
|
|
45 See |'insertmode'|.
|
|
46
|
|
47 char action ~
|
|
48 -----------------------------------------------------------------------
|
|
49 *i_CTRL-[* *i_<Esc>*
|
|
50 <Esc> or CTRL-[ End insert or Replace mode, go back to Normal mode. Finish
|
|
51 abbreviation.
|
|
52 Note: If your <Esc> key is hard to hit on your keyboard, train
|
|
53 yourself to use CTRL-[.
|
|
54 *i_CTRL-C*
|
|
55 CTRL-C Quit insert mode, go back to Normal mode. Do not check for
|
|
56 abbreviations.
|
|
57
|
|
58 *i_CTRL-@*
|
|
59 CTRL-@ Insert previously inserted text and stop insert. {Vi: only
|
|
60 when typed as first char, only up to 128 chars}
|
|
61 *i_CTRL-A*
|
|
62 CTRL-A Insert previously inserted text. {not in Vi}
|
|
63
|
|
64 *i_CTRL-H* *i_<BS>* *i_BS*
|
|
65 <BS> or CTRL-H Delete the character before the cursor (see |i_backspacing|
|
|
66 about joining lines).
|
|
67 See |:fixdel| if your <BS> key does not do what you want.
|
|
68 {Vi: does not delete autoindents}
|
|
69 *i_<Del>* *i_DEL*
|
|
70 <Del> Delete the character under the cursor. If the cursor is at
|
|
71 the end of the line, and the 'backspace' option includes
|
|
72 "eol", delete the <EOL>; the next line is appended after the
|
|
73 current one.
|
|
74 See |:fixdel| if your <Del> key does not do what you want.
|
|
75 {not in Vi}
|
|
76 *i_CTRL-W*
|
|
77 CTRL-W Delete the word before the cursor (see |i_backspacing| about
|
|
78 joining lines). See the section "word motions",
|
|
79 |word-motions|, for the definition of a word.
|
|
80 *i_CTRL-U*
|
|
81 CTRL-U Delete all entered characters in the current line (see
|
|
82 |i_backspacing| about joining lines).
|
|
83
|
|
84 *i_CTRL-I* *i_<Tab>* *i_Tab*
|
|
85 <Tab> or CTRL-I Insert a tab. If the 'expandtab' option is on, the
|
|
86 equivalent number of spaces is inserted (use CTRL-V <Tab> to
|
|
87 avoid the expansion; use CTRL-Q <Tab> if CTRL-V is mapped
|
|
88 |i_CTRL-Q|). See also the 'smarttab' option and
|
|
89 |ins-expandtab|.
|
|
90 *i_CTRL-J* *i_<NL>*
|
|
91 <NL> or CTRL-J Begin new line.
|
|
92 *i_CTRL-M* *i_<CR>*
|
|
93 <CR> or CTRL-M Begin new line.
|
|
94 *i_CTRL-K*
|
|
95 CTRL-K {char1} [char2]
|
|
96 Enter digraph (see |digraphs|). When {char1} is a special
|
|
97 key, the code for that key is inserted in <> form. For
|
|
98 example, the string "<S-Space>" can be entered by typing
|
|
99 <C-K><S-Space> (two keys). Neither char is considered for
|
|
100 mapping. {not in Vi}
|
|
101
|
|
102 CTRL-N Find next keyword (see |i_CTRL-N|). {not in Vi}
|
|
103 CTRL-P Find previous keyword (see |i_CTRL-P|). {not in Vi}
|
|
104
|
|
105 CTRL-R {0-9a-z"%#*+:.-=} *i_CTRL-R*
|
|
106 Insert the contents of a register. Between typing CTRL-R and
|
|
107 the second character, '"' will be displayed to indicate that
|
|
108 you are expected to enter the name of a register.
|
|
109 The text is inserted as if you typed it, but mappings and
|
|
110 abbreviations are not used. If you have options like
|
|
111 'textwidth', 'formatoptions', or 'autoindent' set, this will
|
|
112 influence what will be inserted. This is different from what
|
|
113 happens with the "p" command and pasting with the mouse.
|
|
114 Special registers:
|
|
115 '"' the unnamed register, containing the text of
|
|
116 the last delete or yank
|
|
117 '%' the current file name
|
|
118 '#' the alternate file name
|
|
119 '*' the clipboard contents (X11: primary selection)
|
|
120 '+' the clipboard contents
|
|
121 '/' the last search pattern
|
|
122 ':' the last command-line
|
|
123 '.' the last inserted text
|
|
124 '-' the last small (less than a line) delete
|
|
125 '=' the expression register: you are prompted to
|
|
126 enter an expression (see |expression|)
|
|
127 See |registers| about registers. {not in Vi}
|
|
128
|
|
129 CTRL-R CTRL-R {0-9a-z"%#*+/:.-=} *i_CTRL-R_CTRL-R*
|
|
130 Insert the contents of a register. Works like using a single
|
|
131 CTRL-R, but the text is inserted literally, not as if typed.
|
|
132 This differs when the register contains characters like <BS>.
|
|
133 Example, where register a contains "ab^Hc": >
|
|
134 CTRL-R a results in "ac".
|
|
135 CTRL-R CTRL-R a results in "ab^Hc".
|
|
136 < Options 'textwidth', 'formatoptions', etc. still apply. If
|
|
137 you also want to avoid these, use "<C-R><C-O>r", see below.
|
|
138 The '.' register (last inserted text) is still inserted as
|
|
139 typed. {not in Vi}
|
|
140
|
|
141 CTRL-R CTRL-O {0-9a-z"%#*+/:.-=} *i_CTRL-R_CTRL-O*
|
|
142 Insert the contents of a register literally and don't
|
|
143 auto-indent. Does the same as pasting with the mouse
|
|
144 |<MiddleMouse>|.
|
|
145 Does not replace characters!
|
|
146 The '.' register (last inserted text) is still inserted as
|
|
147 typed. {not in Vi}
|
|
148
|
|
149 CTRL-R CTRL-P {0-9a-z"%#*+/:.-=} *i_CTRL-R_CTRL-P*
|
|
150 Insert the contents of a register literally and fix the
|
|
151 indent, like |[<MiddleMouse>|.
|
|
152 Does not replace characters!
|
|
153 The '.' register (last inserted text) is still inserted as
|
|
154 typed. {not in Vi}
|
|
155
|
|
156 *i_CTRL-T*
|
|
157 CTRL-T Insert one shiftwidth of indent at the start of the current
|
|
158 line. The indent is always rounded to a 'shiftwidth' (this is
|
|
159 vi compatible). {Vi: only when in indent}
|
|
160 *i_CTRL-D*
|
|
161 CTRL-D Delete one shiftwidth of indent at the start of the current
|
|
162 line. The indent is always rounded to a 'shiftwidth' (this is
|
|
163 vi compatible). {Vi: CTRL-D works only when used after
|
|
164 autoindent}
|
|
165 *i_0_CTRL-D*
|
|
166 0 CTRL-D Delete all indent in the current line. {Vi: CTRL-D works
|
|
167 only when used after autoindent}
|
|
168 *i_^_CTRL-D*
|
|
169 ^ CTRL-D Delete all indent in the current line. The indent is
|
|
170 restored in the next line. This is useful when inserting a
|
|
171 label. {Vi: CTRL-D works only when used after autoindent}
|
|
172
|
|
173 *i_CTRL-V*
|
|
174 CTRL-V Insert next non-digit literally. For special keys, the
|
|
175 terminal code is inserted. It's also possible to enter the
|
|
176 decimal, octal or hexadecimal value of a character
|
|
177 |i_CTRL-V_digit|.
|
|
178 The characters typed right after CTRL-V are not considered for
|
|
179 mapping. {Vi: no decimal byte entry}
|
|
180 Note: When CTRL-V is mapped (e.g., to paste text) you can
|
|
181 often use CTRL-Q instead |i_CTRL-Q|.
|
|
182
|
|
183 *i_CTRL-Q*
|
|
184 CTRL-Q Same as CTRL-V.
|
|
185 Note: Some terminal connections may eat CTRL-Q, it doesn't
|
|
186 work then. It does work in the GUI.
|
|
187
|
|
188 CTRL-X Enter CTRL-X mode. This is a sub-mode where commands can
|
|
189 be given to complete words or scroll the window. See
|
|
190 |i_CTRL-X| and |ins-completion|. {not in Vi}
|
|
191
|
|
192 *i_CTRL-E*
|
|
193 CTRL-E Insert the character which is below the cursor. {not in Vi}
|
|
194 *i_CTRL-Y*
|
|
195 CTRL-Y Insert the character which is above the cursor. {not in Vi}
|
|
196 Note that for CTRL-E and CTRL-Y 'textwidth' is not used, to be
|
|
197 able to copy characters from a long line.
|
|
198
|
|
199 *i_CTRL-_*
|
|
200 CTRL-_ Switch between languages, as follows:
|
|
201 - When in a rightleft window, revins and nohkmap are toggled,
|
|
202 since English will likely be inserted in this case.
|
|
203 - When in a norightleft window, revins and hkmap are toggled,
|
|
204 since Hebrew will likely be inserted in this case.
|
|
205
|
|
206 CTRL-_ moves the cursor to the end of the typed text.
|
|
207
|
|
208 This command is only available when the 'allowrevins' option
|
|
209 is set.
|
|
210 Please refer to |rileft.txt| for more information about
|
|
211 right-to-left mode.
|
|
212 {not in Vi}
|
|
213 Only if compiled with the |+rightleft| feature (which is not
|
|
214 the default).
|
|
215 *i_CTRL-^*
|
|
216 CTRL-^ Toggle the use of typing language characters.
|
|
217 When language |:lmap| mappings are defined:
|
|
218 - If 'iminsert' is 1 (langmap mappings used) it becomes 0 (no
|
|
219 langmap mappings used).
|
|
220 - If 'iminsert' has another value it becomes 1, thus langmap
|
|
221 mappings are enabled.
|
|
222 When no language mappings are defined:
|
|
223 - If 'iminsert' is 2 (Input Method used) it becomes 0 (no
|
|
224 Input Method used).
|
|
225 - If 'iminsert' has another value it becomes 2, thus the Input
|
|
226 Method is enabled.
|
|
227 When set to 1, the value of the "b:keymap_name" variable, the
|
|
228 'keymap' option or "<lang>" appears in the status line.
|
|
229 The language mappings are normally used to type characters
|
|
230 that are different from what the keyboard produces. The
|
|
231 'keymap' option can be used to install a whole number of them.
|
|
232 {not in Vi}
|
|
233
|
|
234 *i_CTRL-]*
|
|
235 CTRL-] Trigger abbreviation, without inserting a character. {not in
|
|
236 Vi}
|
|
237
|
|
238 *i_<Insert>*
|
|
239 <Insert> Toggle between Insert and Replace mode. {not in Vi}
|
|
240 -----------------------------------------------------------------------
|
|
241
|
|
242 *i_backspacing*
|
|
243 The effect of the <BS>, CTRL-W, and CTRL-U depend on the 'backspace' option
|
|
244 (unless 'revins' is set). This is a comma separated list of items:
|
|
245
|
|
246 item action ~
|
|
247 indent allow backspacing over autoindent
|
|
248 eol allow backspacing over end-of-line (join lines)
|
|
249 start allow backspacing over the start position of insert; CTRL-W and
|
|
250 CTRL-U stop once at the start position
|
|
251
|
|
252 When 'backspace' is empty, Vi compatible backspacing is used. You cannot
|
|
253 backspace over autoindent, before column 1 or before where insert started.
|
|
254
|
|
255 For backwards compatibility the values "0", "1" and "2" are also allowed, see
|
|
256 |'backspace'|.
|
|
257
|
|
258 If the 'backspace' option does contain "eol" and the cursor is in column 1
|
|
259 when one of the three keys is used, the current line is joined with the
|
|
260 previous line. This effectively deletes the <EOL> in front of the cursor.
|
|
261 {Vi: does not cross lines, does not delete past start position of insert}
|
|
262
|
|
263 *i_CTRL-V_digit*
|
|
264 With CTRL-V the decimal, octal or hexadecimal value of a character can be
|
|
265 entered directly. This way you can enter any character, except a line break
|
|
266 (<NL>, value 10). There are five ways to enter the character value:
|
|
267
|
|
268 first char mode max nr of chars max value ~
|
|
269 (none) decimal 3 255
|
|
270 o or O octal 3 255
|
|
271 x or X hexadecimal 2 ff (255)
|
|
272 u hexadecimal 4 ffff (65535)
|
|
273 U hexadecimal 8 7fffffff (2147483647)
|
|
274
|
|
275 Normally you would type the maximum number of characters. Thus to enter a
|
|
276 space (value 32) you would type <C-V>032. You can omit the leading zero, in
|
|
277 which case the character typed after the number must be a non-digit. This
|
|
278 happens for the other modes as well: As soon as you type a character that is
|
|
279 invalid for the mode, the value before it will be used and the "invalid"
|
|
280 character is dealt with in the normal way.
|
|
281
|
|
282 If you enter a value of 10, it will end up in the file as a 0. The 10 is a
|
|
283 <NL>, which is used internally to represent the <Nul> character. When writing
|
|
284 the buffer to a file, the <NL> character is translated into <Nul>. The <NL>
|
|
285 character is written at the end of each line. Thus if you want to insert a
|
|
286 <NL> character in a file you will have to make a line break.
|
|
287
|
|
288 *i_CTRL-X* *insert_expand*
|
|
289 CTRL-X enters a sub-mode where several commands can be used. Most of these
|
|
290 commands do keyword completion; see |ins-completion|. These are not available
|
|
291 when Vim was compiled without the |+insert_expand| feature.
|
|
292
|
|
293 Two commands can be used to scroll the window up or down, without exiting
|
|
294 insert mode:
|
|
295
|
|
296 *i_CTRL-X_CTRL-E*
|
|
297 CTRL-X CTRL-E scroll window one line up.
|
|
298
|
|
299 *i_CTRL-X_CTRL-Y*
|
|
300 CTRL-X CTRL-Y scroll window one line down.
|
|
301
|
|
302 After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
|
|
303 one line unless that would cause the cursor to move from its current position
|
|
304 in the file. As soon as another key is pressed, CTRL-X mode is exited and
|
|
305 that key is interpreted as in Insert mode.
|
|
306
|
|
307
|
|
308 ==============================================================================
|
|
309 2. Special special keys *ins-special-special*
|
|
310
|
|
311 The following keys are special. They stop the current insert, do something,
|
|
312 and then restart insertion. This means you can do something without getting
|
|
313 out of Insert mode. This is very handy if you prefer to use the Insert mode
|
|
314 all the time, just like editors that don't have a separate Normal mode. You
|
|
315 may also want to set the 'backspace' option to "indent,eol,start" and set the
|
|
316 'insertmode' option. You can use CTRL-O if you want to map a function key to
|
|
317 a command.
|
|
318
|
|
319 The changes (inserted or deleted characters) before and after these keys can
|
|
320 be undone separately. Only the last change can be redone and always behaves
|
|
321 like an "i" command.
|
|
322
|
|
323 char action ~
|
|
324 -----------------------------------------------------------------------
|
|
325 <Up> cursor one line up *i_<Up>*
|
|
326 <Down> cursor one line down *i_<Down>*
|
|
327 CTRL-G <Up> cursor one line up, insert start column *i_CTRL-G_<Up>*
|
|
328 CTRL-G k cursor one line up, insert start column *i_CTRL-G_k*
|
|
329 CTRL-G CTRL-K cursor one line up, insert start column *i_CTRL-G_CTRL-K*
|
|
330 CTRL-G <Down> cursor one line down, insert start column *i_CTRL-G_<Down>*
|
|
331 CTRL-G j cursor one line down, insert start column *i_CTRL-G_j*
|
|
332 CTRL-G CTRL-J cursor one line down, insert start column *i_CTRL-G_CTRL-J*
|
|
333 <Left> cursor one character left *i_<Left>*
|
|
334 <Right> cursor one character right *i_<Right>*
|
|
335 <S-Left> cursor one word back (like "b" command) *i_<S-Left>*
|
|
336 <C-Left> cursor one word back (like "b" command) *i_<C-Left>*
|
|
337 <S-Right> cursor one word forward (like "w" command) *i_<S-Right>*
|
|
338 <C-Right> cursor one word forward (like "w" command) *i_<C-Right>*
|
|
339 <Home> cursor to first char in the line *i_<Home>*
|
|
340 <End> cursor to after last char in the line *i_<End>*
|
|
341 <C-Home> cursor to first char in the file *i_<C-Home>*
|
|
342 <C-End> cursor to after last char in the file *i_<C-End>*
|
|
343 <LeftMouse> cursor to position of mouse click *i_<LeftMouse>*
|
|
344 <S-Up> move window one page up *i_<S-Up>*
|
|
345 <PageUp> move window one page up *i_<PageUp>*
|
|
346 <S-Down> move window one page down *i_<S-Down>*
|
|
347 <PageDown> move window one page down *i_<PageDown>*
|
|
348 <MouseDown> scroll three lines down *i_<MouseDown>*
|
|
349 <S-MouseDown> scroll a full page down *i_<S-MouseDown>*
|
|
350 <MouseUp> scroll three lines up *i_<MouseUp>*
|
|
351 <S-MouseUp> scroll a full page up *i_<S-MouseUp>*
|
|
352 CTRL-O execute one command, return to Insert mode *i_CTRL-O*
|
|
353 CTRL-G u break undo sequence, start new change *i_CTRL-G_u*
|
|
354 -----------------------------------------------------------------------
|
|
355
|
|
356 Note: If the cursor keys take you out of Insert mode, check the 'noesckeys'
|
|
357 option.
|
|
358
|
|
359 The CTRL-O command sometimes has a side effect: If the cursor was beyond the
|
|
360 end of the line, it will be put on the last character in the line. In
|
|
361 mappings it's often better to use <Esc> (first put an "x" in the text, <Esc>
|
|
362 will then always put the cursor on it).
|
|
363
|
|
364 The shifted cursor keys are not available on all terminals.
|
|
365
|
|
366 Another side effect is that a count specified before the "i" or "a" command is
|
|
367 ignored. That is because repeating the effect of the command after CTRL-O is
|
|
368 too complicated.
|
|
369
|
|
370 An example for using CTRL-G u: >
|
|
371
|
|
372 :inoremap <C-H> <C-G>u<C-H>
|
|
373
|
|
374 This redefines the backspace key to start a new undo sequence. You can now
|
|
375 undo the effect of the backspace key, without changing what you typed before
|
|
376 that, with CTRL-O u.
|
|
377
|
|
378 When the 'whichwrap' option is set appropriately, the <Left> and <Right>
|
|
379 keys on the first/last character in the line make the cursor wrap to the
|
|
380 previous/next line.
|
|
381
|
|
382 The CTRL-G j and CTRL-G k commands can be used to insert text in front of a
|
|
383 column. Example: >
|
|
384 int i;
|
|
385 int j;
|
|
386 Position the cursor on the first "int", type "istatic<C-G>j ". The
|
|
387 result is: >
|
|
388 static int i;
|
|
389 int j;
|
|
390 When inserting the same text in front of the column in every line, use the
|
|
391 Visual blockwise command "I" |v_b_I|.
|
|
392
|
|
393 ==============================================================================
|
|
394 3. 'textwidth' and 'wrapmargin' options *ins-textwidth*
|
|
395
|
|
396 The 'textwidth' option can be used to automatically break a line before it
|
|
397 gets too long. Set the 'textwidth' option to the desired maximum line
|
|
398 length. If you then type more characters (not spaces or tabs), the
|
|
399 last word will be put on a new line (unless it is the only word on the
|
|
400 line). If you set 'textwidth' to 0, this feature is disabled.
|
|
401
|
|
402 The 'wrapmargin' option does almost the same. The difference is that
|
|
403 'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
|
|
404 screen. When using 'wrapmargin' this is equal to using 'textwidth' with a
|
|
405 value equal to (columns - 'wrapmargin'), where columns is the width of the
|
|
406 screen.
|
|
407
|
|
408 When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
|
|
409
|
|
410 If you don't really want to break the line, but view the line wrapped at a
|
|
411 convenient place, see the 'linebreak' option.
|
|
412
|
|
413 The line is only broken automatically when using insert mode, or when
|
|
414 appending to a line. When in replace mode and the line length is not
|
|
415 changed, the line will not be broken.
|
|
416
|
|
417 Long lines are broken if you enter a non-white character after the margin.
|
|
418 The situations where a line will be broken can be restricted by adding
|
|
419 characters to the 'formatoptions' option:
|
|
420 "l" Only break a line if it was not longer than 'textwidth' when the insert
|
|
421 started.
|
|
422 "v" Only break at a white character that has been entered during the
|
|
423 current insert command. This is mostly Vi-compatible.
|
|
424 "lv" Only break if the line was not longer than 'textwidth' when the insert
|
|
425 started and only at a white character that has been entered during the
|
|
426 current insert command. Only differs from "l" when entering non-white
|
|
427 characters while crossing the 'textwidth' boundary.
|
|
428
|
|
429 If you want to format a block of text, you can use the "gq" operator. Type
|
|
430 "gq" and a movement command to move the cursor to the end of the block. In
|
|
431 many cases, the command "gq}" will do what you want (format until the end of
|
|
432 paragraph). Alternatively, you can use "gqap", which will format the whole
|
|
433 paragraph, no matter where the cursor currently is. Or you can use Visual
|
|
434 mode: hit "v", move to the end of the block, and type "gq". See also |gq|.
|
|
435
|
|
436 ==============================================================================
|
|
437 4. 'expandtab', 'smarttab' and 'softtabstop' options *ins-expandtab*
|
|
438
|
|
439 If the 'expandtab' option is on, spaces will be used to fill the amount of
|
|
440 whitespace of the tab. If you want to enter a real <Tab>, type CTRL-V first
|
|
441 (use CTRL-Q when CTRL-V is mapped |i_CTRL-Q|).
|
|
442 The 'expandtab' option is off by default. Note that in Replace mode, a single
|
|
443 character is replaced with several spaces. The result of this is that the
|
|
444 number of characters in the line increases. Backspacing will delete one
|
|
445 space at a time. The original character will be put back for only one space
|
|
446 that you backspace over (the last one). {Vi does not have the 'expandtab'
|
|
447 option}
|
|
448
|
|
449 *ins-smarttab*
|
|
450 When the 'smarttab' option is on, a <Tab> inserts 'shiftwidth' positions at
|
|
451 the beginning of a line and 'tabstop' positions in other places. This means
|
|
452 that often spaces instead of a <Tab> character are inserted. When 'smarttab
|
|
453 is off, a <Tab> always inserts 'tabstop' positions, and 'shiftwidth' is only
|
|
454 used for ">>" and the like. {not in Vi}
|
|
455
|
|
456 *ins-softtabstop*
|
|
457 When the 'softtabstop' option is non-zero, a <Tab> inserts 'softtabstop'
|
|
458 positions, and a <BS> used to delete white space, will delete 'softtabstop'
|
|
459 positions. This feels like 'tabstop' was set to 'softtabstop', but a real
|
|
460 <Tab> character still takes 'tabstop' positions, so your file will still look
|
|
461 correct when used by other applications.
|
|
462
|
|
463 If 'softtabstop' is non-zero, a <BS> will try to delete as much white space to
|
|
464 move to the previous 'softtabstop' position, except when the previously
|
|
465 inserted character is a space, then it will only delete the character before
|
|
466 the cursor. Otherwise you cannot always delete a single character before the
|
|
467 cursor. You will have to delete 'softtabstop' characters first, and then type
|
|
468 extra spaces to get where you want to be.
|
|
469
|
|
470 ==============================================================================
|
|
471 5. Replace mode *Replace* *Replace-mode* *mode-replace*
|
|
472
|
|
473 Enter Replace mode with the "R" command in normal mode.
|
|
474
|
|
475 In Replace mode, one character in the line is deleted for every character you
|
|
476 type. If there is no character to delete (at the end of the line), the
|
|
477 typed character is appended (as in Insert mode). Thus the number of
|
|
478 characters in a line stays the same until you get to the end of the line.
|
|
479 If a <NL> is typed, a line break is inserted and no character is deleted.
|
|
480
|
|
481 Be careful with <Tab> characters. If you type a normal printing character in
|
|
482 its place, the number of characters is still the same, but the number of
|
|
483 columns will become smaller.
|
|
484
|
|
485 If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), what
|
|
486 happens is that you delete the changes. The characters that were replaced
|
|
487 are restored. If you had typed past the existing text, the characters you
|
|
488 added are deleted. This is effectively a character-at-a-time undo.
|
|
489
|
|
490 If the 'expandtab' option is on, a <Tab> will replace one character with
|
|
491 several spaces. The result of this is that the number of characters in the
|
|
492 line increases. Backspacing will delete one space at a time. The original
|
|
493 character will be put back for only one space that you backspace over (the
|
|
494 last one). {Vi does not have the 'expandtab' option}
|
|
495
|
|
496 ==============================================================================
|
|
497 6. Virtual Replace mode *vreplace-mode* *Virtual-Replace-mode*
|
|
498
|
|
499 Enter Virtual Replace mode with the "gR" command in normal mode.
|
|
500 {not available when compiled without the +vreplace feature}
|
|
501 {Vi does not have Virtual Replace mode}
|
|
502
|
|
503 Virtual Replace mode is similar to Replace mode, but instead of replacing
|
|
504 actual characters in the file, you are replacing screen real estate, so that
|
|
505 characters further on in the file never appear to move.
|
|
506
|
|
507 So if you type a <Tab> it may replace several normal characters, and if you
|
|
508 type a letter on top of a <Tab> it may not replace anything at all, since the
|
|
509 <Tab> will still line up to the same place as before.
|
|
510
|
|
511 Typing a <NL> still doesn't cause characters later in the file to appear to
|
|
512 move. The rest of the current line will be replaced by the <NL> (that is,
|
|
513 they are deleted), and replacing continues on the next line. A new line is
|
|
514 NOT inserted unless you go past the end of the file.
|
|
515
|
|
516 Interesting effects are seen when using CTRL-T and CTRL-D. The characters
|
|
517 before the cursor are shifted sideways as normal, but characters later in the
|
|
518 line still remain still. CTRL-T will hide some of the old line under the
|
|
519 shifted characters, but CTRL-D will reveal them again.
|
|
520
|
|
521 As with Replace mode, using <BS> etc will bring back the characters that were
|
|
522 replaced. This still works in conjunction with 'smartindent', CTRL-T and
|
|
523 CTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.
|
|
524
|
|
525 In 'list' mode, Virtual Replace mode acts as if it was not in 'list' mode,
|
|
526 unless "L" is in 'cpoptions'.
|
|
527
|
|
528 Note that the only times characters beyond the cursor should appear to move
|
|
529 are in 'list' mode, and occasionally when 'wrap' is set (and the line changes
|
|
530 length to become shorter or wider than the width of the screen), or
|
|
531 momentarily when typing over a CTRL character. A CTRL character takes up two
|
|
532 screen spaces. When replacing it with two normal characters, the first will
|
|
533 be inserted and the second will replace the CTRL character.
|
|
534
|
|
535 This mode is very useful for editing <Tab> separated columns in tables, for
|
|
536 entering new data while keeping all the columns aligned.
|
|
537
|
|
538 ==============================================================================
|
|
539 7. Insert mode completion *ins-completion*
|
|
540
|
|
541 In Insert and Replace modes, there are several commands to complete part of a
|
|
542 keyword or line that has been typed. This is useful if you are using
|
|
543 complicated keywords (e.g., function names with capitals and underscores).
|
|
544
|
|
545 These commands are not available when the |+insert_expand| feature was
|
|
546 disabled at compile time.
|
|
547
|
|
548 Completion can be done for:
|
|
549
|
|
550 1. Whole lines |i_CTRL-X_CTRL-L|
|
|
551 2. keywords in the current file |i_CTRL-X_CTRL-N|
|
|
552 3. keywords in 'dictionary' |i_CTRL-X_CTRL-K|
|
|
553 4. keywords in 'thesaurus', thesaurus-style |i_CTRL-X_CTRL-T|
|
|
554 5. keywords in the current and included files |i_CTRL-X_CTRL-I|
|
|
555 6. tags |i_CTRL-X_CTRL-]|
|
|
556 7. file names |i_CTRL-X_CTRL-F|
|
|
557 8. definitions or macros |i_CTRL-X_CTRL-D|
|
|
558 9. Vim command-line |i_CTRL-X_CTRL-V|
|
|
559 10. keywords in 'complete' |i_CTRL-N|
|
|
560
|
|
561 All these (except 2) are done in CTRL-X mode. This is a sub-mode of Insert
|
|
562 and Replace modes. You enter CTRL-X mode by typing CTRL-X and one of the
|
|
563 CTRL-X commands. You exit CTRL-X mode by typing a key that is not a valid
|
|
564 CTRL-X mode command. Valid keys are the CTRL-X command itself, CTRL-N (next),
|
|
565 and CTRL-P (previous).
|
|
566
|
|
567 Also see the 'infercase' option if you want to adjust the case of the match.
|
|
568
|
|
569 Note: The keys that are valid in CTRL-X mode are not mapped. This allows for
|
|
570 ":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X). The key that
|
|
571 ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.
|
|
572 Also, when doing completion with 'complete' mappings apply as usual.
|
|
573
|
|
574 The following mappings are suggested to make typing the completion commands
|
|
575 a bit easier (although they will hide other commands): >
|
|
576 :inoremap ^] ^X^]
|
|
577 :inoremap ^F ^X^F
|
|
578 :inoremap ^D ^X^D
|
|
579 :inoremap ^L ^X^L
|
|
580
|
|
581 As a special case, typing CTRL-R to perform register insertion (see
|
|
582 |i_CTRL-R|) will not exit CTRL-X mode. This is primarily to allow the use of
|
|
583 the '=' register to call some function to determine the next operation. If
|
|
584 the contents of the register (or result of the '=' register evaluation) are
|
|
585 not valid CTRL-X mode keys, then CTRL-X mode will be exited as if those keys
|
|
586 had been typed.
|
|
587
|
|
588 For example, the following will map <Tab> to either actually insert a <Tab> if
|
|
589 the current line is currently only whitespace, or start/continue a CTRL-N
|
|
590 completion operation: >
|
|
591
|
|
592 function! CleverTab()
|
|
593 if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
|
|
594 return "\<Tab>"
|
|
595 else
|
|
596 return "\<C-N>"
|
|
597 endfunction
|
|
598 inoremap <Tab> <C-R>=CleverTab()<CR>
|
|
599
|
|
600
|
|
601
|
|
602 Completing whole lines *compl-whole-line*
|
|
603
|
|
604 *i_CTRL-X_CTRL-L*
|
|
605 CTRL-X CTRL-L Search backwards for a line that starts with the
|
|
606 same characters as in the current line before the
|
|
607 cursor. Indent is ignored. The found line is
|
|
608 inserted in front of the cursor.
|
|
609 The 'complete' option is used to decide in which
|
|
610 buffers a match is searched for. But only loaded
|
|
611 buffers are used.
|
|
612 CTRL-L or
|
|
613 CTRL-P Search backwards for next matching line. This line
|
|
614 replaces the previous matching line.
|
|
615
|
|
616 CTRL-N Search forward for next matching line. This line
|
|
617 replaces the previous matching line.
|
|
618
|
|
619 CTRL-X CTRL-L After expanding a line you can additionally get the
|
|
620 line next to it by typing CTRL-X CTRL-L again, unless
|
|
621 a double CTRL-X is used.
|
|
622
|
|
623 Completing keywords in current file *compl-current*
|
|
624
|
|
625 *i_CTRL-X_CTRL-P*
|
|
626 *i_CTRL-X_CTRL-N*
|
|
627 CTRL-X CTRL-N Search forwards for words that start with the keyword
|
|
628 in front of the cursor. The found keyword is inserted
|
|
629 in front of the cursor.
|
|
630
|
|
631 CTRL-X CTRL-P Search backwards for words that start with the keyword
|
|
632 in front of the cursor. The found keyword is inserted
|
|
633 in front of the cursor.
|
|
634
|
|
635 CTRL-N Search forward for next matching keyword. This
|
|
636 keyword replaces the previous matching keyword.
|
|
637
|
|
638 CTRL-P Search backwards for next matching keyword. This
|
|
639 keyword replaces the previous matching keyword.
|
|
640
|
|
641 CTRL-X CTRL-N or
|
|
642 CTRL-X CTRL-P Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
|
|
643 copy the words following the previous expansion in
|
|
644 other contexts unless a double CTRL-X is used.
|
|
645
|
|
646 If there is a keyword in front of the cursor (a name made out of alphabetic
|
|
647 characters and characters in 'iskeyword'), it is used as the search pattern,
|
|
648 with "\<" prepended (meaning: start of a word). Otherwise "\<\k\k" is used
|
|
649 as search pattern (start of any keyword of at least two characters).
|
|
650
|
|
651 In Replace mode, the number of characters that are replaced depends on the
|
|
652 length of the matched string. This works like typing the characters of the
|
|
653 matched string in Replace mode.
|
|
654
|
|
655 If there is not a valid keyword character before the cursor, any keyword of
|
|
656 at least two characters is matched.
|
|
657 e.g., to get:
|
|
658 printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
|
|
659 just type:
|
|
660 printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
|
|
661
|
|
662 Multiple repeats of the same completion are skipped; thus a different match
|
|
663 will be inserted at each CTRL-N and CTRL-P (unless there is only one
|
|
664 matching keyword).
|
|
665
|
|
666 Single character matches are never included, as they usually just get in
|
|
667 the way of what you were really after.
|
|
668 e.g., to get:
|
|
669 printf("name = %s\n", name);
|
|
670 just type:
|
|
671 printf("name = %s\n", n^P);
|
|
672 or even:
|
|
673 printf("name = %s\n", ^P);
|
|
674 The 'n' in '\n' is skipped.
|
|
675
|
|
676 After expanding a word, you can use CTRL-X CTRL-P or CTRL-X CTRL-N to get the
|
|
677 word following the expansion in other contexts. These sequences search for
|
|
678 the text just expanded and further expand by getting an extra word. This is
|
|
679 useful if you need to repeat a sequence of complicated words. Although CTRL-P
|
|
680 and CTRL-N look just for strings of at least two characters, CTRL-X CTRL-P and
|
|
681 CTRL-X CTRL-N can be used to expand words of just one character.
|
|
682 e.g., to get:
|
|
683 México
|
|
684 you can type:
|
|
685 M^N^P^X^P^X^P
|
|
686 CTRL-N starts the expansion and then CTRL-P takes back the single character
|
|
687 "M", the next two CTRL-X CTRL-P's get the words "é" and ";xico".
|
|
688
|
|
689 If the previous expansion was split, because it got longer than 'textwidth',
|
|
690 then just the text in the current line will be used.
|
|
691
|
|
692 If the match found is at the end of a line, then the first word in the next
|
|
693 line will be inserted and the message "word from next line" displayed, if
|
|
694 this word is accepted the next CTRL-X CTRL-P or CTRL-X CTRL-N will search
|
|
695 for those lines starting with this word.
|
|
696
|
|
697
|
|
698 Completing keywords in 'dictionary' *compl-dictionary*
|
|
699
|
|
700 *i_CTRL-X_CTRL-K*
|
|
701 CTRL-X CTRL-K Search the files given with the 'dictionary' option
|
|
702 for words that start with the keyword in front of the
|
|
703 cursor. This is like CTRL-N, but only the dictionary
|
|
704 files are searched, not the current file. The found
|
|
705 keyword is inserted in front of the cursor. This
|
|
706 could potentially be pretty slow, since all matches
|
|
707 are found before the first match is used. By default,
|
|
708 the 'dictionary' option is empty.
|
|
709 For suggestions where to find a list of words, see the
|
|
710 'dictionary' option.
|
|
711
|
|
712 CTRL-K or
|
|
713 CTRL-N Search forward for next matching keyword. This
|
|
714 keyword replaces the previous matching keyword.
|
|
715
|
|
716 CTRL-P Search backwards for next matching keyword. This
|
|
717 keyword replaces the previous matching keyword.
|
|
718
|
|
719 *i_CTRL-X_CTRL-T*
|
|
720 CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses
|
|
721 the 'thesaurus' option instead of 'dictionary'. If a
|
|
722 match is found in the thesaurus file, all the
|
|
723 remaining words on the same line are included as
|
|
724 matches, even though they don't complete the word.
|
|
725 Thus a word can be completely replaced.
|
|
726
|
|
727 For an example, imagine the 'thesaurus' file has a
|
|
728 line like this: >
|
|
729 angry furious mad enraged
|
|
730 < Placing the cursor after the letters "ang" and typing
|
|
731 CTRL-X CTRL-T would complete the word "angry";
|
|
732 subsequent presses would change the word to "furious",
|
|
733 "mad" etc.
|
|
734 Other uses include translation between two languages,
|
|
735 or grouping API functions by keyword.
|
|
736
|
|
737 CTRL-T or
|
|
738 CTRL-N Search forward for next matching keyword. This
|
|
739 keyword replaces the previous matching keyword.
|
|
740
|
|
741 CTRL-P Search backwards for next matching keyword. This
|
|
742 keyword replaces the previous matching keyword.
|
|
743
|
|
744
|
|
745 Completing keywords in the current and included files *compl-keyword*
|
|
746
|
|
747 The 'include' option is used to specify a line that contains an include file
|
|
748 name. The 'path' option is used to search for include files.
|
|
749
|
|
750 *i_CTRL-X_CTRL-I*
|
|
751 CTRL-X CTRL-I Search for the first keyword in the current and
|
|
752 included files that starts with the same characters
|
|
753 as those before the cursor. The matched keyword is
|
|
754 inserted in front of the cursor.
|
|
755
|
|
756 CTRL-N Search forwards for next matching keyword. This
|
|
757 keyword replaces the previous matching keyword.
|
|
758 Note: CTRL-I is the same as <Tab>, which is likely to
|
|
759 be typed after a successful completion, therefore
|
|
760 CTRL-I is not used for searching for the next match.
|
|
761
|
|
762 CTRL-P Search backward for previous matching keyword. This
|
|
763 keyword replaces the previous matching keyword.
|
|
764
|
|
765 CTRL-X CTRL-I Further use of CTRL-X CTRL-I will copy the words
|
|
766 following the previous expansion in other contexts
|
|
767 unless a double CTRL-X is used.
|
|
768
|
|
769 Completing tags *compl-tag*
|
|
770 *i_CTRL-X_CTRL-]*
|
|
771 CTRL-X CTRL-] Search for the first tag that starts with the same
|
|
772 characters as before the cursor. The matching tag is
|
|
773 inserted in front of the cursor. Alphabetic
|
|
774 characters and characters in 'iskeyword' are used
|
|
775 to decide which characters are included in the tag
|
|
776 name (same as for a keyword). See also |CTRL-]|.
|
|
777 The 'showfulltag' option can be used to add context
|
|
778 from around the tag definition.
|
|
779 CTRL-] or
|
|
780 CTRL-N Search forwards for next matching tag. This tag
|
|
781 replaces the previous matching tag.
|
|
782
|
|
783 CTRL-P Search backward for previous matching tag. This tag
|
|
784 replaces the previous matching tag.
|
|
785
|
|
786
|
|
787 Completing file names *compl-filename*
|
|
788 *i_CTRL-X_CTRL-F*
|
|
789 CTRL-X CTRL-F Search for the first file name that starts with the
|
|
790 same characters as before the cursor. The matching
|
|
791 file name is inserted in front of the cursor.
|
|
792 Alphabetic characters and characters in 'isfname'
|
|
793 are used to decide which characters are included in
|
|
794 the file name. Note: the 'path' option is not used
|
|
795 here (yet).
|
|
796 CTRL-F or
|
|
797 CTRL-N Search forwards for next matching file name. This
|
|
798 file name replaces the previous matching file name.
|
|
799
|
|
800 CTRL-P Search backward for previous matching file name.
|
|
801 This file name replaces the previous matching file
|
|
802 name.
|
|
803
|
|
804
|
|
805 Completing definitions or macros *compl-define*
|
|
806
|
|
807 The 'define' option is used to specify a line that contains a definition.
|
|
808 The 'include' option is used to specify a line that contains an include file
|
|
809 name. The 'path' option is used to search for include files.
|
|
810
|
|
811 *i_CTRL-X_CTRL-D*
|
|
812 CTRL-X CTRL-D Search in the current and included files for the
|
|
813 first definition (or macro) name that starts with
|
|
814 the same characters as before the cursor. The found
|
|
815 definition name is inserted in front of the cursor.
|
|
816 CTRL-D or
|
|
817 CTRL-N Search forwards for next matching macro name. This
|
|
818 macro name replaces the previous matching macro
|
|
819 name.
|
|
820
|
|
821 CTRL-P Search backward for previous matching macro name.
|
|
822 This macro name replaces the previous matching macro
|
|
823 name.
|
|
824
|
|
825 CTRL-X CTRL-D Further use of CTRL-X CTRL-D will copy the words
|
|
826 following the previous expansion in other contexts
|
|
827 unless a double CTRL-X is used.
|
|
828
|
|
829
|
|
830 Completing Vim commands *compl-vim*
|
|
831
|
|
832 Completion is context-sensitive. It works like on the Command-line. It
|
|
833 completes an Ex command as well as its arguments.
|
|
834
|
|
835 *i_CTRL-X_CTRL-V*
|
|
836 CTRL-X CTRL-V Guess what kind of item is in front of the cursor and
|
|
837 find the first match for it.
|
|
838 Note: When CTRL-V is mapped you can often use CTRL-Q
|
|
839 instead |i_CTRL-Q|.
|
|
840 CTRL-V or
|
|
841 CTRL-N Search forwards for next match. This match replaces
|
|
842 the previous one.
|
|
843
|
|
844 CTRL-P Search backward for previous match. This match
|
|
845 replaces the previous one.
|
|
846
|
|
847 CTRL-X CTRL-V Further use of CTRL-X CTRL-V will do the same as
|
|
848 CTRL-V. This allows mapping a key to do Vim command
|
|
849 completion, for example: >
|
|
850 :imap <Tab> <C-X><C-V>
|
|
851
|
|
852 Completing keywords from different sources *compl-generic*
|
|
853
|
|
854 *i_CTRL-N*
|
|
855 CTRL-N Find next match for words that start with the
|
|
856 keyword in front of the cursor, looking in places
|
|
857 specified with the 'complete' option. The found
|
|
858 keyword is inserted in front of the cursor.
|
|
859
|
|
860 *i_CTRL-P*
|
|
861 CTRL-P Find previous match for words that start with the
|
|
862 keyword in front of the cursor, looking in places
|
|
863 specified with the 'complete' option. The found
|
|
864 keyword is inserted in front of the cursor.
|
|
865
|
|
866 CTRL-N Search forward for next matching keyword. This
|
|
867 keyword replaces the previous matching keyword.
|
|
868
|
|
869 CTRL-P Search backwards for next matching keyword. This
|
|
870 keyword replaces the previous matching keyword.
|
|
871
|
|
872 CTRL-X CTRL-N or
|
|
873 CTRL-X CTRL-P Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
|
|
874 copy the words following the previous expansion in
|
|
875 other contexts unless a double CTRL-X is used.
|
|
876
|
|
877 ==============================================================================
|
|
878 8. Insert mode commands *inserting*
|
|
879
|
|
880 The following commands can be used to insert new text into the buffer. They
|
|
881 can all be undone and repeated with the "." command.
|
|
882
|
|
883 *a*
|
|
884 a Append text after the cursor [count] times. If the
|
|
885 cursor is in the first column of an empty line Insert
|
|
886 starts there. But not when 'virtualedit' is set!
|
|
887
|
|
888 *A*
|
|
889 A Append text at the end of the line [count] times.
|
|
890
|
|
891 <insert> or *i* *insert* *<Insert>*
|
|
892 i Insert text before the cursor [count] times.
|
|
893 When using CTRL-O in Insert mode |i_CTRL-O| the count
|
|
894 is not supported.
|
|
895
|
|
896 *I*
|
|
897 I Insert text before the first non-blank in the line
|
|
898 [count] times.
|
|
899
|
|
900 *gI*
|
|
901 gI Insert text in column 1 [count] times. {not in Vi}
|
|
902
|
|
903 *gi*
|
|
904 gi Insert text in the same position as where Insert mode
|
|
905 was stopped last time in the current buffer.
|
|
906 This uses the |'^| mark. It's different from "`^i"
|
|
907 when the mark is past the end of the line.
|
|
908 The position is corrected for inserted/deleted lines,
|
|
909 but NOT for inserted/deleted characters.
|
|
910 When the |:keepjumps| command modifier is used the |'^|
|
9
|
911 mark won't be changed.
|
7
|
912 {not in Vi}
|
|
913
|
|
914 *o*
|
|
915 o Begin a new line below the cursor and insert text,
|
|
916 repeat [count] times. {Vi: blank [count] screen
|
|
917 lines}
|
|
918
|
|
919 *O*
|
|
920 O Begin a new line above the cursor and insert text,
|
|
921 repeat [count] times. {Vi: blank [count] screen
|
|
922 lines}
|
|
923
|
|
924 These commands are used to start inserting text. You can end insert mode with
|
|
925 <Esc>. See |mode-ins-repl| for the other special characters in Insert mode.
|
|
926 The effect of [count] takes place after Insert mode is exited.
|
|
927
|
|
928 When 'autoindent' is on, the indent for a new line is obtained from the
|
|
929 previous line. When 'smartindent' or 'cindent' is on, the indent for a line
|
|
930 is automatically adjusted for C programs.
|
|
931
|
|
932 'textwidth' can be set to the maximum width for a line. When a line becomes
|
|
933 too long when appending characters a line break is automatically inserted.
|
|
934
|
|
935
|
|
936 ==============================================================================
|
|
937 9. Ex insert commands *inserting-ex*
|
|
938
|
|
939 *:a* *:append*
|
|
940 :{range}a[ppend] Insert several lines of text below the specified
|
|
941 line. If the {range} is missing, the text will be
|
|
942 inserted after the current line.
|
|
943
|
|
944 *:i* *:in* *:insert*
|
|
945 :{range}i[nsert] Insert several lines of text above the specified
|
|
946 line. If the {range} is missing, the text will be
|
|
947 inserted before the current line.
|
|
948
|
|
949 These two commands will keep on asking for lines, until you type a line
|
|
950 containing only a ".". Watch out for lines starting with a backslash, see
|
|
951 |line-continuation|.
|
|
952 NOTE: ":append" and ":insert" don't work properly in between ":if" and
|
|
953 ":endif".
|
|
954
|
|
955 *:start* *:startinsert*
|
|
956 :star[tinsert][!] Start Insert mode just after executing this command.
|
|
957 Works like typing "i" in Normal mode. When the ! is
|
|
958 included it works like "A", append to the line.
|
|
959 Otherwise insertion starts at the cursor position.
|
|
960 Note that when using this command in a function or
|
|
961 script, the insertion only starts after the function
|
|
962 or script is finished.
|
|
963 {not in Vi}
|
|
964 {not available when compiled without the +ex_extra
|
|
965 feature}
|
|
966
|
|
967 *:stopi* *:stopinsert*
|
|
968 :stopi[nsert] Stop Insert mode as soon as possible. Works like
|
|
969 typing <Esc> in Insert mode.
|
|
970 Can be used in an autocommand, example: >
|
|
971 :au BufEnter scratch stopinsert
|
|
972
|
|
973 ==============================================================================
|
|
974 10. Inserting a file *inserting-file*
|
|
975
|
|
976 *:r* *:re* *:read*
|
|
977 :r[ead] [name] Insert the file [name] (default: current file) below
|
|
978 the cursor.
|
|
979
|
|
980 :{range}r[ead] [name] Insert the file [name] (default: current file) below
|
|
981 the specified line.
|
|
982
|
|
983 *:r!* *:read!*
|
|
984 :r[ead] !{cmd} Execute {cmd} and insert its standard output below
|
|
985 the cursor. A temporary file is used to store the
|
|
986 output of the command which is then read into the
|
|
987 buffer. 'shellredir' is used to save the output of
|
|
988 the command, which can be set to include stderr or
|
|
989 not. {cmd} is executed like with ":!{cmd}", any '!'
|
|
990 is replaced with the previous command |:!|.
|
|
991
|
|
992 These commands insert the contents of a file, or the output of a command,
|
|
993 into the buffer. They can be undone. They cannot be repeated with the "."
|
|
994 command. They work on a line basis, insertion starts below the line in which
|
|
995 the cursor is, or below the specified line. To insert text above the first
|
|
996 line use the command ":0r {name}".
|
|
997
|
|
998 After the ":read" command, the cursor is left on the first non-blank in the
|
|
999 first new line. Unless in Ex mode, then the cursor is left on the last new
|
|
1000 line (sorry, this is Vi compatible).
|
|
1001
|
|
1002 If a file name is given with ":r", it becomes the alternate file. This can be
|
|
1003 used, for example, when you want to edit that file instead: ":e! #". This can
|
|
1004 be switched off by removing the 'a' flag from the 'cpoptions' option.
|
|
1005
|
|
1006 *file-read*
|
|
1007 The 'fileformat' option sets the <EOL> style for a file:
|
|
1008 'fileformat' characters name ~
|
|
1009 "dos" <CR><NL> or <NL> DOS format
|
|
1010 "unix" <NL> Unix format
|
|
1011 "mac" <CR> Mac format
|
|
1012 Previously 'textmode' was used. It is obsolete now.
|
|
1013
|
|
1014 If 'fileformat' is "dos", a <CR> in front of an <NL> is ignored and a CTRL-Z
|
|
1015 at the end of the file is ignored.
|
|
1016
|
|
1017 If 'fileformat' is "mac", a <NL> in the file is internally represented by a
|
|
1018 <CR>. This is to avoid confusion with a <NL> which is used to represent a
|
|
1019 <NUL>. See |CR-used-for-NL|.
|
|
1020
|
|
1021 If the 'fileformats' option is not empty Vim tries to recognize the type of
|
|
1022 <EOL> (see |file-formats|). However, the 'fileformat' option will not be
|
|
1023 changed, the detected format is only used while reading the file.
|
|
1024 A similar thing happens with 'fileencodings'.
|
|
1025
|
|
1026 On non-MS-DOS, Win32, and OS/2 systems the message "[dos format]" is shown if
|
|
1027 a file is read in DOS format, to remind you that something unusual is done.
|
|
1028 On Macintosh, MS-DOS, Win32, and OS/2 the message "[unix format]" is shown if
|
|
1029 a file is read in Unix format.
|
|
1030 On non-Macintosh systems, the message "[Mac format]" is shown if a file is
|
|
1031 read in Mac format.
|
|
1032
|
|
1033 An example on how to use ":r !": >
|
|
1034 :r !uuencode binfile binfile
|
|
1035 This command reads "binfile", uuencodes it and reads it into the current
|
|
1036 buffer. Useful when you are editing e-mail and want to include a binary
|
|
1037 file.
|
|
1038
|
|
1039 *read-messages*
|
|
1040 When reading a file Vim will display a message with information about the read
|
|
1041 file. In the table is an explanation for some of the items. The others are
|
|
1042 self explanatory. Using the long or the short version depends on the
|
|
1043 'shortmess' option.
|
|
1044
|
|
1045 long short meaning ~
|
|
1046 [readonly] {RO} the file is write protected
|
|
1047 [fifo/socket] using a stream
|
|
1048 [fifo] using a fifo stream
|
|
1049 [socket] using a socket stream
|
|
1050 [CR missing] reading with "dos" 'fileformat' and a
|
|
1051 NL without a preceding CR was found.
|
|
1052 [NL found] reading with "mac" 'fileformat' and a
|
|
1053 NL was found (could be "unix" format)
|
|
1054 [long lines split] at least one line was split in two
|
|
1055 [NOT converted] conversion from 'fileencoding' to
|
|
1056 'encoding' was desired but not
|
|
1057 possible
|
|
1058 [converted] conversion from 'fileencoding' to
|
|
1059 'encoding' done
|
|
1060 [crypted] file was decrypted
|
|
1061 [READ ERRORS] not all of the file could be read
|
|
1062
|
|
1063
|
|
1064 vim:tw=78:ts=8:ft=help:norl:
|