exit the vi editor code example
Example 1: vim discard changes and quit command
Vim editor:
Insert: hit I key
Discard and exit: esc q!
Save and exit: esc qw
Example 2: vi write and exit
wq // write and quit
Vim editor:
Insert: hit I key
Discard and exit: esc q!
Save and exit: esc qw
wq // write and quit