Vim configurations about Automatic Input

Source: Internet
Author: User
Tags imap

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>

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.