My vim auto-instance parentheses function

Source: Internet
Author: User

No nonsense, directly on the code:

1 """""""""""""""""""""""""""""""""""""""""""2 "Auto Instance Brackets3 """""""""""""""""""""""""""""""""""""""""""4 ""Inoremap (() <ESC>I5Inoremap (<c-r>=openpair ('(',')') <CR>6Inoremap) <c-r>=closepair (')') <CR>7Inoremap {{}<esc>I8Inoremap} <c-r>=closepair ('}') <CR>9Inoremap [[]<esc>ITenInoremap] <c-r>=closepair (']') <CR> OneInoremap"<c-r>=quotedelim ('"') <CR> AInoremap'<c-r>=quotedelim ("' ") <CR> -  -function!Openpair (CHAR1,CHAR2) theLet line = Getline ('.') -Let col = col ('.') -     ifCol'$') ==Col -         returnA:char1. A:char2."\<left>" +     Else -         returna:char1 + endif A endfunction at  -function! Closepair (Char) -     ifGetline'.') [Col ('.') -1] = = A:Char -         return "\<right>" -     Else -         returnA:Char in endif - endfunction to  +function! Quotedelim (Char) -Let line = Getline ('.') theLet col = col ('.') *     ifLine[col-2] =="\\" $         "Inserting a quoted quotation mark into the stringPanax Notoginseng         returnA:Char -ElseIf Line[col-1] = = A:Char the         "escaping out of the string +         return "\<right>" A     Else the         "starting a string +         returnA:CharAChar."\<esc>i" - endif $Endf

My vim auto-instance parentheses function

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.