What is Vi editor
Vi Editor is used to edit files in Linux, this command works in almost every distribution of Linux. Alternate to vi is Vim.
Starting the vi Editor
Command is vi filename
It will look like this # vi myfile.php
Open File in readonly mode
vi -R filename
Exit from Vi / Vim Editor
The command to quit out of vi is :q. Once in the command mode, type colon, and ‘q’, followed by return. If your file has been modified in any way, the editor will warn you of this, and not let you quit. To ignore this message, the command to quit out of vi without saving is :q!. This lets you exit vi without saving any of the changes.
The command to save the contents of the editor is :w. You can combine the above command with the quit command, or use :wq and return.