Vim Foundation, the foundation is not strong, shake

Source: Internet
Author: User

Now it is very important to say Vim,vim, but we have a lot of people to pay attention to the high technology, but when using vim to edit the file, the efficiency is not high. Vim is very important, I said below, is often used, simple things, I hope all remember, skilled in the heart, your work will help a lot.

Here is the technique of using vim:

Tip 1:

Edit mode (with vim to open the file by default is the edit mode), someone in the open vim, with the left and right arrows to move the cursor, here do not need, with "H J k L" These 4 letters to move, you see wrong, is the keyboard next to the 4 letters, H is left, L is to the right (because they are one One on the far right), J is down, K is up (I remember, at the time of playing cards, J is smaller than K, K is the upper level, and the upper level means climbing upwards. There is a way to remember, said the Netizen, J is the Japanese japan,k is Korea Korea, South Korea latitude than Japan, so is to go up)

Tip 2:

Save exit, useful Wq (or wq!), useful x (or x!), new method, uppercase ZZ, continuous press twice (edit mode), you can, also can save exit!

Tip 3:

Vim edit a very long piece of code, want to jump to this section of the end of the line, how to do? Do you use arrows to move to the end of the line? It's too slow! In accordance with the can, immediately jump to this section of the broken tail, simply put! Press the Arabic numerals 0 (or press ^), jump to the first, easy (of course, this is also in edit mode)

Tip 4:

In edit mode:

W: Move to the beginning of the next word (for example: "Hello World,haha", the cursor is on the hello, click W, jump to the top of the next word, that is the first word, you try it yourself)

E: Jump to the tail of the word

B: Returns the beginning of the first word, or the beginning of the current word, and the opposite of W.

(Ah, skill 4 is not a skill, you can do it with ripe)

Tip 5:

In edit mode:

Open a file, want to jump to the tail immediately, how to do, use the down arrow to pull to the tail? Yes, it's too slow! Uppercase G, click, immediately to the tail, tail with the word "bot" Expression!

Want to get to the first? can also be fast, press the lowercase GG, yes, you see wrong, 2 lowercase g, you can quickly to the header.

Tip 5:

Your mouse pauses in the middle of a paragraph of text, you want to remove the front of the mouse, how to do? D0: Yes, it's D and 0.

Your mouse pauses in the middle of a paragraph of text, you want to remove the front of the mouse, how to do? d$: Yes, it's d and the dollar.

Want to delete the next word? DW: Just D and W

Want to delete the previous word? Db

Tip 5 is also in edit mode.

Tip 6:

In the last line mode, change mode Oh, little buddy!

What do I do if I want to delete lines 20th through 30th in the last line mode? The answer---------: 10,20d, yes, a colon, a 10, a comma, a 20, a D is ok.

Again example (in the last line mode):

: . , $d//delete from the current row to the last row

Tip 7:

Edit mode, copy command: yy//2 yy

In edit mode, Paste command: P (pasted below the cursor), upper case p above

Tip 8:

Or in edit mode:

You press DD, delete a line, press DD, and delete a line, right.

But suddenly want to return to the original appearance, how to do? Click U, yes, is a letter U, and then click U, the original deleted rows are all back. (the equivalent of CTRL + Z in office, so you understand)

But also want to restore to the state that has just been deleted, how to do? Simple? Press CTRL +r (equivalent to ctrl+y in office, and if you don't know ctrl+y in office, you can check it out)

Tip 9:

In the last line mode:

: . , $s #i#i#gi a colon, a dot, a comma, a $, a s, a #, an I, a #, an I, a #, a G, an I, description finished! It means to turn all lowercase i in this file into uppercase I

Tip 10:

In the last line mode:

:! LS/ETC/PASSWD Yes, this command means that you can view/etc/passwd,z and then press a return key without exiting Vim.

Vim Foundation, the foundation is not strong, shake

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: 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.