About Exiting Vim

If you accidentally opened a file in Vim (*), you can exit it typing the following characters.

Without saving:

:q!

With saving recent changes:

:wq

(*) Vim is usually set as the default $EDITOR and is used when opening git commit messages for writing or crontab tasks for editing.

Development Bash Zsh Vim