how to save and exit from vi editor code example
Example 1: vi save and exit
//Save
:w
//Exit
:q
Example 2: vi quit and save
# ESC to start command prompt, then
:q! # exit vi without saving
:wq! # exit vi with saving (! means exiting even if file is read only)
Example 3: save and close vim
// Save & exit(quit)
:wq
Example 4: vim save and quit
// Save & exit
:wp