USR_24

*usr_24.txt*    For IdeaVIM version 0.12.0.  Last change: 2006 Nov 12

                     IdeaVIM USER MANUAL - by Rick Maddy

                             Inserting quickly


When entering text, Vim offers various ways to reduce the number of keystrokes
and avoid typing mistakes.  Use Insert mode completion to repeat previously
typed words.  Abbreviate long words to short ones.  Type characters that
aren't on your keyboard.

|24.1|  Making corrections
|24.2|  Showing matches
|24.3|  Completion
|24.4|  Repeating an insert
|24.5|  Copying from another line
|24.6|  Inserting a register
|24.7|  Abbreviations
|24.8|  Entering special characters
|24.9|  Digraphs
|24.10| Normal mode commands

     Next chapter: |usr_25.txt|  Editing formatted text
 Previous chapter: |usr_23.txt|  Editing other files
Table of contents: |usr_toc.txt|


*24.1*  Making corrections

The <BS> key was already mentioned.  It deletes the character just before the
cursor.  The <Del> key does the same for the character under (after) the
cursor.
   When you typed a whole word wrong, use CTRL-W:

        The horse had fallen to the sky 
                                       CTRL-W
        The horse had fallen to the 

If you really messed up a line and want to start over, use CTRL-U to delete
it.  This keeps the text after the cursor and the indent.  Only the text from
the first non-blank to the cursor is deleted.  With the cursor on the "f" of
"fallen" in the next line pressing CTRL-U does this:

        The horse had fallen to the 
                      CTRL-U
        fallen to the 

When you spot a mistake a few words back, you need to move the cursor there to
correct it.  For example, you typed this:

        The horse had follen to the ground 

You need to change "follen" to "fallen".  With the cursor at the end, you
would type this to correct it:

                                        <Esc>4blraA

       get out of Insert mode          <Esc>
        four words back                      4b
        move on top of the "o"                 l
        replace with "a"                        ra
        restart Insert mode                       A

Another way to do this:

                <C-Left><C-Left><C-Left><C-Left><Right><Del>a<End>

       four words back              <C-Left><C-Left><C-Left><C-Left>
        move on top of the "o"                  <Right>
        delete the "o"                                 <Del>
        insert an "a"                                       a
        go to end of the line                                <End>

This uses special keys to move around, while remaining in Insert mode.  This
resembles what you would do in a modeless editor.  It's easier to remember,
but takes more time (you have to move your hand from the letters to the cursor
keys, and the <End> key is hard to press without looking at the keyboard).
   These special keys are most useful when writing a mapping that doesn't
leave Insert mode.  The extra typing doesn't matter then.
   An overview of the keys you can use in Insert mode:

        <C-Home>        to start of the file
        <PageUp>        a whole screenful up
        <Home>          to start of line
        <S-Left>        one word left
        <C-Left>        one word left
        <S-Right>       one word right
        <C-Right>       one word right
        <End>           to end of the line
        <PageDown>      a whole screenful down
        <C-End>         to end of the file

There are a few more, see |ins-special-special|.


*24.2*  Showing matches

This information does not apply to IdeaVIM.


*24.3*  Completion

This information does not apply to IdeaVIM. Use IDEA's code completion features.


*24.4*  Repeating an insert

If you press CTRL-A, the editor inserts the text you typed the last time you
were in Insert mode.
   Assume, for example, that you have a file that begins with the following:

        "file.h" 
        /* Main program begins */ 

You edit this file by inserting "#include " at the beginning of the first
line:

        #include "file.h" 
        /* Main program begins */ 

You go down to the beginning of the next line using the commands "j^".  You
now start to insert a new "#include" line.  So you type:

        i CTRL-A

The result is as follows:

        #include "file.h" 
        #include /* Main program begins */ 

The "#include " was inserted because CTRL-A inserts the text of the previous
insert.  Now you type  "main.h"<Enter>  to finish the line:


        #include "file.h" 
        #include "main.h" 
        /* Main program begins */ 

The CTRL-@ command does a CTRL-A and then exits Insert mode.  That's a quick
way of doing exactly the same insertion again.


*24.5*  Copying from another line

The CTRL-Y command inserts the character above the cursor.  This is useful
when you are duplicating a previous line.  For example, you have this line of
C code:

        b_array[i]->s_next = a_array[i]->s_next; 

Now you need to type the same line, but with "s_prev" instead of "s_next".
Start the new line, and press CTRL-Y 14 times, until you are at the "n" of
"next":

        b_array[i]->s_next = a_array[i]->s_next;
        b_array[i]->s_ 

Now you type "prev":

        b_array[i]->s_next = a_array[i]->s_next; 
        b_array[i]->s_prev 

Continue pressing CTRL-Y until the following "next":

        b_array[i]->s_next = a_array[i]->s_next;
        b_array[i]->s_prev = a_array[i]->s_ 

Now type "prev;" to finish it off.

The CTRL-E command acts like CTRL-Y except it inserts the character below the
cursor.


*24.6*  Inserting a register

The command CTRL-R {register} inserts the contents of the register.  This is
useful to avoid having to type a long word.  For example, you need to type
this:

        r = VeryLongFunction(a) + VeryLongFunction(b) + VeryLongFunction(c) 

The function name is defined in a different file.  Edit that file and move the
cursor on top of the function name there, and yank it into register v:

        "vyiw

"v is the register specification, "yiw" is yank-inner-word.  Now edit the file
where the new line is to be inserted, and type the first letters:

        r = 

Now use CTRL-R v to insert the function name:

        r = VeryLongFunction 

You continue to type the characters in between the function name, and use
CTRL-R v two times more.
   You could have done the same with completion.  Using a register is useful
when there are many words that start with the same characters.


*24.7*  Abbreviations

This functionality is not currently support by IdeaVIM.


*24.8*  Entering special characters

You can use the command CTRL-V {digits} to insert a character with the
decimal number {digits}.  For example, the character number 127 is the <Del>
character (but not necessarily the <Del> key!).  To insert <Del> type:

        CTRL-V 127

You can enter characters up to 255 this way.  When you type fewer than two
digits, a non-digit will terminate the command.  To avoid the need of typing a
non-digit, prepend one or two zeros to make three digits.
   All the next commands insert a <Tab> and then a dot:

        CTRL-V 9.
        CTRL-V 09.
        CTRL-V 009.

To enter a character in hexadecimal, use an "x" after the CTRL-V:

        CTRL-V x7f

This also goes up to character 255 (CTRL-V xff).  You can use "o" to type a
character as an octal number and two more methods allow you to type up to
a 16 bit and a 32 bit number (e.g., for a Unicode character):

        CTRL-V o123
        CTRL-V u1234
        CTRL-V U12345678


*24.9*  Digraphs

Some characters are not on the keyboard.  For example, the copyright character
(©).  To type these characters in Vim, you use digraphs, where two characters
represent one.  To enter a ©, for example, you press three keys:

        CTRL-K Co

To find out what digraphs are available, use the following command:

        :digraphs

Vim will display the digraph table.  Here are three lines of it:

  AC ~_ 159  NS |  160  !I ¡  161  Ct ¢  162  Pd £  163  Cu ¤  164  Ye ¥  165 
  BB ¦  166  SE §  167  ': ¨  168  Co ©  169  -a ª  170  << «  171  NO ¬  172 
  -- ­  173  Rg ®  174  'm ¯  175  DG °  176  +- ±  177  2S ²  178  3S ³  179 

This shows, for example, that the digraph you get by typing CTRL-K Pd is the
character (£).  This is character number 163 (decimal).
   Pd is short for Pound.  Most digraphs are selected to give you a hint about
the character they will produce.  If you look through the list you will
understand the logic.
   You can exchange the first and second character, if there is no digraph for
that combination.  Thus CTRL-K dP also works.  Since there is no digraph for
"dP" Vim will also search for a "Pd" digraph.

        Note:
        The digraphs depend on the character set that Vim assumes you are
        using.  On MS-DOS they are different from MS-Windows.  Always use
        ":digraphs" to find out which digraphs are currently available.

More information about digraphs here: |digraphs|


*24.10* Normal mode commands

Insert mode offers a limited number of commands.  In Normal mode you have many
more.  When you want to use one, you usually leave Insert mode with <Esc>,
execute the Normal mode command, and re-enter Insert mode with "i" or "a".
   There is a quicker way.  With CTRL-O {command} you can execute any Normal
mode command from Insert mode.  For example, to delete from the cursor to the
end of the line:

        CTRL-O D

You can execute only one Normal mode command this way.  But you can specify a
register or a count.  A more complicated example:

        CTRL-O "g3dw

This deletes up to the third word into register g.


Next chapter: |usr_25.txt|  Editing formatted text

Copyright: see |manual-copyright|