Vi Editor Basics With Linux

Linux Vi Editor Basics

Using the Vi Editor that comes with various Linux distributions is one of your options to create, edit and save files. Two other popular editors are Nano and Pico. Nano and Pico usage are almost identical, while Vi usage is different. This tutorial and listings of commands is for the Vi editor. Opening Vi Editor and Insert Mode

 root@vps [~]# vi newfile Here is my new text ~ ~ ~ -- INSERT --

Exit Insert Mode and Enter Command Mode

1) Press 'Enter' and go to a new line 
2) Press 'Esc' on the keyboard

Exit Command mode and go to Insert Mode

 1) Press 'Insert' on the keyboard

Navigating the Vi Editor

 1) Use the arrow keys.

Saving Files and Quitting the Editor In Command Mode

To save a file and quit in command mode, 
1) Type: :wq  

To save a file to another name, 
1) Type: :w newfilename  

To quit the vi editor, 
1) Go to command mode. 
2) Type:  :q or :q!

For more commands and usage, a Vi cheatsheet can be found here.