≡ Menu

Vi / Vim: Save And Quit The Editor Command

I am a new vi (vim) text editor user. How do I quit the vi editor and save my changes under Linux or Unix like operating systems?

To save and quit the vi or vim editor with saving any changes you have made:

If you are currently in insert or append mode, press Esc key.

Press : (colon). The cursor should reappear at the lower left corner of the screen beside a colon prompt.

Enter the following command (type :x and press Enter key):

x

OR

x!

OR

wq!

This will quit the editor, and all changes you have made to the document will be saved to the file.

Fig.01: Vi / vim save and quit demo.

Fig.01: Vi / vim save and quit demo.

Share this tutorial on:

{ 3 comments… add one }
  • aref ghobadi August 16, 2015, 12:25 pm

    Hi,
    thanks

    w!= save without exiting
    q!= exit without saving

  • Mohammad June 14, 2016, 1:42 pm

    To save and quit:
    If you are currently in insert or append mode, press Esc key.
    Press: (semi-colon) The cursor should reappear at the lower left corner of the screen beside a colon prompt.
    Enter the following command (type wq! and press Enter key).
    :)

    • Mohammad June 14, 2016, 1:56 pm

      Press: (colon) The cursor should reappear at the lower left corner of the screen beside a colon prompt.
      colon is right.

Leave a Comment


   Tagged with: , , , , , , , ,