Sinsing to play with you the third section of vim the programmer needs to move the way

Source: Internet
Author: User

In the second section I first worth mentioning is that my Vim tutorial PDF version has been written, you can download, here is csdn: csdn download , if the left side of the hanging off, you can also enter the following address in the browser below to download:/http download.csdn.net/detail/xinguimeng/7714213, of course, if you are Baidu network disk loyal users, you can also help Baidu network disk, I also synced to Baidu Network disk, as follows: Baidu network disk download , if the address hung , you can enter it in the browser: http://pan.baidu.com/s/1sj9CLXz to download.

Before we described how to move the cursor in command mode, but for the programmer is not enough, mainly because the needs of programmers is a bit special, and the developer of Vim is a programmer, naturally, programmers are difficult to embarrass programmers, but, what is the programmer need is particularly important?

Programmer's Special *******************************

1. When we use the C language to programming, often will be layered nested in the size of the parentheses to get dizzy brain swelling, don't worry, as the artifact of Vim has helped us to think of a solution, that is, we just need to move the cursor to a certain parenthesis, and then execute the% command in command mode, It will automatically position the cursor to the corresponding parenthesis, whether it is a parenthesis, curly braces, or brackets, are applicable. If the command is executed and does not match, the program is probably not written correctly. In fact, we don't have to execute the% command, and when we move to part of the brackets, the other part is naturally highlighted.

2. Sometimes we need to highlight line numbers, we can use: Set number to display line numbers, note that in insert mode, we first use the ESC key back to command mode, and then use: Enter the bottom line mode, and then enter the set number, so that the line numbers can be displayed, and: Set Nonumber will suppress the line number.

3. Sometimes we write programs, if it is C, CPP, and other compiled programs, often say compile to a line when the error occurs, because our program easily hundreds of lines, if it is by the mouse wheel and eyes to find it, it is very laborious, under VIM, we can use the G command to fix it, here the G is "Go" means "go, arrive", for example, we think of up to 200 lines, then you can enter 200G in command mode to do so.

4. It is worth noting that the G here is required to be capitalized, usually I. Like to hold the Shifit and then press the G key to OK. It's similar to jumping to other lines, so I don't make orders myself.

5. Sometimes, we do not know the exact number of lines, just want to see the approximate part of the code, we can use the% command, such as 50% to jump to the file about 50% of the place, of course, the 50 can also be replaced by other numbers, to represent a variety of different locations.


Search *********************************

1. We programmers often need to look at the function of a function and so on, then how quickly through the variable name and function name to find it?

2. Of course, we will learn several more powerful methods behind us. However, it is undoubtedly the quickest way to use/Add a word form here, and then we can use the combination of numbers plus n to locate the first few words, or we can directly use the N command to navigate to the next.

3. If we simply want to look at a function name, such as the function called Xin, then we can use/\<xin\> to do, where \< means to match the beginning of a word, and \> means to match the end of a word.


Regular Expression ***********************************

1. Yes, I think most programmers will have regular expressions, as for how familiar they are with the direction of their work, but at least it should be understood.

2. We said before with delimiters to search only xin this variable or function name, yes, we can also use/^xin$ to match only one Xin word in this line of the case.

3. We can use. To match any character, such as X.G can match to Xinxing, can also match to Xig, and can match to Xiig.

4. Then someone might say, if I want to match Xin. That is, the first three characters are Xin, the latter character is a point, then we can use a backslash to escape it, that is, xin\. to represent Xin.



Answer the reader to ask *******************************

1. I don't know what it's like to read this.

2. However, VIM does provide good support for programmers, which is one of the great charms of vim and Emacs to attract programmers.

3. Sinsing vim, looking forward to your attention.

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.