Basic Linux VI Command
Moving the Cursor
* | j or [or down-arrow] | move cursor down one line |
---|---|---|
* | k [or up-arrow] | move cursor up one line |
* | h or [or left-arrow] | move cursor left one character |
* | l or [or right-arrow] | move cursor right one character |
* | 0 (zero) | move cursor to start of current line (the one with the cursor) |
* | $ | move cursor to end of current line |
w | move cursor to beginning of next word | |
b | move cursor back to beginning of preceding word | |
:0 | move cursor to first line in file | |
:n | move cursor to line n | |
:$ | move cursor to last line in file |
Adding, Changing, and Deleting Text
*u UNDO WHATEVER YOU JUST DID;
* | i | insert text before cursor, until |
---|---|---|
I | insert text at beginning of current line, until | |
* | a | append text after cursor, until |
A | append text to end of current line, until | |
* | o | open and put text in a new line below current line, until |
* | O | open and put text in a new line above current line, until |
* | r | replace single character under cursor (no |
---|---|---|
R | replace characters, starting with current cursor position, until | |
cw | change the current word with new text, starting with the character under cursor, until | |
cNw | change N words beginning with character under cursor, until e.g., c5w changes 5 words | |
C | change (replace) the characters in the current line, until | |
cc | change (replace) the entire current line, stopping when | |
Ncc or cNc | change (replace) the next N lines, starting with the current line, stopping when | |
* | x | delete single character under cursor |
---|---|---|
Nx | delete N characters, starting with character under cursor | |
dw | delete the single word beginning with character under cursor | |
dNw | delete N words beginning with character under cursor; e.g., d5w deletes 5 words | |
D | delete the remainder of the line, starting with current cursor position | |
* | dd | delete entire current line |
Ndd or dNd | delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines | |
yy | copy (yank, cut) the current line into the buffer | |
---|---|---|
Nyy or yNy | copy (yank, cut) the next N lines, including the current line, into the buffer | |
p | put (paste) the line(s) in the buffer into the text after the current line | |
0 comments:
Post a Comment