Basic CentOS vi operations

Source: Internet
Author: User

Basic CentOS vi operations

1. About exit


: Wq! ---- Force save and exit
: Wq ---- save and quit
: X ----- works the same as: wq
ZZ ---- has the same role as: wq (note that Z is capitalized and not in command mode)
: Q ---- exit
: Q! --- Force exit

========================================================== ======

2. About mobile


H: Move a character from the current row to the left.
J: Move to the next row
K: Move to the previous row.
L: move one character to the right of the current row
Ctrl + f: Scroll one page forward
Ctrl + B: Scroll back one page
: N: move the cursor to line n.
: $ Move the cursor to the last line
0. move the cursor to the beginning of the row.
$ Position the cursor at the end of the row
G positions the cursor in the last line of this article, which is the same as: $.
H. move the cursor to the top of the screen.
M positions the cursor in the middle of the screen
L move the cursor to the bottom of the screen


========================================================== ====
3. Search


/: Search for the following information in the file.
? : Search for the things to be searched in the file.
N: Repeated search forward
N: Repeated search


========================================================== =====
4. About Replication

Yy: copy the current row of the cursor
Nyy: copy the n-1 line from the current row to the current row.
: 1,100 co 200 will 1 ~ 100 of the content is copied to 200th rows.
: 100,102 co $ change 100 ~ Copy the contents of the first row to the last row.


========================================================== ======
5. About pasting


P: paste it to the next row of the current row.
P (large): paste it to the previous row of the current row


========================================================== ======
6. About Delete. Cut


Dd deletes the current row
Ndd is similar to nyy
Dw deletes a word
Similar to ndd, ndw
X delete a character
Nx Delete n characters
DG deletes all content from the current cursor to the end of the file.
D0 deletes all content from the current cursor to the beginning of the line
D $ delete all content from the current cursor to the end of the row
: 1, 100d delete 1 ~ 100
: 100d Delete 100th rows
: 1,100 mo $ Change 1 ~ Move the content of Row 3 to the last row.

========================================================== =====
7. insert


I: Enter the insert mode before the characters in the current position
I: insert at the beginning of the current row
A: Enter the insert mode after the characters at the current position
A: insert at the end of the current row.
O: Insert a new row under the current row.
O: Insert a new row on the current row.


========================================================== =====
8. About Revocation

U: undo the last change


========================================================== =====
9. About replacement


Regexp: The pattern to be matched.
Replacement: string to be replaced


: S/regexp/replacement ------------------------- Replace the first style of the current row
: S/regexp/replacement/g ------------------------- replace all the matches in the current row
: % S/regexp/replacement/g ----------------------- replace all matching styles in the file


========================================================== =====

PS: Another important command is the "." command, which is used to repeat the previous command.

In vi, how does one: undo the last operation ?, Repeat a group of Edit operations multiple times ?.......

A) undo the previous edit operation. ====> U
B) Repeat the previous edit operation. ====>.
C) restore the unedited operation. ======> Ctrl + R

D) repeat a group of edits multiple times. ====> "." Command can repeat the last edit action.

Tool: yum install gonme-utils; command: gnome-screenshot-;

The synchronization time can be ntpdate us.pool.ntp.org, which must be networked. If ntpdate is not installed, run yum: yum install-y ntpdate.

Reprinted from: http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/14/2211202.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.