vi editor training

   3.4 实训:使用vi编辑器创建并编辑文档

1. Open the file in the terminal directory.
Find a file entry, for example: vi man_db.conf to enter this command
as shown:
Here Insert Picture Description
to enter the page like this:
Here Insert Picture Description
2. Open Vi vi man_db.conf in the current directory
as shown:
Here Insert Picture Description
3. Set at the line number in vi.
Executed in the current directory: set nu command
in the following direct: set nu
Here Insert Picture Description
and then press Enter:
Here Insert Picture Description
4. Move to line 58, to move to 40 characters to the right, within the quotation marks to see what directory?
First press 58G, the press 40 →.
Here Insert Picture Description
There is no 40 →
5 to the first line, and the search string number bzip2 down, will he in the first few lines?
1G or first implementation of the first row gg to directly input / bzip2
Here Insert Picture Description
will be directly input in the bottom of the current page.
Here Insert Picture Description
But we do not have this can be found here.
6. The man between 50 to 100 lines changed MAN, and whether you need to modify one by one to pick, how to place an order?
Direct execution: 50,100s / man / MAN / gc to (performed in line mode)
Here Insert Picture Description
directly to the line 50 to the inside of the man 100 MAN changed
by a direct all of the off press y may be changed one by one, by u direct the full reinstatement.
7. After you finish modifying, suddenly go back on, requiring the full reinstatement, in what ways.
The simplest way to restore the original appearance by u directly, do not save the command: q! Left, read the file again.
Here Insert Picture Description
8. Copy lines 51 to 60 that the contents of the line 10, and then attached to the last row.
51G and then again after the selection performed by 10yy G, the last line, and then paste the contents of line 10.
Here Insert Picture Description
As shown in the last line has been re-copy the contents of the line 10. You can see whether the 10 lines of the same content.
9. Remove the line 20 between lines 11 and 30.
After performing 11G, then 22dd to delete 20 lines
Here Insert Picture Description
10. This document will be saved as a file man.text.config.
Directly in the line mode execution: w man.text.config command.
Display as shown:
Here Insert Picture Description
11 to line 29 and delete 15 characters.
After performing 29G, then you can delete 15x 15 characters.
12. leave without saving
: q!

Guess you like

Origin blog.csdn.net/nnj99/article/details/89019906