vi filename | Open file |
vi -r filename | Recover a file from a crashed session |
vi + filename | Place the cursor on last line of the file |
vi +n filename | Place the cursor on nth line "n" the file |
vi +/pattern filename | Place cursor on line with first occurrence of “pattern” |
:w | Write the file to disk |
:w! | Write the file to disk even if read only |
:wq | Write the file to disk and exit |
:wq! | Write the file to disk even if read only and quit |
:q | Quit |
:q! | Force Quit |
A | Move to end of the line and change to insert mode. |
h | (left arrow) |
j | (down arrow) |
k | (up arrow) |
l | (right arrow) |
w | Move cursor to start of the next word |
b | Move cursor to start of the previous word |
:n | Go to nth line |
i | Go into insert mode |
o | Add a line below cursor and go into insert mode |
x | Delete character |
D | Delete line from the right of cursor to the end of the line |
dd | Delete line |
u | Undo last edit |
yy | Yank current line |
p | Put yanked text before the cursor |
/pattern | Search for "pattern" in the file going forwards |
?pattern | Search for "pattern" in the file going backwards |
n | Find the next occurrence of pattern found forwards |
N | Find next occurrence of pattern found backwards |