If you find yourself ssh:ing into a server where VI is the only text editor available, here is a minimal survival guide to get your editing job done:
- Open your file in VI, for example
vi /path/to/your/file - Move the cursor to the position where you want to start editing using the arrow keys
- Trigger insert mode by pressing
i - Do your editing
- Exit insert mode by pressing
Esc - Exisd and save your changes by executing the command
:wq(write and quit) - If you want to exit without saving any changes execute the command
:q!instead
For the advanced newbie:
- Copy (yank) a line by executing the command
yy - Paste the yanked line by positioning the cursor and executing the
porPcommand - Go to end of file:
G - Go to end of line:
$ - Go to beginning of line:
0 - Go to end of word:
e - Go to beginning of word:
b - Go to next word:
w
Comments