vim – Exiting

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


#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 )


#Quit and throw away unsaved changes

:q! or ZQ

#Write or save and quit on all tabs


Leave a Reply

Your email address will not be published. Required fields are marked *