vim – Exiting


#Write or save the file, but don’t exit

:w

#Write out the current file using sudo

:w !sudo tee %

#Write or save and quit

:wq (or) : x (or) ZZ

#Quit ( fails if there are unsaved changes )

:q

#Quit and throw away unsaved changes

:q! or ZQ

#Write or save and quit on all tabs

:wqa

Leave a Reply