Linux Applications
◾
163
in, use dd. The commands
dd
,
dw,
and
db
cut the items into a buffer. The command
yy
copies the current line into a buffer. To retrieve the contents of the buffer, use
p
or
P
(put
or paste) where
p
pastes in a line immediately above the line of the cursor’s position and
P
pastes in a line immediately after the line of the cursor’s position.
The combination of
dd
/
dw
/
db
and
p
/
P
perform cut and paste while
yy
and
p
/
P
perform copy and paste. Another
interesting command is
xp
, which transposes the current and next character. In fact, it is
a combination of the
x
command to delete the current character and
p
to insert the item
in the buffer immediately after the current character. So,
for instance, if you have abc and
the cursor is under b, typing
xp
deletes b and pastes it after c. The command
J
joins the
current line and the next line, thus removing the line break (\n)
from the end of the cur-
rent line.
There are several different search options. The search allows you to input either a string
or a single character to search for. In the case of a string, the string can be literal charac-
ters or a regular expression (we cover regular expressions in the next chapter). To search
forward from the cursor on for
string
, use
/string <
enter
>
and
to search backward,
use
?
string
. Once an instance of
string
has been found, you can continue to
the search using /
<
enter
>
or
?
<
enter
>
for additional forward or backward searches,
respectively.
You can search for a single character but only on the current line. The commands are
f
char
,
F
char
,
t
char
,
and
T
char
where
f
and
t
search forward for the character
char
,
positioning the cursor on the character or immediately before the character, respectively,
and
F
and
T
search backward on the line for the character
char
, positioning the cursor on
the character or immediately before the character, respectively. The command
;
is used to
repeat the last
f
,
F
,
t
, or
T
command. You can also search forward or backward in a docu-
ment for a parenthesis. If the cursor is resting on an open or close paren, the % key will
move the cursor to the corresponding close or open paren. For instance, if you have “the
value of x (heretofore unknown) is not a concern” and the cursor is on the ‘)’, pressing %
will move it to the ‘(‘.
All file commands start with a
:
and are followed by one or more characters to denote
the command. To open the file
Do'stlaringiz bilan baham: