Vim Install yum install-y vim
Vim View basic information vim--version
Vim Open and new file vim [filename]
Vim operation after entering the file
Note: There are several modes of vim first
1, shortcut key mode: Vim can only move the cursor up or down after opening the file, cannot write.
2, edit mode: Shortcut mode point keyboard i o A can enter the editing mode. Press ESC, from edit mode to shortcut key mode. The concept does not explain.
3, command-line mode: Press SHIFT + in the shortcut mode: called command-line mode (the main difference between the shortcut mode is the command can be displayed at the command line)
The basic command to explain the main in 1, 3 mode
Basic commands in shortcut key mode:
| Dd |
Delete the cursor where you are moving forward |
| U |
Go back to previous steps |
| Ctrl + R |
Back much, before further |
| Yy |
Copy the cursor where you are moving forward |
| P |
Paste |
| N +DD |
where n is a number, delete the n rows below the current line where the cursor is located |
| n + yy |
where n is the number, and the next n rows at the beginning of the current line of the cursor are copied |
| Gg |
Quick back to top of file |
| Shift+gg |
Quickly back to the end of the file |
| SHIFT + $ |
Fast reach end of line |
| SHIFT + 6 |
Quickly reach the beginning of the line |
Command-line mode base command:
| : Set Nu |
Show line Numbers |
| : Set Nonu |
Do not display line numbers |
| /"Characters to look for" |
Full text find characters from top down |
| ? "Characters to look for" |
Full text find characters from bottom to top |
| N |
During the lookup, the cursor moves to the next |
| Shift+n |
During the lookup process, the cursor moves to the previous |
| :%s/"character to be replaced"/"substitution character" |
Replace All |
| : S/"character to be replaced"/"substitution character" |
Replace the cursor where you are moving forward |
| : n,m S/"character to be replaced"/"substitution character" |
Replace from n lines until m rows |
Common basic commands for Linux VI vim