character of the line. The "0"
command (zero) moves to the very first character of the line, and the <Home>
key does the same thing. In a picture ("." indicates a space):
^
<-----------x
.....This is a line with example text ~
<----------------x x-------------->
0 $
(the "....." indicates blanks here)
The "$" command takes a count, like most movement commands. But moving to
the end of the line several times doesn't make sense. Therefore it causes the
editor to move to the end of another line. For example, "1$" moves you to
the end of the first line (the one you're on), "2$" to the end of the next
line, and so on.
The "0" command doesn't take a count argument, because the "0" would be
part of the count. Unexpectedly, using a count with "^" doesn't have any
effect.
==============================================================================
*03.3* Moving to a character
One of the most useful movement commands is the single-character search
command. The command "fx" searches forward in the line for the single
character x. Hint: "f" stands for "Find".
For example, you are at the beginning of the following line. Suppose you
want to go to the h of human. Just execute the command "fh" and the cursor
will be positioned over the h:
To err is human. To really foul up you need a computer. ~
---------->--------------->
fh fy
This also shows that the command "fy" moves to the end of the word really.
You can specify a count; therefore, you can go to the "l" of "foul" with
"3fl":
To err is human. To really foul up you need a computer. ~
--------------------->
3fl
The "F" command searches to the left:
To err is human. To really foul up you need a computer. ~
<---------------------
Fh
The "tx" command works like the "fx" command, except it stops one character
before the searched character. Hint: "t" stands for "To". The backward
version of this command is "Tx".
To err is human. To really foul up you need a computer. ~
<------------ ------------->
Th tn
These four commands can be repeated with ";". "," repeats in the other
direction. The cursor is never moved to another line. Not even when the
sentence continues.
Sometimes you will start a search, only to realize that you have typed the
wrong command. You type "f" to search backward, for example, only to realize
that you really meant "F". To abort a search, press <Esc>. So "f<Esc>" is an
aborted forward search and doesn't do anything. Note: <Esc> cancels most
operations, not just searches.
==============================================================================
*03.4* Matching a parenthesis
When writing a program you often end up with nested () constructs. Then the
"%" command is very handy: It moves to the matching paren. If the cursor is
on a "(" it will move to the matching ")". If it's on a ")" it will move to
the matching "(".
%
<----->
if (a == (b * c) / d) ~
<---------------->
%
This also works for [] and {} pairs. (This can be defined with the
'matchpairs' option.)
When the cursor is not on a useful character, "%" will search forward to find
one. Thus if the cursor is at the start of the line of the previous example,
"%" will search forward and find the first "(". Then it moves to its match:
if (a == (b * c) / d) ~
---+---------------->
%
Other ways to move around code can be found in |usr_29.txt|.
==============================================================================
*03.5* Moving to a specific line
If you are a C or C++ programmer, you are familiar with error messages such as
the following:
prog.c:33: j undeclared (first use in this function) ~
This tells you that you might want to fix something on line 33. So how do you
find line 33? One way is to do "9999k" to go to the top of the file and "32j"
to go down thirty-two lines. It is not a good way, but it works. A much
better way of doing things is to