Vim Basics

Save file and exit in Vim To go to insert mode: i To save: [Esc] and zz To quit: [Esc] and :wq

You need to press [Esc] key followed by the colon (:) before typing the following commands:

q Quit
q! Quit without saving changes i.e. discard changes
r fileName Read data from file called fileName
wq Write and quit (save and exit)
w fileName Write to file called fileName (save as)
w! fileName Overwrite to file called fileName (save as forcefully)

HowTo: Save File in Vi / Vim Text Editor