Xin Xing helps you with the movement mode required by programmers in Section 3 of vim. Xin Xing vim
First of all, it is worth mentioning that the pdf version of my vim tutorial has been completed. You can download it. Here is the download of csdn: csdn. If the download fails on the left, you can also enter the following address in the browser to download: http://download.csdn.net/detail/xinguimeng/7714213, of course, if you are a loyal user of Baidu network disk, you can also use Baidu network disk, I also synchronized upload to Baidu network disk, below: Baidu Network Disk download, if the address is Hung, you can enter in the browser: http://pan.baidu.com/s/1sj9CLXz to download.
We have introduced how to move the cursor in command mode, but it is not enough for programmers. It is mainly because of the special requirements of programmers. vim developers are also programmers. Naturally, why do programmers bother programmers? But what are the requirements of programmers?
* ************************************ Special offer for programmers *** ****************************
1. when we use C language-like programming, we often get dizzy and swollen by the nested brackets. Don't worry, vim, an artifact, has helped us figure out a solution, that is, we only need to move the cursor to a bracket and then execute the % command in command mode, it automatically positions the cursor on the corresponding parentheses. Both parentheses, braces, and brackets are applicable. If the command is not matched, most of them are incorrectly programmed. In fact, we do not need to execute the % command. When we move to a part of the brackets, the other part will naturally be highlighted.
2. sometimes we need to highlight the line number. We can use: set number to display the line number. Note that in insert mode, we first use the ESc key to return to the command mode, and then use: enter the baseline mode and enter set number to display the row number. set nonumber will undisplay the row number.
3. sometimes we write a program. If it is a c, cpp, or other compiled program, it is often said that an error occurs when it is compiled into a certain line. Because our program is usually hundreds of lines, if you find it with the scroll wheel and eyes of the mouse, it is undoubtedly very laborious. In vim, we can use the G command to solve it, G indicates "go". For example, if we want to reach 200 rows, We can enter GB in command mode.
4. It is worth noting that G here needs to be written in uppercase. Generally, I like to press shifit and then press g. The jump to other lines is similar, so I will not personally execute the command.
5. sometimes, we don't know the specific number of lines, but just want to see a rough part of the code, we can use the % command, such as 50% to jump to about 50% of the file, of course, you can change the value 50 to another number to indicate different positions.
* ************************************ Search * ********************************
1. Our programmers often need to view the functions of a function. How can we quickly find it through the variable name and function name?
2. Of course, we will learn several more powerful methods later. However, it is undoubtedly the quickest way to use/add a word. Then we can use a combination of numbers and n to locate the first few words, you can also use the n command to locate the next one.
3. if we simply want to look at a function name, for example, the function name is xin, we can use/\ <xin \>, where \ <indicates matching the beginning of a word, and \> indicates matching the end of a word.
* ************************** Regular Expression *********** ************************
1. That's right. I think most programmers use regular expressions. As for how familiar they are, it is related to their work direction. But at least they should understand it.
2. As we have mentioned before, we use delimiters to only search for the variable or function name of xin. Yes, we can also use/^ xin $ to match only one xin word in this row.
3. We can use. To match any character. For example, x. g can match xinxing, xig, or xiig.
4. Some people may say that what if I want to match xin? That is, if the first three characters are xin and the last one is a vertex, we can use a backslash to escape it, that is, xin \. To represent xin.
******************** ***********
1. I don't know how readers feel.
2. But vim does provide good support to programmers, which is also a charm that vim and emacs can firmly attract programmers.
3. Xin Xing vim, looking forward to your attention.