Installing vi/vim |
sudo apt install vim |
Start vi/vim |
vi file.txt |
You have 'Normal' and 'Insert' mode. If you want to edit 'file.txt' you need to get into 'Insert' mode first. Hit the 'i' key (i for Insert). |
Saving and Quitting |
When you have finished editing press the Esc key, this places you back into 'Normal' mode. Hit the ':' key, vi moves the cursor to the last line of the window. Here you can enter colon commands. Type 'w' and press enter to write your progress. Type 'q' to quit vi. Type 'q!' to quit vi without saving progress. |
Editing Multiple Files |
If ediing more than one document at a time enter the colon commands 'prev' and 'next' to switch between documents. Another colon command you may find useful is 'help'.
|
Cursor Movement |
After you return to 'Normal' mode by pressing the Esc key you can move around using these keys: |
h left
j down
k up
l right |
Delete and Undo |
To delete a character move the cursor over it and hit 'x'. To delete a whole line use the 'dd' command. Use the 'u' command to undo. |
Searching text |
To search for a word use the colon command '/' followed directly by the word you are searching for. |
Stick with It! |
It might seem a little odd to begin with but stick with it and you will soon understand the convenience vi has to offer. |