How to Save a File in Vim
Saving in Vim is a Command-mode action: press colon, type a write command, and hit Enter. These commands cover saving, saving-and-quitting, and saving under a new name.
Steps
- Enter Command mode. From Normal mode press : to start a command (press Esc first if you are still typing text).
- Write the file. Type w and press Enter to save the current file.
- Write and quit. Type wq and press Enter to save and exit.
- Save under a new name. Type w newname.txt and press Enter to write a copy to a different file.
In the Vim Browser Editor
In the Vim Browser Editor, :w saves through your browser: it downloads the file, writes back to a file you opened, or stores it in your cloud workspace when you are signed in. :wq behaves the same as :w here because there is nothing to close. Instead of :w filename, the editor prompts you for a filename the first time you save a new buffer.