Vi Command Linux Tutorial: Beginner’s Guide
Vi is a text editor used for editing files in the Linux system. Here are some basic operations for using the Vi command:
- To open a file in Vi, enter the following command in the terminal:
- view the file
- To exit Vi and save changes, press the “ESC” key, then type “:wq” and press “Enter”.
To exit Vi without saving changes, press the “ESC” key, then type “:q!” and press “Enter”. - Insert text: Press the “i” key to enter insertion mode, then start typing text.
- Save the file by pressing the “ESC” key, then typing “:w” and pressing the “Enter” key.
- Undo changes: press the “ESC” key, then type “u” and press the “Enter” key.
- Move the cursor: Use the arrow keys or “h”, “j”, “k”, “l” to move the cursor.
- Copy, paste, cut: Enter visual mode by pressing the “v” key, then use the directional keys to select the text. Press “y” to copy the selected text, “d” to cut the selected text, and “p” to paste the text.
These are some basic Vi command operations that will help you get started with using the Vi editor in the Linux system.