In the past, all the auto-completion functions of VIM were downloaded from the Internet when needed, and copied to their own vimrc. I didn't know what it meant, the results show that many of the methods found to be auto-complete are quite different. Some prefer to use auto-wrap when the braces are fully filled, and others prefer to use auto-indent when the braces are fully filled, let's take a few minutes to understand how to write these configurations by ourselves. Why not?
* ******************************** Key ing ****** ************************
1. first, we need to distinguish between nnoremap and inoremap. The first is the ing that takes effect in normal mode, and the second is the ing that takes effect in insert mode, we generally need to use it in the insert mode. Therefore, we usually use inoremap. So what is ing?
2. The so-called ing means that when we press a key, it will execute another part of the content. For example, we use map T: Q !, When we press t in command mode and press enter, We will exit Vim. In addition to map, NMAP also indicates that it takes effect in normal mode and IMAP takes effect in insert mode, vmap takes effect in visual mode and map takes effect in all modes.
3. Set a ing using Map <ing key> <ing Key sequence>. If we want to unmap, run the unmap command to clear all mappings and run the mapclear command.
4. We usually write these mappings into the configuration file vimrc. Such a write takes effect permanently.
************ **********************
1. Any character that can be directly displayed can be directly entered, but there are two exceptions, namely, backslash and <, because we use backlash to indicate escape, and
2. The backslash is represented by two backslashes, or <bslash>
3. <must be expressed by \ <or <lt>.
4. <key> indicates a special key. We will introduce some common special keys:
<ESC> escape key,
<C-G> Ctrl-G key
<Up> indicates moving the cursor up
<C-leftmouse> CTRL and left-click
<Space> Space
<Tab> table key
<CR> is the Enter key.
* ********************** Start to write our own Automatic completion *********** ************
1. First, I will provide my auto-completion format. First, it is worth noting that this code is written in _ vimrc. The following is a careful analysis:
"Auto-completion: inoremap () <ESC> I: inoremap) <c-r> = closepair (') <CR>: inoremap {<CR> <CR >}< ESC> 0ki <tab>: inoremap} <c-r> = closepair ('}') <CR> function closepair (char) if Getline ('. ') [col ('. ')-1] = A: charreturn "\ <right>" else return a: Char endif ENDF
2. here: inoremap indicates the ing in the insert mode. First, the second line (that is, write () first, and then return to the command mode using ESC, then run I to enter the insert mode.
3. when I enter {, check its command. First, enter {, then <CR> to enter the line feed, then a line feed, and then enter }, then run ESC to return to the command mode. Then run the 0 command to return to the beginning of the line. Then run the K Command to move the mouse over the previous line, and then run the I command to enter the insert mode, then we use <tab> to insert a tab.
4. Of course, I only define auto-Completions for parentheses and braces. I didn't use auto-Completions for brackets. You can modify them by yourself.
5. Vim is quite comfortable to use at this point. After all, it feels very free.
6. Spread programming knowledge, revitalize Chinese software, Xin Xing, and look forward to your attention.