How to use VIM commands in Linux system

Vim is a common text editor, usually widely used in Linux systems.
1. Open a terminal: Open a terminal window in the Linux system.
2. Enter the vim command: Enter the vim command in the terminal window and press the Enter key to enter the Vim editor.
3. Open the file: In the Vim editor, you can use the command ":e" plus the file name to open the file. For example, enter ":e /path/to/file" to open the /path/to/file file.
4. Enter edit mode: By default, Vim is in command mode. To enter edit mode, press the "i" key or another letter key. In edit mode, you can edit the file content.
5. Save and exit: When finished making changes to the file, press the "Esc" key to return to command mode. Then enter the ":wq" command to save the changes and exit the Vim editor.

Here are some commonly used Vim editing commands:
1. i: enters insert mode, allowing you to enter text.
2. Esc: Exit Insert mode and return to Normal mode.
3. :w: Save the current file.
4. :q: Exit Vim.
5. :wq: Save and exit Vim.
6. dd: Cut the current line.
7. yy: Copy the current line.
8. p: Paste the copied or cut text.
9. u: Undo the previous operation.
10. /: Find text.
11. n: During a lookup, jump to the next match.
12. N: During a lookup, jump to the previous match.
13. :%s/old/new/g: Globally replace all occurrences of old strings in the text with new strings.
14. :set number: Display line number.
15. :set nonumber: Hide line numbers.
16. :x: Similar to :wq, save and exit Vim. However, if no changes have been made to the current file, the save will not be written. This function can be used by entering the ":x" command in normal mode.

Guess you like

Origin blog.csdn.net/weixin_54104864/article/details/130784671