CentOS Linux Server Guide

Vi Editor - Save and Quit

There are 2 way you can save the content after you finished editing a file.

 

Method 1: issuing :w to save current file content

To save the current content under the name of the file that you currently open. However, please make sure that you are in command mode of vi
:w

 

Method 2: issuing :w filename to save current file content as different file name

If you wish to save the file under different file name, you can issue the :w filename
:w newfilename.txt

 

Method 3: issuing :wq  to save current file content and quit the vi application

The following command let you save the current open file content and quit the application after save operation.
:wq

 

If you merely open the file content and do not make any changes to the open file, you can issue the  following command
:q

 

You can  also issue the following command to force quitting without saving.
:q!

 

Read more on Visual Editor (VI)



Copyright 2011 http://www.1a-centosserver.com All Rights Reserved

All trademarks are the property of their respective owners.

Contact Us | Terms of Use | Privacy Policy