vim tutorial: vim save and quit

Vim save and quit / exit, there are two shortcut keys:

  • : wq
    Force write file and quit.
    Even if the file is not modified, it is forced to write, and the modification time of the file is updated.
  • : x
    Write to file and quit.
    Write only when the file is modified, and update the file modification time; otherwise, the file modification time will not be updated.

  1. Open the terminal

2. Use vim to open the file and enter the vim normal mode

3. In the vim normal mode, use the i or a or o shortcut key to enter vim insert mode, add or modify content

4. After modification, press esc to exit vim insert mode

5. Type: enter the last line mode, then type x or wq and press Enter, vim will save and quit

6. Use the cat command to view the contents of the file

Add a Comment

Your email address will not be published.