How to edit in vi on Linux?
To edit on Linux using the vi editor, you can follow these steps:
- Open the terminal window.
- Enter the following command to create or edit a new file: vi filename (for example: vi example.txt).
- Press the “i” key on the keyboard to enter “insert mode”, so you can start editing the file.
- In Insert Mode, use the keyboard to input text or perform other editing operations.
- After editing is complete, press the Esc key on the keyboard to exit “insert mode”.
- In command mode, enter a colon (:) to access command mode.
- Save the file.
- Exit the editor.
- Save and exit the editor by typing :wq.
- Do not save the file and quit the editor forcefully.
- Save the file and exit the editor (equivalent to the :wq command).
- :show line numbers.
- :set nonum to disable displaying line numbers.
- Search for specified keywords in the file.
- In command mode, enter the above command and press the Enter key to execute the corresponding operation.
Here are the basic instructions for using the vi editor. In actual practice, you can learn more advanced techniques and shortcuts by referring to the documentation or other tutorials for the vi editor.