As the editor God, Vim's key ing function is very practical. When writing code, you often need to enter various parentheses, such as the parentheses of function parameters and the brackets under the array, the braces of the function body. To avoid missing brackets, you usually enter a pair of brackets before positioning them to add content. However, VIM is a pattern-based editor. It is troublesome to enter a pair of brackets and locate the brackets. You can either move it to the direction key, which may cause the hand to deviate from the main key area, either press <ESC> to switch to the command mode and then press I to enter the insert mode. Then the cursor is placed in brackets. This is too painful. With the help of Vim's key ing function, to solve this problem perfectly, you only need to do the following key ing:
Imap <m-(> () <ESC> I
Imap <m-[> [] <ESC> I
Imap <m-{>{}< ESC> I
In this way, you only need to press the meta key (usually the Alt key on the PC) at the same time while pressing the left bracket, You can automatically enter the right bracket and place the cursor in the brackets for the input.
When writing code, there are usually many similar things, such as the main function, you can also use one or two keys to automatically enter the main function and place the cursor at the position of the content to be added:
Imap <m-F> <m-m> int main () <enter >{< enter >}< ESC> O <tab> return 0; <ESC> O <tab>