USR_20

*usr_20.txt*    For IdeaVIM version 0.12.0.  Last change: 2006 Dec 01

                     IdeaVIM USER MANUAL - by Rick Maddy

                     Typing command-line commands quickly


Vim has a few generic features that makes it easier to enter commands.  Colon
commands can be abbreviated, edited and repeated.  Completion is available for
nearly everything.

|20.1|  Command line editing
|20.2|  Command line abbreviations
|20.3|  Command line completion
|20.4|  Command line history
|20.5|  Command line window

     Next chapter: |usr_21.txt|  Go away and come back
 Previous chapter: |usr_12.txt|  Clever tricks
Table of contents: |usr_toc.txt|


*20.1*  Command line editing

When you use a colon (:) command or search for a string with / or ?, Vim puts
the cursor on the bottom of the screen.  There you type the command or search
pattern.  This is called the Command line.  Also when it's used for entering a
search command.

The most obvious way to edit the command you type is by pressing the <BS> key.
This erases the character before the cursor.  To erase another character,
typed earlier, first move the cursor with the cursor keys.
   For example, you have typed this:

        :s/col/pig/

Before you hit <Enter>, you notice that "col" should be "cow".  To correct
this, you type <Left> five times.  The cursor is now just after "col".  Type
<BS> and "w" to correct:

        :s/cow/pig/

Now you can press <Enter> directly.  You don't have to move the cursor to the
end of the line before executing the command.

The most often used keys to move around in the command line:

        <Left>                  one character left
        <Right>                 one character right
        <S-Left> or <C-Left>    one word left
        <S-Right> or <C-Right>  one word right
        CTRL-B or <Home>        to begin of command line
        CTRL-E or <End>         to end of command line

        Note:
        <S-Left> (cursor left key with Shift key pressed) and <C-Left> (cursor
        left key with Control pressed) will not work on all keyboards.  Same
        for the other Shift and Control combinations.

You can also use the mouse to move the cursor.


DELETING

As mentioned, <BS> deletes the character before the cursor.
  To delete a whole
word use CTRL-W.

        /the fine pig 

                     CTRL-W

        /the fine 

CTRL-U removes all text, thus allows you to start all over again.


OVERSTRIKE

The <Insert> key toggles between inserting characters and replacing the
existing ones.  Start with this text:

        /the fine pig 

Move the cursor to the start of "fine" with <S-Left> twice (or <Left> eight
times, if <S-Left> doesn't work).  Now press <Insert> to switch to overstrike
and type "great":

        /the greatpig 

Oops, we lost the space.  Now, don't use <BS>, because it would delete the
"t" (this is different from Replace mode).  Instead, press <Insert> to switch
from overstrike to inserting, and type the space:

        /the great pig 


CANCELLING

You thought of executing a : or / command, but changed your mind.  To get rid
of what you already typed, without executing it, press CTRL-C or <Esc>.

        Note:
        <Esc> is the universal "get out" key.  Unfortunately, in the good old
        Vi pressing <Esc> in a command line executed the command!  Since that
        might be considered to be a bug, Vim uses <Esc> to cancel the command.
        But with the 'cpoptions' option it can be made Vi compatible.  And
        when using a mapping (which might be written for Vi) <Esc> also works
        Vi compatible.  Therefore, using CTRL-C is a method that always works.

If you are at the start of the command line, pressing <BS> will cancel the
command.  It's like deleting the ":" or "/" that the line starts with.


*20.2*  Command line abbreviations

Some of the ":" commands are really long.  We already mentioned that
":substitute" can be abbreviated to ":s".  This is a generic mechanism, all
":" commands can be abbreviated.

How short can a command get?  There are 26 letters, and many more commands.
For example, ":set" also starts with ":s", but ":s" doesn't start a ":set"
command.  Instead ":set" can be abbreviated to ":se".
   When the shorter form of a command could be used for two commands, it
stands for only one of them.  There is no logic behind which one, you have to
learn them.  In the help files the shortest form that works is mentioned.  For
example:

        :s[ubstitute]

This means that the shortest form of ":substitute" is ":s".  The following
characters are optional.  Thus ":su" and ":sub" also work.

In the user manual we will either use the full name of command, or a short
version that is still readable.  For example, ":function" can be abbreviated
to ":fu".  But since most people don't understand what that stands for, we
will use ":fun".  (Vim doesn't have a ":funny" command, otherwise ":fun" would
be confusing too.)

It is recommended that in Vim scripts you write the full command name.  That
makes it easier to read back when you make later changes.  Except for some
often used commands like ":w" (":write") and ":r" (":read").
   A particularly confusing one is ":end", which could stand for ":endif",
":endwhile" or ":endfunction".  Therefore, always use the full name.


SHORT OPTION NAMES

In the user manual the long version of the option names is used.  Many options
also have a short name.  Unlike ":" commands, there is only one short name
that works.  For example, the short name of 'autoindent' is 'ai'.  Thus these
two commands do the same thing:

        :set autoindent
        :set ai

You can find the full list of long and short names here: |option-list|.


*20.3*  Command line completion

This functionality is not currently support by IdeaVIM.


*20.4*  Command line history

In chapter 3 we briefly mentioned the history.  The basics are that you can
use the <Up> key to recall an older command line.  <Down> then takes you back
to newer commands.

There are actually four histories.  The ones we will mention here are for ":"
commands and for "/" and "?" search commands.  The "/" and "?" commands share
the same history, because they are both search commands.  The two other
histories are for expressions and input lines for the input() function.
|cmdline-history|

Suppose you have done a ":set" command, typed ten more colon commands and then
want to repeat that ":set" command again.  You could press ":" and then ten
times <Up>.  There is a quicker way:

        :se<Up>

Vim will now go back to the previous command that started with "se".  You have
a good chance that this is the ":set" command you were looking for.  At least
you should not have to press <Up> very often (unless ":set" commands is all
you have done).

The <Up> key will use the text typed so far and compare it with the lines in
the history.  Only matching lines will be used.
   If you do not find the line you were looking for, use <Down> to go back to
what you typed and correct that.  Or use CTRL-U to start all over again.

To see all the lines in the history:

        :history

That's the history of ":" commands.  The search history is displayed with this
command:

        :history /



*20.5*  Command line window

This functionality is not currently support by IdeaVIM.


Next chapter: |usr_21.txt|  Go away and come back

Copyright: see |manual-copyright|