VI common M commands I. moving the cursor Vim uses h, j, k, and l keys to move the cursor. According to the official statement, this ensures that both hands do not leave the keyboard area, thus improving the input efficiency. The positions of these four keys on the keyboard are from left to right, and the corresponding directions are left, down, up, and...
VI common M commands I. moving the cursor Vim uses h, j, k, and l keys to move the cursor. According to the official statement, this ensures that both hands do not leave the keyboard area, thus improving the input efficiency. The positions of these four keys on the keyboard are from left to right, and the corresponding directions are left, down, up, and right. All books and tutorials on Vim on the Internet teach Vim beginners a set of memory methods, that is, h on the left, l on the right, and j on the bottom. This method is very clever and summed up by countless Vimmer in learning and using it. However, I have another experience: the initial position of our right Index on the keyboard is the j key. Generally, the most common direction key we use when reading or editing documents is down, therefore, setting the j key as the downward key is the most suitable. setting the k key on the right side and its adjacent k key as the downward key also achieves the same convenience. When the cursor needs to move to the left, our right index finger also needs to move to the left. the two directions are the same. The use frequency of the right-click is higher than that of the left-click, so it is set to the l key that the ring finger directly contacts. 2. how to exit Vim there are two different ways to exit Vim as the editor wishes: 1. exit without saving, that is, force exit. : Q! 2. save and exit. : Wq 3. delete class Command www.2cto.com 1. delete the character at the cursor position: x. Place the cursor at the position of the character to be deleted, and then press the x key. 2. delete all characters from the cursor position to the end of a word/word: dw. Note: Because each word in English has spaces but there are no spaces between Chinese characters, the command in Vim defines the single word/word, therefore, when you execute this command on a line of Chinese, all characters from the cursor position to the row where the cursor is located will be deleted, and the effect is the same as that of the d $ command. 3. delete all characters from the cursor position to the end of the row where the cursor is located: d $. 4. delete all characters in the row where the cursor is located: dd. The character on the left of the cursor will also be deleted. IV. Insert Command 1. Insert: I before the cursor position. 2. Insert a after the cursor position. 3. Insert A at the end of the row where the cursor is located. 5. open class commands 1. open a new line below the row where the cursor is located and enter the insert mode: o. 2. open a new line above the row where the cursor is located and enter the insert mode: O. Www.2cto.com 6. change class commands 1. change all characters from the cursor position to the word/word end of the cursor, and enter the insertion mode: cw. 2. change all characters from the cursor position to the row where the cursor is located and enter the insert mode: c $. VII. replacement commands 1. replace the character at the cursor position: r. Place the cursor at the position of the character to be replaced, press r, and type a new character. 2. continuously replace the character after the cursor position: R. Www.2cto.com 8. one of the correct commands 1. replace the first old character in the line where the cursor is located with the new character.: S/old/new2. replace all old characters in the row where the cursor is located with new characters.: S/old/new/g3. replace all the old characters between the two rows with the new character, # indicates the row number.: #,# S/old/new/g4. replace all old characters in the file with new characters.: % S/old/new/g5. replace all the old characters in the file with the new character, and ask whether to confirm the replacement.: % S/old/new/gc 9. placement class commands place the last deleted content after the cursor: p. 10. undo class commands 1. undo the last executed command: u. 2. undo all operations on the entire row: U. 3. restore the undo command: CTRL-R. 11. locate and obtain the file status 1. display the position of the row where the cursor is located and the file status information: CTRL-g. 2. jump directly to the specified row: SHIFT-G. First, press SHIFT-G. 12. search for matching brackets: %. After % is pressed, the cursor will automatically jump to the matching brackets and then jump back to the original brackets. 13. search command 1. search for a string in sequence in the current file:/string. Start from the beginning of the article. 2. reverse query a string in the current file :? String. Start from the end of the article. 3. search for the next one in sequence: n. 4. Reverse Query: Shift-N. 14. Save the file 1. save the changes to the file.: W FILENAME2. save part of the file. # indicates the row number.: #,# W FILENAME 15. extract and merge files and insert additional file content at the cursor of the current file.: R FILENAME www.2cto.com 16. execute the external command in Vim :! Command 17. set command class: set command 18. the command and the command in the object Vim follow a certain format. The following describes how to delete the command (d. Www.2cto.com [number] d object or d [number] object number indicates the number of times commands are executed. (optional) the default value is 1. D indicates deletion. it is the command name. Object refers to the object to be operated by the command. For d, w (from the current cursor to the end of the word/word, including spaces), e (from the current cursor to the end of the word/word, excluding spaces) and $ (from the current cursor to the end of the current row ).
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