Basic Vi and Vim Guide

A very basic guide on how to use the common Linux CLI text editor Vi and Vim.
Firstly you need to open a text document by calling Vim and supplying a filename (which can use the relative or absolute path to the file):
vim filename
Once program has opened the file you will be able to scroll around the document but in order to edit the document you must switch to Insert Mode, simply press the “i“key.
To exit Insert Mode press the Escape key to return to Command Mode.
When you have finished with the document and you are back in Command Mode, to quit type “:q“to exit without saving any changes.
If you wish to save the changes then type “:wq“.
If you want to save the changes to a new filename type “:wq! newfilename
To search the document for keywords you can type either “/” or “?” followed by your keyword. If you press the “n” it will go to the next result in the keyword search.