Introduction
vim is a Windows-like Notepad editor for Linux systems.
Three modes often used in vim
Normal Mode: Browse file contents.
Insert Mode: Edit file content.
Bottom line mode: perform operations such as saving editing content, exiting, etc.
Basic command operations
vim filename , open the file, enter normal mode.
So now what if I want to modify the file?
First, switch from normal mode to edit mode.
Enter i in normal mode to switch to edit mode
then you can now edit the content
What if you want to save the content after editing? Remember what mode the save operation was in when we said earlier?
That's right! is in bottom row mode.
In vim, you cannot directly switch from insert mode to bottom line mode, you need to switch to normal mode first, and then switch to bottom line mode.
Press esc to switch from insert mode to normal mode, then you will find that the bottom -- insert-- mark disappears, indicating that it has switched to normal mode.
In normal mode, enter: to switch to bottom line mode.
Enter wq in bottom line mode and press Enter to save and exit.
What if you don't want to save it? Type q! in bottom line mode! , you can force quit without saving.
What if you don't want to quit? Press the esc key to switch back to normal mode.
Summarize
General mode:
Function: browse file content
Toggle:
Press i to switch to insert mode
Press: can switch to bottom row mode
Insert mode:
Function: You can edit the file content.
Toggle:
Press ESC to switch back to normal mode
Bottom row mode:
Function: Enter q! to force exit without saving, enter wq to save and exit
Toggle:
Press ESC to switch back to normal mode