Vim Exit command (save, discard Save)

Source: Internet
Author: User

In command mode, double-press two capital Letter Z, if the currently edited file has been modified, then VI save the file and exit, return to the shell; if the currently edited file has not been modified, VI exits directly and returns to the shell.

In the last line mode, enter the command

: W

VI saves the current edit file, 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 file a new file name.

[Example 6]

: w NewFile

At this point VI will save the contents of the current file to the specified NewFile, while the original file remains unchanged. If NewFile is an existing file, 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 file, you can use the command

: w! NewFile

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

In the last line mode, enter the command

: Q

System Exit VI returns to the shell. If the edit file 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 file 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 file 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 file first and then Exit VI to return to the shell.

In the last line mode, enter the command

: X

The command functions the same as the ZZ command in command mode

Vim Exit command (save, discard Save)

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.