Vim Command to Exit

:q quit

"How do I quit vim?" is a question that every vim user has asked themselves (followed by: how do I quit vim again?). Something that we are used to being easy - like quiting - can be hard to understand because vim is fundamentally different from other text editors. In other text editors, hitting the "q" key always does the same thing (i.e. it prints the letter "q"). In vim, hitting the "q" key will do different things depending on what mode you are in. In "insert" mode, vim will print the letter "q". But, in "normal mode", "q" is the command to quit vim.

:q! force quit

"Why won't vim let me quit?" is a question that every vim user has asked themselves. Vim won't let you quit when there are changes in the buffer. Force quit tells vim to "delete" any work that hasn't been saved and exit.