Linux vi command quick operation summary, linuxvi command Summary

Source: Internet
Author: User

Linux vi command quick operation summary, linuxvi command Summary

Part 1: buttons available in the general instruction mode: cursor movement, copy and paste, search replacement, etc.

I. How to move a cursor
H or move a byte to the left by the cursor
J or move a byte downward by the cursor
K or forward (forward) the cursor moves one byte up
L or move a byte to the right of the cursor (→)

[Ctrl] + [f] the screen moves one Page Down, which is equivalent to [Page Down] pressing cursor (commonly used)
[Ctrl] + [B] The screen moves one Page Up, which is equivalent to [Page Up] pressing forward (commonly used)
[Ctrl] + [d] Move the screen down half page
[Ctrl] + [u] screen "up" move half page

N <space> that n represents a number, for example, 20. Press the number and then press the blank cursor. The cursor will move the n Bytes of this column to the right.
0 or feature [Home] This is the digit "0": Move to the front byte of this column (commonly used)
$ Or the function moves [End] to the last byte of this column (commonly used)

H The cursor moves to the first byte in the column at the top of the screen
M cursor moves to the first byte of the column in the center of the screen
L move the cursor to the first byte in the column at the bottom of the screen

G moves to the last column of this document (commonly used)
NGn is a digital word. Move to column n of this document. For example, 20 GB will be moved to the 20th column of this document (can be used with: set nu)
Gg moves to the first column of this document, which is equivalent to 1 GB! (Common)
N <Enter> n is a number. Move the cursor down n columns (commonly used)

2. search and replace
/Word searches for a string named word under the cursor.
? Word searches for a string named word above the cursor.
N. n is an English word. Indicates "repeat the previous search action 』.
N. N is an English word. Opposite to n branch, the previous search action is performed for "reverse.
: N1, n2s/word1/word2/gn1 and n2. Search for the word1 string between column n1 and column n2 and replace it with word2.
": 100,200 s/vbird/VBIRD/g 』. (Common)
: 1, $ s/word1/word2/g searches for the word1 string from the first column to the last column, and replaces the string with word2! (Common)
: % S/one/two/g same as above
: 1, $ s/word1/word2/gc is the same as above. display the prompt byte before replacement to confirm (confirm) whether to replace! (Common)

Iii. Division, copying and pasting
X and X are in a column. x is a forward delimiter in addition to a byte. X is a forward delimiter.
Nxn is a digital word, which is used to divide n Bytes backward.
Dd sort the entire column in which the cursor is located (commonly used)
Nddn is a number. Remove the n-down column of the cursor.
D1G except all data in the first column where the cursor is located
DG sort all data from the cursor to the last column
D $ remove the cursor to the last byte of the column
D0 is the number 0. It is the first word in the column in the cursor division.

Yy copy the column of the cursor (commonly used)
Nyyn is a number. Copy the n-down column where the cursor is located. For example, 20yy copies 20 columns (commonly used)
Y1G copy all data from the cursor column to the first column
YG copies all data from the column where the cursor is located to the last column
Y0 copies the cursor's byte to all data at the beginning of the row.
Y $ copy all data from the byte of the cursor to the end of the row.
P and Pp paste the copied data in the next column of the cursor. P should be placed in the previous column of the cursor!
For example, I currently have a cursor in 20th columns and have copied 10 columns of data.
After you press p, the 10 columns of data will begin after the original 20 columns, that is, starting from the 21 columns.
But what if I press P? The original 20th columns will be pushed to 30 columns. (Common)

C. Repeat multiple data items, such as dividing 10 columns down and [10cj]
U was the original previous action. (Common)
[Ctrl] + r redo the previous action. (Common)
. Don't be suspicious! This is a small data point! It means to repeat the previous action.
If you want to repeat operations such as division and pasting, just click! (Common)

 

Part 2: Description of the buttons available for switching from General Command mode to zookeeper Mode

1. Inbound insertion or replacement of zookeeper Mode
I, Ii is "insert from where the current cursor is located", and I is "insert from the first non-blank byte in the current column 』. (Common)
A, Aa: "insert starting from the next byte of the current cursor", and A: "insert starting from the last byte of the column where the cursor is located 』. (Common)
O, Oo: "insert a new column in the next column where the current cursor is located"; O insert a new column in the previous column where the current cursor is located! (Common)
R, Rr will replace the byte where the cursor is located only once; R will replace the text where the cursor is located until you Press ESC; (commonly used)
[Esc] exit the zookeeper mode and return to the General Command mode (commonly used)

 

Part 3: available button description for switching from the General Command mode to the command column Mode

: E! Restore a document to its original state
: W. Copy scanned data to the hard drive document (commonly used)
: W! If the document is written as "read-only", write the document in writing mode. However, whether or not it can be written is related to the document permission of the document!
: Q exit vi (commonly used)
: Q! If you have modified the document and do not want to save it, use it! To enable or disable saving of documents.
Note that the exclamation point (!) In vi, it often has the meaning of "Scheme ~
: Wq: Save and exit. If it is: wq! As follows: Save and exit (commonly used)
ZZ: This is the Z of big data! If the document is not updated, it will not be saved and opened. If the document has been changed, it will be saved and opened later!
: W [filename]: Save the uploaded documents as another document (similar to storing new documents)
: R [filename]: in the documents of another document, enter the documents of another document. That is, add the content of "filename" to the end of the column where the cursor is located.
: N1, n2 w [filename] n1, n2 is a number. Save the content from n1 to n2 as filename.
:! Command temporarily leaves vi to the command column mode! For example
『:! Ls/home ", you can view the ls documentation under/home in vi!

: Set nu displays the row cursor. After setting, the row cursor in the column is displayed at the beginning of each column.
: Set nonu is opposite to set nu!

Part 4:
Ctrl + z run the text editing process in the background
Fg uses this command to call up

 

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.