VI is a Linux text editor that can edit most of the files under a Linux architecture (text files, php, cfm, cfc, etc).
To open a file in VI editor, type the following:
For a file named test.txt, it would be:
Once the file has been opened, press the "insert" or "i" key on your keyboard to enter edit mode.
The "Esc" key will allow you to leave the edit mode, but not the VI editor.
Here is the list of the most used commands in the VI editor:
- :q!Â - Forces the editor to exit without saving.
- :wÂ - Saves the changes that have been made to the file.
- :wqÂ - Saves the changes that have been made to the file and then exits.
- :#Â - Where # is a number - Brings you to line number #
- :$Â - Brings you to the last line of the file
- :0Â - Brings you to the first line of the file
- :/wordÂ - This will search for the string "word" in the file. By pressing "n" you can view the other search result.