Vim Speed Introduction

Source: Internet
Author: User

This is called "Vim speed Introduction" article, really is the introduction of the speed, usually need is so much, so turn around. Here, by the way, a lot of things are not inclined to read the original in recent studies, so that they can quickly understand and enter the practical stage. Like Vim, you can't read all the documents.

This article talks about what not to say. Vim's commands are numerous and famous, in the face of the official document that pile of orders, it is easy to let the novice deterred. The purpose of this article is to give Vim's novice the minimal concepts and set of commands they need to be comfortable with vim. For beginners, only practical not to ask for accurate terminology. In addition to play vim powerful features also need to modify the configuration file, which is not covered in this article.

How to start and exit vim. The method is simple, you can see the VIM interface by tapping vim on the command line. Of course, you must have thought of it. Vim can be followed by several filenames as parameters, if the file does not exist The program will help you create a new one. Quit a bit of trouble, first click the ESC key, and then type ": Q" You can quit. If you open several files at once, a ": Q" can only close the currently active file, at which point you may need "QA". Of course, if you change a file is not saved, you will be prompted that the file is not saved, you can not quit now, so you have to save the exit ": Wq." What does it mean when you build a ": WQA"? Guess what. In addition to tell everyone a small secret, in fact, "ZZ" can also be useful, and it is very convenient to press.

Two. How to move the cursor. Forget what "HJKL" It is, you are just a beginner, those so-called masters of the Assumption for you are not exist, so remember, to move the cursor on top and bottom. Of course, there are four orders of the price is also very high, it is recommended to remember that is "$", "^" (moved to the end of the line and the beginning of), "GG", "G" (moved to the text and the end of the text). In addition, these commands can be repeated, such as 2, which is the next two lines. If you find that 2 has been entered into the text, press ESC and then press U and try "2" again. Isn't it cool to make a mistake instead of learning a new command u, a bit like Windows Ctrl+z. If you are a programmer, then teach you a quick jump from one bracket to another bracket you can press "%" on a bracket.

Three. How to edit content. To edit a file you first have to go into edit mode. Press "I" to enter edit mode. In edit mode you can move, enter, and delete as you would in Windows. Until you press ESC to enter the first mode. "A" and "I" are also similar, that is, to move the cursor, the Novice in fact completely can when it does not exist. But "a" I think is a very useful command, I was a rookie when the time to remember, it can quickly to the end of the line to insert. In fact, if you have mastered the things I said earlier, "A" and "$a" or "$i right" effect is the same, in fact, and "99999 right A" effect is also similar. If you're interested in looking at a Help file, you can find a whole bunch of commands about code movement and editing, to be honest, as a beginner, what I'm not talking about is that you can pretend that it doesn't exist at all.

Four. How to copy and paste. How to delete the content should have been mentioned in the previous section, but I think it's better to move over. In Windows everyone is very accustomed to "CTRL + C", "Ctrl + V", "ctrl+x" and a series of shortcut keys, under Vim a little bit different. First you need to know how to select an area. "V" is to select the current position, "V" is the current line, "Ctrl + V" is very magical, you can try to realize the difference with "V". Whichever way you use it, the program goes into visual mode, at which point you can use the move command to change the selected area. Select a block to delete it, directly press "D" on it, to copy it a bit of trouble to press "+y" (the plus sign requires input), cut is "+x" (the plus sign needs to be entered). Copy the words you Remember "P" and "P" one of them is OK. In addition, you can be directly "P" after an area "D". In addition, there are some high cost performance orders recommended by everyone to remember. "DD" deletes an entire line, "GGVG" can select all content (that is, gg-v-g). The key to Vim is to be flexible, such as when you want to select a pair of parentheses, you can "v%".

Five. How to manage Windows. ": SP filename", ": vs. FileName" When opening a file, the window is divided from the current window. (No new windows are available to open with ": E filename".) To move through the window using the ctrl+w+ arrow keys. ctrl-w-+,ctrl-w-,ctrl-w-<,ctrl-w-> can adjust the size of the window partition. New window uses "Ctrl+w n". Close the window using "Ctrl+w Q", in fact ": Q" also line, but the content is still in memory (the term is called buffer), not really turn off, want to really turn off please use ": Bd." There is a plug-in management Buferr very convenient, called MINIBUFEXPL, download after the copy to the ~/.vim/plugin/after the restart on it. (The Windows user must also be able to find the plugin directory in your gvim installation directory) For more details on this plugin you can query the relevant documents.

Six. How to get into the shell. This function is very important, write code compiled to compile, then quit Vim and compile is not not, but if I write wrong what think "u" words on the back of the powerless. So it is recommended that ": sh" enter the shell to perform the operation, and then ctrl-d can return vim.

Seven. How to find and replace. This is not words enough to speak clearly. Press ESC and press "/" and the text you want to search for can quickly find, "n" to the Next, "N" is the previous. More complex "s" commands please use ": h:s" to view Help.

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.