Course connection: Vi Text Editor
Vi and vim
Vi is a text editing tool on the command line interface. It provides text editing, text processing, code development, and other functions.
Vim is the strong version of vi (Code highlighting)
Run vim to start the vim editor.
Vim + target path
- Open the file if the file exists.
- Create a file if the file does not exist.
Vim three modes-command mode
- After vim is started, it enters the command mode by default. In any mode, the command mode can be returned through the esc key.
- In command mode, you can copy, paste, select, and revoke commands.
-In the insert mode, press 'I in the command mode to enter the insert mode. In the insert mode, you can enter the edit content and Press esc to return to the command mode.
-In the command mode, press the ':' key in the quiet mode. The cursor moves to the bottom. You can save or exit vim here.
Command mode
- I insert before the cursor
- O insert in the next row of the current row
- Dd deletes the current row
- Yy put the current row into the buffer (copy the current row)
- N + yy put n rows of content into the buffer (copy the current n rows)
- P paste the content in the buffer after the cursor
- U undo
- R replaces the current character
- /Search for keywords (n-key switch)
EX Mode
- : W save
- : Q exit
- : Q! Force exit without saving changes
- : X save and exit, equivalent to: wq
- : Set number: displays the row number.
- :! The system command executes a system command and displays the result.
- : Sh switch to the command line, Ctrl + d returns vim
Insert mode
After pressing 'I', you can enter any text, and esc will exit the return command mode.