Run the VIM exit command and run the vim exit command.

Source: Internet
Author: User

Run the VIM exit command and run the vim exit command.

Note: These commands are preceded by a colon:

You can use either of the following methods to exit Vi and return to shell after editing the document.

In command mode, two uppercase letters are used for a connection. If the edited document has been modified, Vi saves the document and exits, and returns to shell; if the edited document has not been modified, Vi exits and returns to shell.

In the last line mode, enter the command

: W

Vi saves the current edited document, but does not exit, but continues waiting for the user to enter the command. When you use the w command, you can create a new document name for editing the document.

[Example 6]

: W newfile

At this time, Vi will save the content of the current document to the specified newfile, while the original document remains unchanged. If newfile is an existing document, the Vi prompts in the status line of the display window:

File exists (use! To override)

If you really want to replace the original content in newfile with the current content of the document, you can use the command

: W! Newfile

Otherwise, you can select another document name to save the current document.

In the last line mode, enter the command

: Q

The system exits Vi and returns to shell. If you exit Vi with this command and the editing document is not saved, the last line of the Vi display window will display the following information:

No write since last change (use! To overrides)

The user is prompted that the document is not saved after modification, and then Vi does not exit, continue waiting for the USER command. If you want to force exit Vi without saving the modified document, you can use the command

: Q!

Vi abandons the modification and directly returns it to shell.

In the last line mode, enter the command

: Wq

Vi will save the document first, and then exit Vi and return to shell.

In the last line mode, enter the command

: X

This command has the same functions as the ZZ command in command mode.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.