我的vim 自動執行個體括弧函數

來源:互聯網
上載者:User

標籤:

不廢話,直接上代碼:

 1 """"""""""""""""""""""""""""""""""""""""""" 2 "自動執行個體括弧 3 """"""""""""""""""""""""""""""""""""""""""" 4 ""inoremap ( ()<ESC>i 5 inoremap ( <c-r>=OpenPair(‘(‘,‘)‘)<CR> 6 inoremap ) <c-r>=ClosePair(‘)‘)<CR> 7 inoremap { {}<ESC>i 8 inoremap } <c-r>=ClosePair(‘}‘)<CR> 9 inoremap [ []<ESC>i10 inoremap ] <c-r>=ClosePair(‘]‘)<CR>11 inoremap " <c-r>=QuoteDelim(‘"‘)<CR>12 inoremap ‘ <c-r>=QuoteDelim("‘")<CR>13 14 function! OpenPair(char1,char2)15     let line = getline(‘.‘)16     let col = col(‘.‘)17     if col(‘$‘) == col18         return a:char1 . a:char2. "\<Left>"19     else20         return a:char1 21     endif22 endfunction23 24 function! ClosePair(char)25     if getline(‘.‘)[col(‘.‘) - 1] == a:char26         return "\<Right>"27     else28         return a:char29     endif30 endfunction31 32 function! QuoteDelim(char)33     let line = getline(‘.‘)34     let col = col(‘.‘)35     if line[col - 2] == "\\"36         "Inserting a quoted quotation mark into the string37         return a:char38     elseif line[col - 1] == a:char39         "Escaping out of the string40         return "\<Right>"41     else42         "Starting a string43         return a:char.a:char."\<Esc>i"44     endif45 endf

 

我的vim 自動執行個體括弧函數

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.