Linux Editor--ancient artifact vim

Source: Internet
Author: User

1. Insert

Press "I": Enter the file starting at the cursor's current position.
Press "I": Insert at the beginning of the line where the cursor is located.
Press "a": Enter text from the next position where the cursor is currently located.
Press "A": Insert at the end of the line where the cursor is located.
Press "O": Insert a row below
Press "O": Insert a row above.
Press "s": delete one character after the cursor and enter insert mode.
Press "S": Delete the line where the cursor is located and enter insert mode.

2. Cursor movement

"H", "J", "K", "L" respectively control the left, bottom, upper and right of the cursor to move one cell.

"W": the cursor jumps to the beginning of the next word.

"E": the cursor jumps to the end of the next word.
"B": the cursor returns to the beginning of the last word.
"NL": the cursor moves the nth position of the row, for example: "5l" represents the 5th character moved to the line.

"Ctrl+b": the screen moves backward one page.
"Ctrl+f": the screen moves forward one page.
"Ctrl+u": the screen Moves backward half-page.
"Ctrl+d": the screen moves forward half a page.
Number "0": moves to the beginning of the text.
"G": Moves to the end of the file.

"GG": Move to the beginning of the file
"$": Moves to the end of the line where the cursor is located.
"^": moves to the beginning of the line where the cursor is located.

3. Delete

"X": Deletes the following character at the position of the cursor every time it is pressed.
"NX": for example: "6x" means the deletion of 6 characters after the cursor position.
"X": Deletes the previous character in the position of the cursor every time it is pressed.
"DD": Deletes the line where the cursor is located.
"NDD": Deletes n rows starting at the line where the cursor is located.

4. Copy

"YW": copies the character of the cursor at the end of the word into the buffer.
"NYW": copies n words to buffer.
"YY": Copies the line of the cursor to the buffer.
"Nyy": for example: "6yy" means that the copy starts at 6 lines of characters from the line where the cursor is located.
"P": writes the characters in the buffer to the location of the cursor.

5. Modify

CW: Changes the word-to-tail at the cursor location.
"CNW": for example: "c4w" means change of 4 words.

6. Jumps to the specified line

"Ctrl+g": Lists the line number of the line where the cursor is located.
"NG": for example: "15G", which means moving the cursor to the beginning of the 15th line of the file.

7. Save

"ESC": Exit Edit mode

E ": Restore the file to its original state

"Q": No modification exit

"Q! ": Do not save forced exits

"Wq": Save exit

"Wq!" : Force Save to exit

"ZZ": Save and exit
"ZQ": Do not save the disk to exit
"R": replaces the character at which the cursor is located.
"R": replaces characters that are everywhere in the cursor until the ESC key is pressed.
"U": Undo Last Action

8. Display Line Numbers

Press the "ESC" key first to determine that you are in normal mode and then press the colon ":" To enter the last command mode.

"Set nu": List line numbers
"Set Nonu": un-listing line numbers
"Set IC": ignoring case when searching
"Set Noic": Cancels ignoring case when searching.
"N": jumps to a line in the file, "n" represents a number, enters the number 10, and then returns to the 10th line of text.
"!cmd": Run shell command cmd.

9. Find characters

"/word" looks for word string after cursor
"? word" to find word strings before the cursor
"/keyword": First press "/", then enter the character you want to find, if the first search for the keyword is not desired, you can always press "n", looking for a keyword. “? Keyword ": Press first?" Key, and then enter the character you want to find, and if the keyword you first searched for is not what you want, you can always press "? , look for a keyword later.

10. Replacement characters
S/word1/word2/g find word1 on the current line of the cursor and replace it with WORD2
n1,n2s/word1/word2/g find word1 between line N1 and line N2 and replace with Word2
%s/word1/word2/g the entire article to find word1, and replace it with WORD2


This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1886400

Linux Editor--ancient artifact vim

Related Article

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.