Enter edit mode
Enter the mode in which the document can be edited
| Key |
function |
| I |
Insert in current character |
| I |
Insert at the beginning of the line where the cursor is located |
| A |
Insert in current word specifier |
| A |
Inserts at the end of the line where the cursor is located |
| O |
Insert a row below the line where the cursor is located |
| O |
Insert a row above the line where the cursor is located |
Vim Command mode
| Command |
function |
| /word |
Look for a string after the cursor word, press N to go back to search, N to return to search |
| ? word |
Find a string before the cursor word, press N to continue searching |
| : n1,n2s/word1/word2/g |
Find word1 between n1-n2 row ranges and replace with Word2, and no G replaces only the first word1 of each row |
| : 1, $s/word1/word2/g |
Replaces all word1 in the document with Word2, and replaces only the first word1 of each line |
| Attention |
When replacing a path or ambiguous character, such as/etc/sysconfig, you need to use # or @ instead of "/" in the search, i.e.: #/etc/sysconfig# |
| : W |
Save text |
| : Q |
Exit Vim |
| : w! |
Force save, root user, even if read-only can save |
| : q! |
Force exit, all changes are not valid |
| : Wq |
Save and exit, modify Mtime |
| : X |
Save and exit, do not modify Mtime |
| : Set Nu |
Show line Numbers |
| : Set Nonu |
Do not display line numbers |
| : Nohl |
Do not display highlighting |
Vim Practice
Find more scenes to practice
4 week 3rd session vim enters edit mode command mode