![](https://www.linuxcommands.site/wp-content/uploads/2020/09/2020-09-13-08.39.48.gif)
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.
- Open the terminal
![](https://www.linuxcommands.site/wp-content/uploads/2020/09/image-9-1024x567.png)
2. Use vim to open the file and enter the vim normal mode
![](https://www.linuxcommands.site/wp-content/uploads/2020/09/image-10-1024x567.png)
3. In the vim normal mode, use the i or a or o shortcut key to enter vim insert mode, add or modify content
![](https://www.linuxcommands.site/wp-content/uploads/2020/09/image-11-1024x567.png)
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
![](https://www.linuxcommands.site/wp-content/uploads/2020/09/image-12-1024x567.png)
6. Use the cat command to view the contents of the file
![](https://www.linuxcommands.site/wp-content/uploads/2020/09/image-13-1024x567.png)