VIM Exit command

Source: Internet
Author: User

Note: These commands have a colon before them:

When you are finished editing the document, you are ready to exit VI when you return to the shell, you can use one of the following methods.

In command mode, double-press two capital Letter Z, if the currently edited document has been modified, VI saves the document and exits, returns to the shell, and if the currently edited document has not been modified, VI exits directly and returns to the shell.

In the last line mode, enter the command

: W

VI saves the currently edited document, but does not exit, but continues to wait for the user to enter the command. When you use the W command, you can then give the edit document a new document name.

[Example 6]

: w NewFile

At this point VI will save the contents of the current document to the specified NewFile, while the original document remains unchanged. If NewFile is an existing document, VI gives a hint in the status line of the display window:

File exists (use!) To override)

At this point, if the user really wants to replace the contents of NewFile with the current contents of the document, you can use the command

: w! NewFile

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

In the last line mode, enter the command

: Q

System Exit VI returns to the shell. If the edit document is not saved when you exit VI with this command, VI displays the following information in the last line of the display window:

No write since last change (use!) To overrides)

Prompts the user that the document has been modified without saving, and then VI does not exit, continuing to wait for the user command. If the user does not want to save the modified document and want to forcibly exit VI, you can use the command

: q!

VI Discard the changes and return directly to the shell.


In the last line mode, enter the command

: Wq

VI will save the document first and then Exit VI to return to the shell.

In the last line mode, enter the command

: X

The function of this command is the same as the ZZ command in command mode.

VIM Exit command

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: info-contact@alibabacloud.com 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.