Vim's save file and Exit command

Source: Internet
Author: User
Tags save file

Article Source: http://blog.sina.com.cn/s/blog_5e357d2d0100zmth.html

Command

Simple description

: W

Saves the edited file content, but does not exit the vim Editor. The purpose of this command is to write the data in the memory buffer into the file specified when Vim is started.

: w!

Force the file to be written, that is, to overwrite the original file. This command can be used to force writes if the original file's access permission does not allow writing to the file, for example, if the original file is a read-only file. However, this command usage applies only if the user is the owner of the file, and the superuser is not restricted.

:wq

Save file contents and exit vim Editor. The purpose of this command is to write the data in the memory buffer to the file specified when you start vim . Then exit vim Editor. Another alternative is to use the zz command.

:wq!

forces the file contents to be saved and exits vim Editor. The purpose of this command is to force the data in the memory buffer to be written to the file specified when you start vim . Then exit vim Editor.

zz

using zz command, if the file has already been edited, write the data in the memory buffer to start vim when you specify the file, and then exit vim Editor. Otherwise, just exit vim only. Note that the zz command does not need to be preceded by a colon ":", nor does it need to press enter key.

:q

ready to quit without any editing processing Vim , you can use this command. vim do not allow user " :q "command exits, and the following warning message is also output:

no write since last Change (: quit! overrides)

: q!

Forces the vim editor to quit and discard the results of the editing process. If you do not need to save the modified file content, you can enter ": q! command to forcibly exit the vim Editor.

: w filename

Writes the result of the edit process to the specified file and saves it

: w! FileName

The result of editing is forced to be saved to the specified file, overwriting the existing file if the file already exists.

: wq! FileName

Forces the edited result to be saved to the specified file, overwriting the existing file if the file already exists, and exiting the vim Editor.

Vim's save file and 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.