Start anew
[msysgit.git] / share / vim / vim58 / doc / insert.txt
blobfa0fbdfb83d9a38a2b8d3f1cc299b90fc8f8e3cc
1 *insert.txt*    For Vim version 5.8.  Last change: 2001 Jan 18
4                   VIM REFERENCE MANUAL    by Bram Moolenaar
7                                                 *Insert* *Insert-mode*
8 Inserting and replacing text                            *mode-ins-repl*
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.
13 1. Special keys                                         |ins-special-keys|
14 2. Special special keys                                 |ins-special-special|
15 3. 'textwidth' and 'wrapmargin' options                 |ins-textwidth|
16 4. 'expandtab', 'smarttab' and 'softtabstop'  options   |ins-expandtab|
17 5. Replace mode                                         |Replace-mode|
18 6. Virtual replace mode                                 |Virtual-replace-mode|
19 7. Insert mode completion                               |ins-completion|
20 8. Insert mode commands                                 |inserting|
21 9. Ex insert commands                                   |inserting-ex|
22 10. Inserting a file                                    |inserting-file|
24 ==============================================================================
25 1. Special keys                                         *ins-special-keys*
27 In Insert and Replace mode, the following characters have a special meaning;
28 other characters are inserted directly.  To insert one of these special
29 characters into the buffer, precede it with CTRL-V.  To insert a <Nul>
30 character use "CTRL-V CTRL-@" or "CTRL-V 000".  On some systems, you have to
31 use "CTRL-V 003" to insert a CTRL-C.
33 If you are working in a special language mode when inserting text, see the
34 'langmap' option, |'langmap'|, on how to avoid switching this mode on and off
35 all the time.
37 If you have 'insertmode' set, <Esc> and a few other keys get another meaning.
38 See |'insertmode'|.
40 char            action  ~
41 -----------------------------------------------------------------------
42                                                 *i_CTRL-[* *i_<Esc>*
43 <Esc> or CTRL-[ End insert or Replace mode, go back to Normal mode.  Finish
44                 abbreviation.
45                 Note: If your <Esc> key is hard to hit on your keyboard, train
46                 yourself to use CTRL-[.
47                                                 *i_CTRL-C*
48 CTRL-C          Quit insert mode, go back to Normal mode.  Do not check for
49                 abbreviations.
51                                                 *i_CTRL-@*
52 CTRL-@          Insert previously inserted text and stop insert.  {Vi: only
53                 when typed as first char, only up to 128 chars}
54                                                 *i_CTRL-A*
55 CTRL-A          Insert previously inserted text.  {not in Vi}
57                                                 *i_CTRL-H* *i_<BS>*
58 <BS> or CTRL-H  Delete the character before the cursor (see |i_backspacing|
59                 about joining lines).
60                 See |:fixdel| if your <BS> key does not do what you want.
61                 {Vi: does not delete autoindents}
62                                                 *i_<Del>*
63 <Del>           Delete the character under the cursor.  If the cursor is at
64                 the end of the line, and the 'backspace' option includes
65                 "eol", delete the <EOL>; the next line is appended after the
66                 current one.
67                 See |:fixdel| if your <Del> key does not do what you want.
68                 {not in Vi}
69                                                 *i_CTRL-W*
70 CTRL-W          Delete the word before the cursor (see |i_backspacing| about
71                 joining lines).  See the section "word motions",
72                 |word-motions|, for the definition of a word.
73                                                 *i_CTRL-U*
74 CTRL-U          Delete all entered characters in the current line (see
75                 |i_backspacing| about joining lines).
77                                                 *i_CTRL-I* *i_<Tab>*
78 <Tab> or CTRL-I Insert a tab.  If the 'expandtab' option is on, the
79                 equivalent number of spaces is inserted (use CTRL-V <Tab> to
80                 avoid the expansion).  See also the 'smarttab' option and
81                 |ins-expandtab|.
82                                                 *i_CTRL-J* *i_<NL>*
83 <NL> or CTRL-J  Begin new line.
84                                                 *i_CTRL-M* *i_<CR>*
85 <CR> or CTRL-M  Begin new line.
86                                                 *i_CTRL-K*
87 CTRL-K {char1} [char2]
88                 Enter digraph (see |digraphs|).  When {char1} is a special
89                 key, the code for that key is inserted in <> form.  For
90                 example, the string "<S-Space>" can be entered by typing
91                 <C-K><S-Space> (two keys).  Neither char is considered for
92                 mapping.  {not in Vi}
94 CTRL-N          Find next keyword (see |i_CTRL-N|).  {not in Vi}
95 CTRL-P          Find previous keyword (see |i_CTRL-P|).  {not in Vi}
97 CTRL-R {0-9a-z"%#:.-=}                          *i_CTRL-R* *i_<C-R>*
98                 Insert the contents of a register.  Between typing CTRL-R and
99                 the second character, '"' will be displayed to indicate that
100                 you are expected to enter the name of a register.
101                 The text is inserted as if you typed it, but mappings and
102                 abbreviations are not used.  If you have options like
103                 'textwidth', 'formatoptions', or 'autoindent' set, this will
104                 influence what will be inserted.  This is different from what
105                 happens with the "p" command and pasting with the mouse.
106                 Special registers:
107                         '"'     the unnamed register, containing the text of
108                                 the last delete or yank
109                         '%'     the current file name
110                         '#'     the alternate file name
111                         '*'     the clipboard contents
112                         '/'     the last search pattern
113                         ':'     the last command-line
114                         '.'     the last inserted text
115                         '-'     the last small (less than a line) delete
116                         '='     the expression register: you are prompted to
117                                 enter an expression (see |expression|)
118                 See |registers| about registers.  {not in Vi}
120 CTRL-R CTRL-R {0-9a-z"%#/:.-=}          *i_CTRL-R_CTRL-R* *i_<C-R>_<C-R>*
121                 Insert the contents of a register.  Works like using a single
122                 CTRL-R, but the text is inserted literally, not as if typed.
123                 This differs when the register contains characters like <BS>.
124                 Example, where register a contains "ab^Hc":
125 >       CTRL-R a                results in "ac".
126 >       CTRL-R CTRL-R a         results in "ab^Hc".
127                 Options 'textwidth', 'formatoptions', etc. still apply.  If
128                 you also want to avoid these, use "<C-R><C-O>r", see below.
129                 The '.' register (last inserted text) is still inserted as
130                 typed.  {not in Vi}
132 CTRL-R CTRL-O {0-9a-z"%#/:.-=}          *i_CTRL-R_CTRL-O* *i_<C-R>_<C-O>*
133                 Insert the contents of a register literally and don't
134                 auto-indent.  Does the same as pasting with the mouse
135                 |<MiddleMouse>|.
136                 Does not replace characters!
137                 The '.' register (last inserted text) is still inserted as
138                 typed.  {not in Vi}
140 CTRL-R CTRL-P {0-9a-z"%#/:.-=}          *i_CTRL-R_CTRL-P* *i_<C-R>_<C-P>*
141                 Insert the contents of a register literally and fix the
142                 indent, like |[<MiddleMouse>|.
143                 Does not replace characters!
144                 The '.' register (last inserted text) is still inserted as
145                 typed.  {not in Vi}
147                                                 *i_CTRL-T*
148 CTRL-T          Insert one shiftwidth of indent at the start of the current
149                 line.  The indent is always rounded to a 'shiftwidth' (this is
150                 vi compatible).  {Vi: only when in indent}
151                                                 *i_CTRL-D*
152 CTRL-D          Delete one shiftwidth of indent at the start of the current
153                 line.  The indent is always rounded to a 'shiftwidth' (this is
154                 vi compatible).  {Vi: CTRL-D works only when used after
155                 autoindent}
156                                                 *i_0_CTRL-D*
157 0 CTRL-D        Delete all indent in the current line.  {Vi: CTRL-D works
158                 only when used after autoindent}
159                                                 *i_^_CTRL-D*
160 ^ CTRL-D        Delete all indent in the current line.  The indent is
161                 restored in the next line.  This is useful when inserting a
162                 label.  {Vi: CTRL-D works only when used after autoindent}
164                                                 *i_CTRL-V*
165 CTRL-V          Insert next non-digit literally.  For special keys, the
166                 terminal code is inserted.  Up to three digits form the
167                 decimal value of a single byte (see below |i_CTRL-V_digit|.
168                 The non-digit and the three digits are not considered for
169                 mapping.  {Vi: no decimal byte entry}
170                 Note: Under Windows CTRL-V is often mapped to paste text.
171                 Then use CTRL-Q instead.
173                                                 *i_CTRL-Q*
174 CTRL-Q          Same as CTRL-V.
175                 Note: Some terminal connections may eat CTRL-Q.
177 CTRL-X          Enter CTRL-X mode.  This is a sub-mode where commands can
178                 be given to complete words or scroll the window. See
179                 |i_CTRL-X| and |ins-completion|. {not in Vi}
181                                                 *i_CTRL-E*
182 CTRL-E          Insert the character which is below the cursor.  {not in Vi}
183                                                 *i_CTRL-Y*
184 CTRL-Y          Insert the character which is above the cursor.  {not in Vi}
185                 Note that for CTRL-E and CTRL-Y 'textwidth' is not used, to be
186                 able to copy characters from a long line.
188                                                 *i_CTRL-_*
189 CTRL-_          Switch between languages, as follows:
190                 -  When in a rightleft window, revins and nohkmap are toggled,
191                    since English will likely be inserted in this case.
192                 -  When in a norightleft window, revins and hkmap are toggled,
193                    since Hebrew will likely be inserted in this case.
195                 CTRL-_ moves the cursor to the end of the typed text.
197                 This command is only available when the 'allowrevins' option
198                 is set.
199                 Please refer to |rightleft.txt| for more information about
200                 right-to-left mode.
201                 {not in Vi}
202                 Only if compiled with the |+rightleft| feature (which is not
203                 the default).
205                                                 *i_CTRL-]*
206 CTRL-]          Trigger abbreviation, without inserting a character.  {not in
207                 Vi}
209                                                 *i_<Insert>*
210 <Insert>        Toggle between insert and replace mode.  {not in Vi}
211 -----------------------------------------------------------------------
213                                                 *i_backspacing*
214 The effect of the <BS>, CTRL-W, and CTRL-U depend on the 'backspace' option
215 (unless 'revins' is set).  This is a comma separated list of items:
217 item        action ~
218 indent      allow backspacing over autoindent
219 eol         allow backspacing over end-of-line (join lines)
220 start       allow backspacing over the start position of insert; CTRL-W and
221             CTRL-U stop once at the start position
223 When 'backspace' is empty, Vi compatible backspacing is used.  You cannot
224 backspace over autoindent, before column 1 or before where insert started.
226 For backwards compatibility the values "0", "1" and "2" are also allowed, see
227 |'backspace'|.
229 If the 'backspace' option does contain "eol" and the cursor is in column 1
230 when one of the three keys is used, the current line is joined with the
231 previous line.  This effectively deletes the <EOL> in front of the cursor.
232 {Vi: does not cross lines, does not delete past start position of insert}
234                                                 *i_CTRL-V_digit*
235 With CTRL-V followed by one, two, or three digits, you can enter the decimal
236 value of any byte, except 10.  Normally CTRL-V is followed by three digits.
237 The formed byte is inserted as soon as you type the third digit.  If you type
238 only one or two digits and then a non-digit, the decimal value of those one
239 or two digits form the byte.  After that the non-digit is dealt with in the
240 normal way.  If you enter a value of 10, it will end up in the file as a 0.
241 The 10 is a <NL>, which is used internally to represent the <Nul> character.
242 When writing the buffer to a file, the <NL> character is translated into
243 <Nul>.  The <NL> character is written at the end of each line.  Thus if you
244 want to insert a <NL> character in a file you will have to make a line
245 break.  The maximum value that can be entered is 255.
247                                                 *i_CTRL-X* *insert_expand*
248 CTRL-X enters a sub-mode where several commands can be used.  Most of these
249 commands do keyword completion; see |ins-completion|.  These are not available
250 when Vim was compiled without the |+insert_expand| feature.
252 Two commands can be used to scroll the window up or down, without exiting
253 insert mode:
255                                                 *i_CTRL-X_CTRL-E*
256 CTRL-X CTRL-E           scroll window one line up.
258                                                 *i_CTRL-X_CTRL-Y*
259 CTRL-X CTRL-Y           scroll window one line down.
261 After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
262 one line unless that would cause the cursor to move from its current position
263 in the file.  As soon as another key is pressed, CTRL-X mode is exited and
264 that key is interpreted as in Insert mode.
267 ==============================================================================
268 2. Special special keys                         *ins-special-special*
270 The following keys are special.  They stop the current insert, do something,
271 and then restart insertion.  This means you can do something without getting
272 out of Insert mode.  This is very handy if you prefer to use the Insert mode
273 all the time, just like editors that don't have a separate Normal mode.  You
274 may also want to set the 'backspace' option to "indent,eol,start" and set the
275 'insertmode' option.  You can use CTRL-O if you want to map a function key to
276 a command.
278 The changes (inserted or deleted characters) before and after these keys can
279 be undone separately.  Only the last change can be redone and always behaves
280 like an "i" command.
282 char            action  ~
283 -----------------------------------------------------------------------
284 <Up>            cursor one line up                           *i_<Up>*
285 <Down>          cursor one line down                         *i_<Down>*
286 <Left>          cursor one character left                    *i_<Left>*
287 <Right>         cursor one character right                   *i_<Right>*
288 <S-Left>        cursor one word back (like "b" command)      *i_<S-Left>*
289 <C-Left>        cursor one word back (like "b" command)      *i_<C-Left>*
290 <S-Right>       cursor one word forward (like "w" command)   *i_<S-Right>*
291 <C-Right>       cursor one word forward (like "w" command)   *i_<C-Right>*
292 <Home>          cursor to first char in the line             *i_<Home>*
293 <End>           cursor to after last char in the line        *i_<End>*
294 <C-Home>        cursor to first char in the file             *i_<C-Home>*
295 <C-End>         cursor to after last char in the file        *i_<C-End>*
296 <LeftMouse>     cursor to position of mouse click            *i_<LeftMouse>*
297 <S-Up>          move window one page up                      *i_<S-Up>*
298 <PageUp>        move window one page up                      *i_<PageUp>*
299 <S-Down>        move window one page down                    *i_<S-Down>*
300 <PageDown>      move window one page down                    *i_<PageDown>*
301 <MouseDown>     scroll three lines down                      *i_<MouseDown>*
302 <S-MouseDown>   scroll a full page down                      *i_<S-MouseDown>*
303 <MouseUp>       scroll three lines up                        *i_<MouseUp>*
304 <S-MouseUp>     scroll a full page up                        *i_<S-MouseUp>*
305 CTRL-O          execute one command, return to Insert mode   *i_CTRL-O*
306 -----------------------------------------------------------------------
308 Note: If the cursor keys take you out of Insert mode, check the 'noesckeys'
309 option.
311 The CTRL-O command sometimes has one side effect: If the cursor was beyond the
312 end of the line, it will be put on the last character in the line.
313 The shifted cursor keys are not available on all terminals.
315 When the 'whichwrap' option is set appropriately, the <Left> and <Right>
316 keys on the first/last character in the line make the cursor wrap to the
317 previous/next line.
319 ==============================================================================
320 3. 'textwidth' and 'wrapmargin' options                 *ins-textwidth*
322 The 'textwidth' option can be used to automatically break a line before it
323 gets too long.  Set the 'textwidth' option to the desired maximum line
324 length.  If you then type more characters (not spaces or tabs), the
325 last word will be put on a new line (unless it is the only word on the
326 line).  If you set 'textwidth' to 0, this feature is disabled.
328 The 'wrapmargin' option does almost the same.  The difference is that
329 'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
330 screen.  When using 'wrapmargin' this is equal to using 'textwidth' with a
331 value equal to (columns - 'wrapmargin'), where columns is the width of the
332 screen.
334 When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
336 If you don't really want to break the line, but view the line wrapped at a
337 convenient place, see the 'linebreak' option.
339 The line is only broken automatically when using insert mode, or when
340 appending to a line.  When in replace mode and the line length is not
341 changed, the line will not be broken.
343 Long lines are broken if you enter a non-white character after the margin.
344 The situations where a line will be broken can be restricted by adding
345 characters to the 'formatoptions' option:
346 "l"  Only break a line if it was not longer than 'textwidth' when the insert
347      started.
348 "v"  Only break at a white character that has been entered during the
349      current insert command.  This is mostly Vi-compatible.
350 "lv" Only break if the line was not longer than 'textwidth' when the insert
351      started and only at a white character that has been entered during the
352      current insert command.  Only differs from "l" when entering non-white
353      characters while crossing the 'textwidth' boundary.
355 If you want to format a block of text, you can use the "gq" operator.  Type
356 "gq" and a movement command to move the cursor to the end of the block.  In
357 many cases, the command "gq}" will do what you want (format until the end of
358 paragraph).  Alternatively, you can use "gqap", which will format the whole
359 paragraph, no matter where the cursor currently is.  Or you can use Visual
360 mode: hit "v", move to the end of the block, and type "gq".  See also |gq|.
362 ==============================================================================
363 4. 'expandtab', 'smarttab' and 'softtabstop' options    *ins-expandtab*
365 If the 'expandtab' option is on, spaces will be used to fill the amount of
366 whitespace of the tab.  If you want to enter a real <Tab>, type CTRL-V first.
367 The 'expandtab' option is off by default.  Note that in Replace mode, a single
368 character is replaced with several spaces.  The result of this is that the
369 number of characters in the line increases.  Backspacing will delete one
370 space at a time.  The original character will be put back for only one space
371 that you backspace over (the last one).  {Vi does not have the 'expandtab'
372 option}
374                                                         *ins-smarttab*
375 When the 'smarttab' option is on, a <Tab> inserts 'shiftwidth' positions at
376 the beginning of a line and 'tabstop' positions in other places.  This means
377 that often spaces instead of a <Tab> character are inserted.  When 'smarttab
378 is off, a <Tab> always inserts 'tabstop' positions, and 'shiftwidth' is only
379 used for ">>" and the like.  {not in Vi}
381                                                         *ins-softtabstop*
382 When the 'softtabstop' option is non-zero, a <Tab> inserts 'softtabstop'
383 positions, and a <BS> used to delete white space, will delete 'softtabstop'
384 positions.  This feels like 'tabstop' was set to 'softtabstop', but a real
385 <Tab> character still takes 'tabstop' positions, so your file will still look
386 correct when used by other applications.
388 If 'softtabstop' is non-zero, a <BS> will try to delete as much white space to
389 move to the previous 'softtabstop' position, except when the previously
390 inserted character is a space, then it will only delete the character before
391 the cursor.  Otherwise you cannot always delete a single character before the
392 cursor.  You will have to delete 'softtabstop' characters first, and then type
393 extra spaces to get where you want to be.
396 ==============================================================================
397 5. Replace mode                         *Replace* *Replace-mode* *mode-replace*
399 Enter Replace mode with the "R" command in normal mode.
401 In Replace mode, one character in the line is deleted for every character you
402 type.  If there is no character to delete (at the end of the line), the
403 typed character is appended (as in Insert mode).  Thus the number of
404 characters in a line stays the same until you get to the end of the line.
405 If a <NL> is typed, a line break is inserted and no character is deleted.
407 Be careful with <Tab> characters.  If you type a normal printing character in
408 its place, the number of characters is still the same, but the number of
409 columns will become smaller.
411 If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), what
412 happens is that you delete the changes.  The characters that were replaced
413 are restored.  If you had typed past the existing text, the characters you
414 added are deleted.  This is effectively a character-at-a-time undo.
416 If the 'expandtab' option is on, a <Tab> will replace one character with
417 several spaces.  The result of this is that the number of characters in the
418 line increases.  Backspacing will delete one space at a time.  The original
419 character will be put back for only one space that you backspace over (the
420 last one).  {Vi does not have the 'expandtab' option}
422 ==============================================================================
423 6. Virtual replace mode         *vreplace-mode* *Virtual-replace-mode*
425 Enter Virtual replace mode with the "gR" command in normal mode.
427 Virtual replace mode is similar to Replace mode, but instead of replacing
428 actual characters in the file, you are replacing screen real estate, so that
429 characters further on in the file never appear to move.
431 So if you type a <Tab> it may replace several normal characters, and if you
432 type a letter on top of a <Tab> it may not replace anything at all, since the
433 <Tab> will still line up to the same place as before.
435 Typing a <NL> still doesn't cause characters later in the file to appear to
436 move.  The rest of the current line will be replaced by the <NL> (that is,
437 they are deleted), and replacing continues on the next line.  A new line is
438 NOT inserted unless you go past the end of the file.
440 Interesting effects are seen when using CTRL-T and CTRL-D.  The characters
441 before the cursor are shifted sideways as normal, but characters later in the
442 line still remain still.  CTRL-T will hide some of the old line under the
443 shifted characters, but CTRL-D will reveal them again.
445 As with Replace mode, using <BS> etc will bring back the characters that were
446 replaced.  This still works in conjunction with 'smartindent', CTRL-T and
447 CTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.
449 In 'list' mode, Virtual replace mode acts as if it was not in 'list' mode,
450 unless "L" is in 'cpoptions'.
452 Note that the only times characters beyond the cursor should appear to move
453 are in 'list' mode, and occasionally when 'wrap' is set (and the line changes
454 length to become shorter or wider than the width of the screen), or
455 momentarily when typing over a CTRL character.  A CTRL character takes up two
456 screen spaces.  When replacing it with two normal characters, the first will
457 be inserted and the second will replace the CTRL character.
459 This mode is very useful for editing <Tab> separated columns in tables, for
460 entering new data while keeping all the columns aligned.
461 {Vi does not have Virtual replace mode}
463 ==============================================================================
464 7. Insert mode completion                               *ins-completion*
466 In Insert and Replace modes, there are several commands to complete part of a
467 keyword or line that has been typed.  This is useful if you are using
468 complicated keywords (e.g., function names with capitals and underscores).
470 These commands are not available when the |+insert_expand| feature was
471 disabled at compile time.
473 Completion can be done for:
475 1. Whole lines                                          |i_CTRL-X_CTRL-L|
476 2. keywords in the current file                         |i_CTRL-X_CTRL-N|
477 3. keywords in 'dictionary'                             |i_CTRL-X_CTRL-K|
478 4. keywords in the current and included files           |i_CTRL-X_CTRL-I|
479 5. tags                                                 |i_CTRL-X_CTRL-]|
480 6. file names                                           |i_CTRL-X_CTRL-F|
481 7. definitions or macros                                |i_CTRL-X_CTRL-D|
482 8. keywords in 'complete'                               |i_CTRL-N|
484 All these (except 2) are done in CTRL-X mode.  This is a sub-mode of Insert
485 and Replace modes.  You enter CTRL-X mode by typing CTRL-X and one of the
486 CTRL-X commands.  You exit CTRL-X mode by typing a key that is not a valid
487 CTRL-X mode command.  Valid keys are the CTRL-X command itself, CTRL-N (next),
488 and CTRL-P (previous).
490 Also see the 'infercase' option if you want to adjust the case of the match.
492 Note: The keys that are valid in CTRL-X mode are not mapped.  This allows for
493 ":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X).  The key that
494 ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.
496 The following mappings are suggested to make typing the completion commands
497 a bit easier (although they will hide other commands):
498     :inoremap ^] ^X^]
499     :inoremap ^F ^X^F
500     :inoremap ^D ^X^D
501     :inoremap ^L ^X^L
504 Completing whole lines                                  *compl-whole-line*
506                                                         *i_CTRL-X_CTRL-L*
507 CTRL-X CTRL-L           Search backwards for a line that starts with the
508                         same characters as in the current line before the
509                         cursor.  Indent is ignored.  The found line is
510                         inserted in front of the cursor.
511         CTRL-L  or
512         CTRL-P          Search backwards for next matching line.  This line
513                         replaces the previous matching line.
515         CTRL-N          Search forward for next matching line.  This line
516                         replaces the previous matching line.
518         CTRL-X CTRL-L   After expanding a line you can additionally get the
519                         line next to it by typing CTRL-X CTRL-L again, unless
520                         a double CTRL-X is used.
522 Completing keywords in current file                     *compl-current*
524                                                         *i_CTRL-X_CTRL-P*
525                                                         *i_CTRL-X_CTRL-N*
526 CTRL-X CTRL-N           Search forwards for words that start with the keyword
527                         in front of the cursor.  The found keyword is inserted
528                         in front of the cursor.
530 CTRL-X CTRL-P           Search backwards for words that start with the keyword
531                         in front of the cursor.  The found keyword is inserted
532                         in front of the cursor.
534         CTRL-N          Search forward for next matching keyword.  This
535                         keyword replaces the previous matching keyword.
537         CTRL-P          Search backwards for next matching keyword.  This
538                         keyword replaces the previous matching keyword.
540         CTRL-X CTRL-N or
541         CTRL-X CTRL-P   Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
542                         copy the words following the previous expansion in
543                         other contexts unless a double CTRL-X is used.
545 If there is a keyword in front of the cursor (a name made out of alphabetic
546 characters and characters in 'iskeyword'), it is used as the search pattern,
547 with "\<" prepended (meaning: start of a word).  Otherwise "\<\k\k" is used
548 as search pattern (start of any keyword of at least two characters).
550 In Replace mode, the number of characters that are replaced depends on the
551 length of the matched string.  This works like typing the characters of the
552 matched string in Replace mode.
554 If there is not a valid keyword character before the cursor, any keyword of
555 at least two characters is matched.
556         e.g., to get:
557             printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
558         just type:
559             printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
561 Multiple repeats of the same completion are skipped; thus a different match
562 will be inserted at each CTRL-N and CTRL-P (unless there is only one
563 matching keyword).
565 Single character matches are never included, as they usually just get in
566 the way of what you were really after.
567         e.g., to get:
568                 printf("name = %s\n", name);
569         just type:
570                 printf("name = %s\n", n^P);
571         or even:
572                 printf("name = %s\n", ^P);
573 The 'n' in '\n' is skipped.
575 After expanding a word, you can use CTRL-X CTRL-P or CTRL-X CTRL-N to get the
576 word following the expansion in other contexts.  These sequences search for
577 the text just expanded and further expand by getting an extra word.  This is
578 useful if you need to repeat a sequence of complicated words.  Although CTRL-P
579 and CTRL-N look just for strings of at least two characters, CTRL-X CTRL-P and
580 CTRL-X CTRL-N can be used to expand words of just one character.
581         e.g., to get:
582                 M&eacute;xico
583         you can type:
584                 M^N^P^X^P^X^P
585 CTRL-N starts the expansion and then CTRL-P takes back the single character
586 "M", the next two CTRL-X CTRL-P's get the words "&eacute" and ";xico".
588 If the previous expansion was split, because it got longer than 'textwidth',
589 then just the text in the current line will be used.
591 If the match found is at the end of a line, then the first word in the next
592 line will be inserted and the message "word from next line" displayed, if
593 this word is accepted the next CTRL-X CTRL-P or CTRL-X CTRL-N will search
594 for those lines starting with this word.
597 Completing keywords in 'dictionary'                     *compl-dictionary*
599                                                         *i_CTRL-X_CTRL-K*
600 CTRL-X CTRL-K           Search the files given with the 'dictionary' option
601                         for words that start with the keyword in front of the
602                         cursor.  This is like CTRL-N, but only the dictionary
603                         files are searched, not the current file.  The found
604                         keyword is inserted in front of the cursor.  This
605                         could potentially be pretty slow, since all matches
606                         are found before the first match is used.  By default,
607                         the 'dictionary' option is empty.
608                         For suggestions where to find a list of words, see the
609                         'dictionary' option.
611         CTRL-K  or
612         CTRL-N          Search forward for next matching keyword.  This
613                         keyword replaces the previous matching keyword.
615         CTRL-P          Search backwards for next matching keyword.  This
616                         keyword replaces the previous matching keyword.
619 Completing keywords in the current and included files   *compl-keyword*
621 The 'include' option is used to specify a line that contains an include file
622 name.  The 'path' option is used to search for include files.
624                                                         *i_CTRL-X_CTRL-I*
625 CTRL-X CTRL-I           Search for the first keyword in the current and
626                         included files that starts with the same characters
627                         as those before the cursor.  The matched keyword is
628                         inserted in front of the cursor.
630         CTRL-N          Search forwards for next matching keyword.  This
631                         keyword replaces the previous matching keyword.
632                         Note: CTRL-I is the same as <Tab>, which is likely to
633                         be typed after a successful completion, therefore
634                         CTRL-I is not used for searching for the next match.
636         CTRL-P          Search backward for previous matching keyword.  This
637                         keyword replaces the previous matching keyword.
639         CTRL-X CTRL-I   Further use of CTRL-X CTRL-I will copy the words
640                         following the previous expansion in other contexts
641                         unless a double CTRL-X is used.
643 Completing tags                                         *compl-tag*
644                                                         *i_CTRL-X_CTRL-]*
645 CTRL-X CTRL-]           Search for the first tag that starts with the same
646                         characters as before the cursor.  The matching tag is
647                         inserted in front of the cursor.  Alphabetic
648                         characters and characters in 'iskeyword' are used
649                         to decide which characters are included in the tag
650                         name (same as for a keyword).  See also |CTRL-]|.
651                         The 'showfulltag' option can be used to add context
652                         from around the tag definition.
653         CTRL-]  or
654         CTRL-N          Search forwards for next matching tag.  This tag
655                         replaces the previous matching tag.
657         CTRL-P          Search backward for previous matching tag.  This tag
658                         replaces the previous matching tag.
661 Completing file names                                   *compl-filename*
662                                                         *i_CTRL-X_CTRL-F*
663 CTRL-X CTRL-F           Search for the first file name that starts with the
664                         same characters as before the cursor.  The matching
665                         file name is inserted in front of the cursor.
666                         Alphabetic characters and characters in 'isfname'
667                         are used to decide which characters are included in
668                         the file name.  Note: the 'path' option is not used
669                         here (yet).
670         CTRL-F  or
671         CTRL-N          Search forwards for next matching file name.  This
672                         file name replaces the previous matching file name.
674         CTRL-P          Search backward for previous matching file name.
675                         This file name replaces the previous matching file
676                         name.
679 Completing definitions or macros                        *compl-define*
681 The 'define' option is used to specify a line that contains a definition.
682 The 'include' option is used to specify a line that contains an include file
683 name.  The 'path' option is used to search for include files.
685                                                         *i_CTRL-X_CTRL-D*
686 CTRL-X CTRL-D           Search in the current and included files for the
687                         first definition (or macro) name that starts with
688                         the same characters as before the cursor.  The found
689                         definition name is inserted in front of the cursor.
690         CTRL-D  or
691         CTRL-N          Search forwards for next matching macro name.  This
692                         macro name replaces the previous matching macro
693                         name.
695         CTRL-P          Search backward for previous matching macro name.
696                         This macro name replaces the previous matching macro
697                         name.
699         CTRL-X CTRL-D   Further use of CTRL-X CTRL-D will copy the words
700                         following the previous expansion in other contexts
701                         unless a double CTRL-X is used.
704 Completing keywords from different sources              *compl-generic*
706                                                         *i_CTRL-N*
707 CTRL-N                  Search backwards in the places given with the
708                         'complete' option for words that start with the
709                         keyword in front of the cursor.  The found keyword is
710                         inserted in front of the cursor.
712                                                         *i_CTRL-P*
713 CTRL-P                  Search forwards in the places given with the
714                         'complete' option for words that start with the
715                         keyword in front of the cursor.  The found keyword is
716                         inserted in front of the cursor.
718         CTRL-N          Search forward for next matching keyword.  This
719                         keyword replaces the previous matching keyword.
721         CTRL-P          Search backwards for next matching keyword.  This
722                         keyword replaces the previous matching keyword.
724         CTRL-X CTRL-N or
725         CTRL-X CTRL-P   Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
726                         copy the words following the previous expansion in
727                         other contexts unless a double CTRL-X is used.
729 ==============================================================================
730 8. Insert mode commands                                 *inserting*
732 The following commands can be used to insert new text into the buffer.  They
733 can all be undone and repeated with the "." command.
735                                                         *a*
736 a                       Append text after the cursor [count] times.
738                                                         *A*
739 A                       Append text at the end of the line [count] times.
741 <insert>        or                              *i* *insert* *<Insert>*
742 i                       Insert text before the cursor [count] times.
744                                                         *I*
745 I                       Insert text before the first non-blank in the line
746                         [count] times.
748                                                         *gI*
749 gI                      Insert text in column 1 [count] times.  {not in Vi}
751                                                         *o*
752 o                       Begin a new line below the cursor and insert text,
753                         repeat [count] times.  {Vi: blank [count] screen
754                         lines}
756                                                         *O*
757 O                       Begin a new line above the cursor and insert text,
758                         repeat [count] times.  {Vi: blank [count] screen
759                         lines}
761 These commands are used to start inserting text.  You can end insert mode with
762 <Esc>.  See |mode-ins-repl| for the other special characters in Insert mode.
763 The effect of [count] takes place after insert mode is exited.
765 When 'autoindent' is on, the indent for a new line is obtained from the
766 previous line.  When 'smartindent' or 'cindent' is on, the indent for a line
767 is automatically adjusted for C programs.
769 'textwidth' can be set to the maximum width for a line.  When a line becomes
770 too long when appending characters a line break is automatically inserted.
773 ==============================================================================
774 9. Ex insert commands                                   *inserting-ex*
776                                                         *:a* *:append*
777 :{range}a[ppend]        Insert several lines of text below the specified
778                         line.  If the {range} is missing, the text will be
779                         inserted after the current line.
781                                                         *:i* *:in* *:insert*
782 :{range}i[nsert]        Insert several lines of text above the specified
783                         line.  If the {range} is missing, the text will be
784                         inserted before the current line.
786 These two commands will keep on asking for lines, until you type a line
787 containing only a ".".  Watch out for lines starting with a backslash, see
788 |line-continuation|.
790                                                         *:start* *:startinsert*
791 :star[tinsert][!]       Start Insert mode just after executing this command.
792                         Works like typing "i" in Normal mode.  When the ! is
793                         included it works like "A", append to the line.
794                         Otherwise insertion starts at the cursor position.
795                         Note that when using this command in a function or
796                         script, the insertion only starts after the function
797                         or script is finished.
798                         {not in Vi}
800 ==============================================================================
801 10. Inserting a file                                    *inserting-file*
803                                                         *:r* *:re* *:read*
804 :r[ead] [name]          Insert the file [name] (default: current file) below
805                         the cursor.
807 :{range}r[ead] [name]   Insert the file [name] (default: current file) below
808                         the specified line.
810                                                         *:r!* *:read!*
811 :r[ead] !{cmd}          Execute {cmd} and insert its standard output below
812                         the cursor.  A temporary file is used to store the
813                         output of the command which is then read into the
814                         buffer.  'shellredir' is used to save the output of
815                         the command, which can be set to include stderr or
816                         not.  {cmd} is executed like with ":!{cmd}", any '!'
817                         is replaced with the previous command |:!|.
819 These commands insert the contents of a file, or the output of a command,
820 into the buffer.  They can be undone.  They cannot be repeated with the "."
821 command.  They work on a line basis, insertion starts below the line in which
822 the cursor is, or below the specified line.  To insert text above the first
823 line use the command ":0r {name}".
825 After the ":read" command, the cursor is left on the first non-blank in the
826 first new line.  Unless in Ex mode, then the cursor is left on the last new
827 line (sorry, this is Vi compatible).
829 If a file name is given with ":r", it becomes the alternate file.  This can be
830 used, for example, when you want to edit that file instead: ":e! #".  This can
831 be switched off by removing the 'a' flag from the 'cpoptions' option.
833                                                         *file-read*
834 The 'fileformat' option sets the <EOL> style for a file:
835 'fileformat'    characters         name                         ~
836   "dos"         <CR><NL> or <NL>   DOS format
837   "unix"        <NL>               Unix format
838   "mac"         <CR>               Mac format
839 Previously 'textmode' was used.  It is obsolete now.
841 If 'fileformat' is "dos", a <CR> in front of an <NL> is ignored and a CTRL-Z
842 at the end of the file is ignored.
844 If 'fileformat' is "mac", a <NL> in the file is internally represented by a
845 <CR>.  This is to avoid confusion with a <NL> which is used to represent a
846 <NUL>.  See |CR-used-for-NL|.
848 If the 'fileformats' option is not empty Vim tries to recognize the type of
849 <EOL> (see |file-formats|).  However, the 'fileformat' option will not be
850 changed, the detected format is only used while reading the file.
852 On non-MS-DOS, Win32, and OS/2 systems the message "[dos format]" is shown if
853 a file is read in DOS format, to remind you that something unusual is done.
854 On Macintosh, MS-DOS, Win32, and OS/2 the message "[unix format]" is shown if
855 a file is read in Unix format.
856 On non-Macintosh systems, the message "[Mac format]" is shown if a file is
857 read in Mac format.
859 An example on how to use ":r !":
860 >  :r !uuencode binfile binfile
861 This command reads "binfile", uuencodes it and reads it into the current
862 buffer.  Useful when you are editing e-mail and want to include a binary
863 file.
865  vim:tw=78:ts=8:sw=8: