In command mode, the upper-case letter Z is used for two connections. if the current edited file has been modified, Vi will save the file and exit, and return to shell; if the current edited file has not been modified, Vi exits directly and returns to shell. In the last line mode, enter the command: wVi...
In command mode, the upper-case letter Z is used for two connections. if the current edited file has been modified, Vi will save the file and exit, and return to shell; if the current edited file has not been modified, Vi exits directly and returns to shell.
In the last line mode, enter the command
: W
Vi saves the current editing file, 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 file name for the editing file.
[Example 6]
: W newfile
At this time, Vi will save the content of the current file to the specified newfile, while the original file remains unchanged. If newfile is an existing file, 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 file, you can use the command
: W! Newfile
Otherwise, you can select another file name to save the current file.
In the last line mode, enter the command
: Q
The system exits Vi and returns to shell. If the editing file is not saved when you exit Vi with this command, the last line of the Vi display window displays the following information:
No write since last change (use! To overrides)
The user is prompted that the file 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 file, 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 file 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.
From lovejing007