xxxxxxxxxx
:q Quits Vim but fails when file has been changed
:w Save the file
:w new_name Save the file with the new_name filename
:wq Save the file and quit Vim.
:q! Quit Vim without saving the changes to the file.
ZZ Write file, if modified, and quit Vim
ZQ Same as :q! Quits Vim without writing changes
:sav[eas] file Save file as
:clo[se] Close the current pane
xxxxxxxxxx
// Save a new file (if you have entered vim without first creating a file)
:w <filename>
// Save file and exit
:x
to save: press Esc key, type :w and hit Enter key.
to save and exit: press Esc key, type :x and hit Enter key.
xxxxxxxxxx
to save: press Esc key, type :w and hit Enter key.
to save and exit: press Esc key, type :x and hit Enter key.
to exit and NOT save: press Esc key, type :q! and hit enter
https://www.cyberciti.biz/faq/linux-unix-vim-save-and-quit-command/