home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / insert.txt < prev    next >
Text File  |  1998-08-30  |  34KB  |  772 lines

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