Common Vim shortcut keys

Source: Internet
Author: User

H. Move a character to the left.
J move a character downward with the cursor
K move the cursor one character up
L move the cursor one character to the right
W: Move a word to the back ~ You need to use this word before you can understand it.
If you want to move multiple times, for example, move 30 rows down, you can use 30j to pull ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit mode:
I don't need to mention this. I can directly enter the insert mode ~
O I like this command! It is to insert a new row under the row and automatically enter the insertion mode. If the O (large O) is used, it is from the top of the current row ~
The a command is used to enter the insert mode, but unlike I, it will return a backward character, which is very useful! You will know how to pull it when writing C language!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Some Common commands:
CTRL + F move a page down, that is, the page down
CTRL + B move one page up, which is the role of page up

Some Common commands. I think it is useful! Let's take a look at it. It's common! In upper case, Shift + CHA will be pulled.
H move the cursor to the row at the top of the screen
G move the cursor to the lowest line of the entire document
L which line should the cursor move to the bottom of the screen?
J (uppercase) The command function is to combine the line and the next line into a line
$ Move to the end of the line
* This asterisk has the search function ~ It will search for the word on your cursor and automatically move the cursor to the next word ~
0 (zero) Move to the beginning of the line
U is quite useful! Is to restore the meaning of the previous action. Return to the previous action, which is equivalent to the CTRL + z command in the graphic editor.
CTRL + R is the opposite of U. This is to redo the previous action.
. You are not mistaken! This is a period in English! Powerful functions. Repeat the previous action! Remember, it's repeated ~ Not restoration ~
/Word: search for a string named word under the cursor. Eg: Search for yutao and then pull/yutao.
? Word searches for a string named word over the cursor.
N indicates repeating the previous search. For example, if you search for/yutao, you can search for yutao again.
N is the opposite of the small N function, which repeats the previous one. This is reverse search ~ Hey
: N1, N2s/word1/word2/g is replaced. It means that from the line N1 to the line N2, We can find word1 and replace it with word2. If we replace N2 with $, it means from that row to the last row, if we change g to GC, you can try it ~ It will prompt you whether to delete it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy. Paste. Delete.
X. You will know it when you use it ~ Is to delete the current character
D. This is what Delete means ~ Next I will introduce her usage!
Dd deletes a whole row! If it is 30dd, 30 rows will be deleted ~
D1g deletes the data from the cursor to the first row.
DG deletes the data from the cursor to the last row...
D $ indicates what it means ~ It's the end of the line!
YY: This is the row where the copy cursor is located! Very useful!
Nyy, n is the meaning of a row. Let's guess its function.
Y $ hey. $ Met you again. Yes, it's just copying the cursor to the end of the line. What if it's 0? Hey hey... I don't need to explain it.
P is paste. Paste it under this row. The big P is above this line ..
C. Delete multiple data records repeatedly. Eg: if you delete 10 rows down, enter 10cj and click OK. This is rarely used. Just read it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Below are some Vim commands
: W name is too common, that is, to save the current file to the hard disk. Name is the name you specified. You can also specify the path! If W is used! It is forced write, that is, if the current document is read-only, it is forced to write. But it also depends on the permissions of your users .! Is mandatory ~
: Q: Exit vim. If Q is used! This indicates forced exit. That is to say, do not save ~~
: The r name command is generally not commonly used and is not intended to be written. Append the content of a file from the current cursor.
: E! Restore the file to the initial state ....
ZZ is a useless command. You can give me an explanation when you press the wrong command .. If the file is not modified, it is not saved and left. If the file is changed, it is stored and left.
: W. This is the meaning of saving, provided that the document you edited is written to the hard disk!
: Find filename. The file name is next to it ~
: The set hlsearch command can highlight the search content ~ Very good
: The set nu function is used to display the row number.
: Set Nonu is obviously SA, which is the opposite of the preceding command...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
The following commands for the set can be set in the vim configuration file. I usually enable the row number. How can I use the vim configuration file? Go to Baidu: vimrc is complicated. There are too many settings. Select some of your favorite commands and add them to the configuration file. You will fall in love with vim ~ The vimrc path is/etc/vimrc. The/etc/directory is the configuration directory of most Linux software ~ Haha
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

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.