All instructions for VIM compatible VI
The VI command has the following characteristics:
- There's a difference in case letters.
- Does not appear on the screen when you enter it
- No more commands to add the ENTER key
1. Open and Close files
When you edit the text, vi copies the files you want to edit to the buffer (the part of the staging local content that is additionally set in memory), and displays the buffer (although you can see only a portion of the screen size at a time) and lets you add, delete, and change the text. When storing the edited result, Vi writes the contents of the buffer back to the permanent file, replacing the old file with the same name. Remember that you are always working on a copy of the file in the buffer.
Open File Command:
$ VI [Fikename]
The preceding command appears in square brackets, indicating that filename is optional and the square brackets themselves do not enter. If omitting Filename,vi opens an unknown buffer, we can name the contents of the buffer when it is written to the file. But the good habit is to give the file name first.
The file name must be unique in the directory, and can include any 8-bit characters except the slash (/), ASCII nul: Slash left as the directory separator, ASCII nul all parts are 0. You can even include spaces in the file name as long as you precede it with a backslash (\). It usually contains any uppercase or lowercase letters, plus dots and underscores.
Open a file under another directory to specify the full pathname, such as: $ vi/home/john/letter
2. Save and leave files
- W: Save but do not leave VI
- Q: Exit
- Wq: Save, leave
- Zz=wq
- E! Then press ENTER: Restore the last saved content
- Q! Then press ENTER: Remove all editing effects and leave VI
- W! File: filename conflict occurred while saving files, this command overwrites the original file
- W NewFile: Writes the edited result to a new file
Vim Learning Note (ii): Chapter I: VI text Editor