Hit the Esc key to enter “Normal mode”. Then you can type
: to enter “Command-line mode”. A colon (
:) will appear at the bottom of the screen and you can type in one of the following commands. To execute a command, press the Enter key.
:qto quit (short for
:q!to quit without saving (short for
:wqto write and quit
:wq!to write and quit even if file has only read permission (if file does not have write permission: force write)
:xto write and quit (similar to
:wq, but only write if there are changes)
:exitto write and exit (same as
:qato quit all (short for
:cqto quit without saving and make Vim return non-zero error (i.e. exit with error)
You can also exit Vim directly from “Normal mode” by typing
ZZ to save and quit (same as
ZQ to just quit (same as
:q!). (Note that case is important here.
zz do not mean the same thing.)
Vim has extensive help – that you can access with the
:help command – where you can find answers to all your questions and a tutorial for beginners.