VI Vim Bracket Auto indent settings and explanations

Source: Internet
Author: User
Tags imap

The first thing to do is to set the automatic indentation before you set the parentheses automatically, by adding the following statement to the ~/.VIMRC file:

set Autoindentset shiftwidth=4set TabStop=4set Expandtabset smarttab

The parentheses in the VI editor cannot be indented automatically, and I find that using IMAP is possible, and after the experiment, when the indentation is set to the above, my curly brace indentation is set to:

IMAP {<cr> {<cr>}<esc>o

It means to map curly braces to line breaks in curly braces when you enter them. Enter the curly braces to connect the uppercase O, think, replace the content is you can use a manual line of input, again, according to this idea, if you want the brackets and parentheses auto-complete and the cursor moved to the middle of the parentheses, You can use the following mapping methods:

IMAP [[]<esc>Iimap (()<esc>i

Think about, [] plus I is not your own operation when you can use an input method, according to this idea, we can also map:

IMAP [[]<left>IMAP ()<LEFT>

This looks more intuitive, enter an opening parenthesis, equivalent to enter the full parenthesis and then move the cursor to the left one character

And then what is IMAP mean, IMAP means the mapping operation in the Insert mode, the mapping rules of the above settings only work in the input mode, there is no such mapping rule in other modes there will be no substitution of this input, map has several mapping modes, want to set a pattern mapping rules , you can use the mapping command in this mode, such as command mode CMAP, Normal mode nmap, about the map mode can refer to this blog http://haoxiang.org/2011/09/vim-modes-and-mappin/

VI Vim Bracket Auto indent settings and explanations

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.