same thing you do with vim :-o
(without saving changes)
if in insert or append mode press Esc.
else type ":q!" and press Enter
#to modify a file:
vi FILENAME.sh
#press colon ':' + ENTER (the position of the cursor will be to the end of file)
#to exit & SAVE:
wq
#to exit WITHOUT SAVING:
q!
:q to quit (short for :quit)
:q! to quit without saving (short for :quit!)
:wq to write and quit
:wq! to write and quit even if file has only read permission (if file does not have write permission: force write)
:x to write and quit (similar to :wq, but only write if there are changes)
:exit to write and exit (same as :x)
:qa to quit all (short for :quitall)
:cq to quit without saving and make Vim return non-zero error (i.e. exit with error)