How do you edit with the Linux vi command?
To edit a file using vi command, input the following command in the terminal:
vi 文件名
This will open a vi editor interface where you can use the following commands for editing:
- Enter the insert mode to start inserting text at the current cursor position.
- Press ESC to exit insert mode and return to command mode.
- :wq:Save and exit the file.
- Do not save and exit the file.
- :x: Save and exit the file.
- :w: Save the file.
- Please exit the file.
- dd: delete the current line.
- yy: Copy the current line.
- p: Paste copied content.
- Search Content: Scroll down to search for specific content.
- n: Locate the next matching item in the search results.
- u: Undo the last action.
- Press Ctrl + f to scroll down the page.
- Pressing Ctrl + b scrolls up the page.
These are just a few basic operations of the vi command, there are many other functions and commands that can be used. You can view more help information by entering the following commands in the terminal:
man vi