Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

How to exit vim

Discussion in 'General Linux' started by Rob, May 23, 2017.

Tags:
  1. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    395
    This question comes up a LOT with users experimenting with different editors.



    To exit vim, hit ESC to get out of insert mode, then type the following, including the colon

    Quit, saving changes:
    Code:
    :wq<ENTER>
    Quit, NOT saving changes:
    Code:
    :q!<ENTER>
     
  2. JasKinasis

    JasKinasis Member

    Joined:
    Apr 25, 2017
    Messages:
    51
    Likes Received:
    56
    Additionally, if you have multiple files open in different buffers/tabs:
    To save all files and quit you can use:
    Code:
    :xa<ENTER>
    
    or
    Code:
    :wqa<ENTER>
    
    The differences between the two options are:
    :xa - will only save buffers/files that have changes in them before quitting. So if a file does not have any changes, it will simply be closed.
    :wqa - will save all buffers before quitting, regardless of whether there were any changes.


    To close all files/buffers/tabs without saving:
    Code:
    :qa!<ENTER>
    
    or
    Code:
    :xa!<ENTER>
    
    Both of these commands are equivalent.
     
    Rob likes this.

Share This Page