Normal Mode Command: Writing and Quitting
Writing and Quitting
Note
When entering commands like :w and :q into vim through normal mode you are technically in Command Line Mode. The only way to access Command Line Mode is through Normal mode which is what allows you to enter commands via the Command Line.
vim commands can be sent while in normal mode. This article will cover the write and quit commands.
Write Command
To write a file type :w:
Note
While in command mode any typing will be displayed at the bottom of the terminal window. The above picture shows :w.
After typing :w simply hit enter to submit the command to vim:
The text at the bottom of the terminal window changed after submitting the write command.
It reads:
"temp-file.txt" [New] 0L, 0C writtenThis is a notification from vim saying the file was successfully written with so many lines and characters, in this case zero as no content has been added yet.
Quit Command
To exit a file enter the :q command:
After executing the command your terminal window will return back to the bash shell:
Written File Validation
Check that the file was written by looking for the file name after executing the ls command:
Combining Commands
Bonus
In vim commands can be combined.
The write and quit commands can be combined by typing and entering :wq.




