Normal Mode (7) – Save and Exit

To save changes and exit Vim, you can use the combination of w (write) and q (quit) command. ! is used to forcefully execute the command.
:w : write (save) changes in the current file, but don't exit
:w file_name : write (save) changes in a new file, but don't exit
:q : quit (when there is no unsaved change)
:q! : quit without saving changes
:wq : write (save) changes in the current file and quit
:wq file_name : write (save) changes in a new file and quit
Note: Quit
When you quit with the :q command even though you made some changes, you'll encounter the error like below.
E37: No write since last change (add ! to override)
If you are sure that you want to exit Vim without saving the changes, run the :q! command.
:q!

