VI-Editor




[INTRODUCTION]


         


[ - Entering Insert Mode]


To start editing, press 'i' to enter insert mode. You'll see "-- INSERT --" at the bottom. Now type and edit freely. Press 'Esc' to exit insert mode and return to command mode.


[- Basic Editing]


While in command mode, try these essential text-editing commands:


- 'x' to delete the character under the cursor.

- 'dd' to delete the current line.

- 'yy' to copy the current line.

- 'p' to paste after the cursor.


[- Undo, Redo, and Replace]


In command mode, use these commands for advanced editing:


- 'u' to undo the last change.

- 'Ctrl + r' to redo changes.

- ':s/old_text/new_text/g' to find and replace 'old_text' with 'new_text'.


[- Setting Line Numbers]


Display line numbers for easy navigation:


- ':set number' to show line numbers.

- ':set nonumber' to hide line numbers.


[- Search and Find]


Search for text:


- '/search_text' to find 'search_text' forward.

- '?search_text' to find backward.


[Question and Answer]


Q1. How do I edit multiple files simultaneously?

A1. Use 'vi file1 file2' to edit multiple files.


Q2. Can I edit a specific line directly?

A2. In command mode, type the line number followed by 'G' to go to that line.


Q3. How do I copy text from one file to another?

A3. Use 'y' to yank the text, then open the target file and 'p' to paste it.



Post a Comment

Post a Comment (0)

Previous Post Next Post