How to Save & Exit in Vim Editor

The Vim (Vi Improved) text editor may have originally been written decades ago, but its powerful set of keystrokes and philosophy of "modal editing" still make it a favorite among Linux users and programmers. Nonetheless, it lacks many of the conventional user interface features of more recent editors, such as a main menu, so users are forced to learn keystrokes for all tasks.

Step

Press "Escape." This will take you out of "Insert" mode and into "Command" (or "Normal") mode.

Step

Type ":wq." The colon indicates that what follows is a Vim command, the "w" indicates that the file should be written, or saved, and the "q" indicates that Vim should quit, or exit.

Step

Add the filename at the end of the command if you are saving a new document. So, instead of ":wq", you should type ":wq filename.txt."