How to Save & Exit in Vim Editor

Found This Helpful

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.

Instructions

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

  2. 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.

  3. 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."

Tips & Warnings

  • If Vim objects to saving the file for any reason (such as if the file is marked as "read-only"), you can override this by adding an exclamation mark after the "q" in the command. This tells Vim to force the command and exit without saving.

References

Comments

You May Also Like

  • How to Edit PDF Files in Linux

    Linux offers very few choices when it comes to editing Portable Document Format files (PDFs) that you download from the Internet. Luckily,...

  • How to Edit Using Unix Vi Editor

    The Unix vi editor command was created to make it more efficient and convenient to edit text in Unix. It allows you...

Featured

Read Article

iPhone Screen Tips You Can Really Use