Appendix A. References 259
p The line before which a copy (c) or a move (m) is to be inserted.
i Inserts a line.
i<n> Inserts 'n' lines.
m Moves one line.
mm Moves a block of lines.
" Replicates a line.
"<n> Replicates a line 'n' times.
"" Replicates a block of lines.
A vi cheat sheet
Here is a small subset of vi commands (the ones most commonly used). The vi editor has
three modes:
1. Input mode: The Insert key, i, o (add a line below), O (add a line above) and other
commands put you in this mode. When you are in this mode, you will see the text
--INSERT-- in the last line.
2. Command mode: Pressing Esc takes you out of input mode and into command mode. The
relevant commands are:
i Brings you back to input mode.
dd Deletes a line and puts it into the buffer.
<n>dd Deletes <n> lines.
x Deletes a character.
dw Deletes a word.
p Adds the buffer past the current location.
P Adds the buffer before the current location.
o Adds a line and goes into insert mode.
/string Searches for a string.
n Performs the last command again.
jkl; Performs a cursor movement.
A Adds text at the end of the line.
<nn>G Goes to line <nn>.
G Goes to the last line in the file.
yy Yanks a line (copies into buffer).
<n>yy Yanks n lines.
3. Command line mode: Pressing the colon key puts you into this mode:
:wq Saves (writes and quits).
:q! Quits and discards changes.
:<nn> Goes to line number <nn>.
:r <file> Leads <file> into the current file.
:1,$s/old/new/g Globally replaces <old> with <new>.
:help Gives help.
Commenti su questo manuale