auto-pairs.vim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. " Insert or delete brackets, parens, quotes in pairs.
  2. " Maintainer: JiangMiao <jiangfriend@gmail.com>
  3. " Contributor: camthompson
  4. " Last Change: 2019-02-02
  5. " Version: 2.0.0
  6. " Homepage: http://www.vim.org/scripts/script.php?script_id=3599
  7. " Repository: https://github.com/jiangmiao/auto-pairs
  8. " License: MIT
  9. if exists('g:AutoPairsLoaded') || &cp
  10. finish
  11. end
  12. let g:AutoPairsLoaded = 1
  13. if !exists('g:AutoPairs')
  14. let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"}
  15. end
  16. " default pairs base on filetype
  17. func! AutoPairsDefaultPairs()
  18. if exists('b:autopairs_defaultpairs')
  19. return b:autopairs_defaultpairs
  20. end
  21. let r = copy(g:AutoPairs)
  22. let allPairs = {
  23. \ 'vim': {'\v^\s*\zs"': ''},
  24. \ 'rust': {'\w\zs<': '>', '&\zs''': ''},
  25. \ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}
  26. \ }
  27. for [filetype, pairs] in items(allPairs)
  28. if &filetype == filetype
  29. for [open, close] in items(pairs)
  30. let r[open] = close
  31. endfor
  32. end
  33. endfor
  34. let b:autopairs_defaultpairs = r
  35. return r
  36. endf
  37. if !exists('g:AutoPairsMapBS')
  38. let g:AutoPairsMapBS = 1
  39. end
  40. " Map <C-h> as the same BS
  41. if !exists('g:AutoPairsMapCh')
  42. let g:AutoPairsMapCh = 1
  43. end
  44. if !exists('g:AutoPairsMapCR')
  45. let g:AutoPairsMapCR = 1
  46. end
  47. if !exists('g:AutoPairsWildClosedPair')
  48. let g:AutoPairsWildClosedPair = ''
  49. end
  50. if !exists('g:AutoPairsMapSpace')
  51. let g:AutoPairsMapSpace = 1
  52. end
  53. if !exists('g:AutoPairsCenterLine')
  54. let g:AutoPairsCenterLine = 1
  55. end
  56. if !exists('g:AutoPairsShortcutToggle')
  57. let g:AutoPairsShortcutToggle = '<M-p>'
  58. end
  59. if !exists('g:AutoPairsShortcutFastWrap')
  60. let g:AutoPairsShortcutFastWrap = '<M-e>'
  61. end
  62. if !exists('g:AutoPairsMoveCharacter')
  63. let g:AutoPairsMoveCharacter = "()[]{}\"'"
  64. end
  65. if !exists('g:AutoPairsShortcutJump')
  66. let g:AutoPairsShortcutJump = '<M-n>'
  67. endif
  68. " Fly mode will for closed pair to jump to closed pair instead of insert.
  69. " also support AutoPairsBackInsert to insert pairs where jumped.
  70. if !exists('g:AutoPairsFlyMode')
  71. let g:AutoPairsFlyMode = 0
  72. endif
  73. " When skipping the closed pair, look at the current and
  74. " next line as well.
  75. if !exists('g:AutoPairsMultilineClose')
  76. let g:AutoPairsMultilineClose = 1
  77. endif
  78. " Work with Fly Mode, insert pair where jumped
  79. if !exists('g:AutoPairsShortcutBackInsert')
  80. let g:AutoPairsShortcutBackInsert = '<M-b>'
  81. endif
  82. if !exists('g:AutoPairsSmartQuotes')
  83. let g:AutoPairsSmartQuotes = 1
  84. endif
  85. " 7.4.849 support <C-G>U to avoid breaking '.'
  86. " Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3
  87. " Vim note: https://github.com/vim/vim/releases/tag/v7.4.849
  88. if v:version > 704 || v:version == 704 && has("patch849")
  89. let s:Go = "\<C-G>U"
  90. else
  91. let s:Go = ""
  92. endif
  93. let s:Left = s:Go."\<LEFT>"
  94. let s:Right = s:Go."\<RIGHT>"
  95. " unicode len
  96. func! s:ulen(s)
  97. return len(split(a:s, '\zs'))
  98. endf
  99. func! s:left(s)
  100. return repeat(s:Left, s:ulen(a:s))
  101. endf
  102. func! s:right(s)
  103. return repeat(s:Right, s:ulen(a:s))
  104. endf
  105. func! s:delete(s)
  106. return repeat("\<DEL>", s:ulen(a:s))
  107. endf
  108. func! s:backspace(s)
  109. return repeat("\<BS>", s:ulen(a:s))
  110. endf
  111. func! s:getline()
  112. let line = getline('.')
  113. let pos = col('.') - 1
  114. let before = strpart(line, 0, pos)
  115. let after = strpart(line, pos)
  116. let afterline = after
  117. if g:AutoPairsMultilineClose
  118. let n = line('$')
  119. let i = line('.')+1
  120. while i <= n
  121. let line = getline(i)
  122. let after = after.' '.line
  123. if !(line =~ '\v^\s*$')
  124. break
  125. end
  126. let i = i+1
  127. endwhile
  128. end
  129. return [before, after, afterline]
  130. endf
  131. " split text to two part
  132. " returns [orig, text_before_open, open]
  133. func! s:matchend(text, open)
  134. let m = matchstr(a:text, '\V'.a:open.'\v$')
  135. if m == ""
  136. return []
  137. end
  138. return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m]
  139. endf
  140. " returns [orig, close, text_after_close]
  141. func! s:matchbegin(text, close)
  142. let m = matchstr(a:text, '^\V'.a:close)
  143. if m == ""
  144. return []
  145. end
  146. return [a:text, m, strpart(a:text, len(m), len(a:text)-len(m))]
  147. endf
  148. " add or delete pairs base on g:AutoPairs
  149. " AutoPairsDefine(addPairs:dict[, removeOpenPairList:list])
  150. "
  151. " eg:
  152. " au FileType html let b:AutoPairs = AutoPairsDefine({'<!--' : '-->'}, ['{'])
  153. " add <!-- --> pair and remove '{' for html file
  154. func! AutoPairsDefine(pairs, ...)
  155. let r = AutoPairsDefaultPairs()
  156. if a:0 > 0
  157. for open in a:1
  158. unlet r[open]
  159. endfor
  160. end
  161. for [open, close] in items(a:pairs)
  162. let r[open] = close
  163. endfor
  164. return r
  165. endf
  166. func! AutoPairsInsert(key)
  167. if !b:autopairs_enabled
  168. return a:key
  169. end
  170. let b:autopairs_saved_pair = [a:key, getpos('.')]
  171. let [before, after, afterline] = s:getline()
  172. " Ignore auto close if prev character is \
  173. if before[-1:-1] == '\'
  174. return a:key
  175. end
  176. " check open pairs
  177. for [open, close, opt] in b:AutoPairsList
  178. let ms = s:matchend(before.a:key, open)
  179. let m = matchstr(afterline, '^\v\s*\zs\V'.close)
  180. if len(ms) > 0
  181. " process the open pair
  182. " remove inserted pair
  183. " eg: if the pairs include < > and <!-- -->
  184. " when <!-- is detected the inserted pair < > should be clean up
  185. let target = ms[1]
  186. let openPair = ms[2]
  187. if len(openPair) == 1 && m == openPair
  188. break
  189. end
  190. let bs = ''
  191. let del = ''
  192. while len(before) > len(target)
  193. let found = 0
  194. " delete pair
  195. for [o, c, opt] in b:AutoPairsList
  196. let os = s:matchend(before, o)
  197. if len(os) && len(os[1]) < len(target)
  198. " any text before openPair should not be deleted
  199. continue
  200. end
  201. let cs = s:matchbegin(afterline, c)
  202. if len(os) && len(cs)
  203. let found = 1
  204. let before = os[1]
  205. let afterline = cs[2]
  206. let bs = bs.s:backspace(os[2])
  207. let del = del.s:delete(cs[1])
  208. break
  209. end
  210. endfor
  211. if !found
  212. " delete charactor
  213. let ms = s:matchend(before, '\v.')
  214. if len(ms)
  215. let before = ms[1]
  216. let bs = bs.s:backspace(ms[2])
  217. end
  218. end
  219. endwhile
  220. return bs.del.openPair.close.s:left(close)
  221. end
  222. endfor
  223. " check close pairs
  224. for [open, close, opt] in b:AutoPairsList
  225. if close == ''
  226. continue
  227. end
  228. if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && opt['key'] == a:key
  229. " the close pair is in the same line
  230. let m = matchstr(afterline, '^\v\s*\V'.close)
  231. if m != ''
  232. if before =~ '\V'.open.'\v\s*$' && m[0] =~ '\v\s'
  233. " remove the space we inserted if the text in pairs is blank
  234. return "\<DEL>".s:right(m[1:])
  235. else
  236. return s:right(m)
  237. end
  238. end
  239. let m = matchstr(after, '^\v\s*\zs\V'.close)
  240. if m != ''
  241. if a:key == g:AutoPairsWildClosedPair || opt['multiline']
  242. if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
  243. normal! ddk$
  244. end
  245. call search(m, 'We')
  246. return "\<Right>"
  247. else
  248. break
  249. end
  250. end
  251. end
  252. endfor
  253. " Fly Mode, and the key is closed-pairs, search closed-pair and jump
  254. if g:AutoPairsFlyMode && a:key =~ '\v[\}\]\)]'
  255. if search(a:key, 'We')
  256. return "\<Right>"
  257. endif
  258. endif
  259. return a:key
  260. endf
  261. func! AutoPairsDelete()
  262. if !b:autopairs_enabled
  263. return "\<BS>"
  264. end
  265. let [before, after, ig] = s:getline()
  266. for [open, close, opt] in b:AutoPairsList
  267. let b = matchstr(before, '\V'.open.'\v\s?$')
  268. let a = matchstr(after, '^\v\s*\V'.close)
  269. if b != '' && a != ''
  270. if b[-1:-1] == ' '
  271. if a[0] == ' '
  272. return "\<BS>\<DELETE>"
  273. else
  274. return "\<BS>"
  275. end
  276. end
  277. return s:backspace(b).s:delete(a)
  278. end
  279. endfor
  280. return "\<BS>"
  281. " delete the pair foo[]| <BS> to foo
  282. for [open, close, opt] in b:AutoPairsList
  283. let m = s:matchend(before, '\V'.open.'\v\s*'.'\V'.close.'\v$')
  284. if len(m) > 0
  285. return s:backspace(m[2])
  286. end
  287. endfor
  288. return "\<BS>"
  289. endf
  290. " Fast wrap the word in brackets
  291. func! AutoPairsFastWrap()
  292. let c = @"
  293. normal! x
  294. let [before, after, ig] = s:getline()
  295. if after[0] =~ '\v[\{\[\(\<]'
  296. normal! %
  297. normal! p
  298. else
  299. for [open, close, opt] in b:AutoPairsList
  300. if close == ''
  301. continue
  302. end
  303. if after =~ '^\s*\V'.open
  304. call search(close, 'We')
  305. normal! p
  306. let @" = c
  307. return ""
  308. end
  309. endfor
  310. if after[1:1] =~ '\v\w'
  311. normal! e
  312. normal! p
  313. else
  314. normal! p
  315. end
  316. end
  317. let @" = c
  318. return ""
  319. endf
  320. func! AutoPairsJump()
  321. call search('["\]'')}]','W')
  322. endf
  323. func! AutoPairsMoveCharacter(key)
  324. let c = getline(".")[col(".")-1]
  325. let escaped_key = substitute(a:key, "'", "''", 'g')
  326. return "\<DEL>\<ESC>:call search("."'".escaped_key."'".")\<CR>a".c."\<LEFT>"
  327. endf
  328. func! AutoPairsBackInsert()
  329. let pair = b:autopairs_saved_pair[0]
  330. let pos = b:autopairs_saved_pair[1]
  331. call setpos('.', pos)
  332. return pair
  333. endf
  334. func! AutoPairsReturn()
  335. if b:autopairs_enabled == 0
  336. return ''
  337. end
  338. let b:autopairs_return_pos = 0
  339. let before = getline(line('.')-1)
  340. let [ig, ig, afterline] = s:getline()
  341. let cmd = ''
  342. for [open, close, opt] in b:AutoPairsList
  343. if close == ''
  344. continue
  345. end
  346. if before =~ '\V'.open.'\v\s*$' && afterline =~ '^\s*\V'.close
  347. let b:autopairs_return_pos = line('.')
  348. if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
  349. " Recenter before adding new line to avoid replacing line content
  350. let cmd = "zz"
  351. end
  352. " If equalprg has been set, then avoid call =
  353. " https://github.com/jiangmiao/auto-pairs/issues/24
  354. if &equalprg != ''
  355. return "\<ESC>".cmd."O"
  356. endif
  357. " conflict with javascript and coffee
  358. " javascript need indent new line
  359. " coffeescript forbid indent new line
  360. if &filetype == 'coffeescript' || &filetype == 'coffee'
  361. return "\<ESC>".cmd."k==o"
  362. else
  363. return "\<ESC>".cmd."=ko"
  364. endif
  365. end
  366. endfor
  367. return ''
  368. endf
  369. func! AutoPairsSpace()
  370. if !b:autopairs_enabled
  371. return "\<SPACE>"
  372. end
  373. let [before, after, ig] = s:getline()
  374. for [open, close, opt] in b:AutoPairsList
  375. if close == ''
  376. continue
  377. end
  378. if before =~ '\V'.open.'\v$' && after =~ '^\V'.close
  379. if close =~ '\v^[''"`]$'
  380. return "\<SPACE>"
  381. else
  382. return "\<SPACE>\<SPACE>".s:Left
  383. end
  384. end
  385. endfor
  386. return "\<SPACE>"
  387. endf
  388. func! AutoPairsMap(key)
  389. " | is special key which separate map command from text
  390. let key = a:key
  391. if key == '|'
  392. let key = '<BAR>'
  393. end
  394. let escaped_key = substitute(key, "'", "''", 'g')
  395. " use expr will cause search() doesn't work
  396. execute 'inoremap <buffer> <silent> '.key." <C-R>=AutoPairsInsert('".escaped_key."')<CR>"
  397. endf
  398. func! AutoPairsToggle()
  399. if b:autopairs_enabled
  400. let b:autopairs_enabled = 0
  401. echo 'AutoPairs Disabled.'
  402. else
  403. let b:autopairs_enabled = 1
  404. echo 'AutoPairs Enabled.'
  405. end
  406. return ''
  407. endf
  408. func! s:sortByLength(i1, i2)
  409. return len(a:i2[0])-len(a:i1[0])
  410. endf
  411. func! AutoPairsInit()
  412. let b:autopairs_loaded = 1
  413. if !exists('b:autopairs_enabled')
  414. let b:autopairs_enabled = 1
  415. end
  416. if !exists('b:AutoPairs')
  417. let b:AutoPairs = AutoPairsDefaultPairs()
  418. end
  419. if !exists('b:AutoPairsMoveCharacter')
  420. let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter
  421. end
  422. let b:autopairs_return_pos = 0
  423. let b:autopairs_saved_pair = [0, 0]
  424. let b:AutoPairsList = []
  425. " buffer level map pairs keys
  426. " n - do not map the first charactor of closed pair to close key
  427. " m - close key jumps through multi line
  428. " s - close key jumps only in the same line
  429. for [open, close] in items(b:AutoPairs)
  430. let o = open[-1:-1]
  431. let c = close[0]
  432. let opt = {'mapclose': 1, 'multiline':1}
  433. let opt['key'] = c
  434. if o == c
  435. let opt['multiline'] = 0
  436. end
  437. let m = matchlist(close, '\v(.*)//(.*)$')
  438. if len(m) > 0
  439. if m[2] =~ 'n'
  440. let opt['mapclose'] = 0
  441. end
  442. if m[2] =~ 'm'
  443. let opt['multiline'] = 1
  444. end
  445. if m[2] =~ 's'
  446. let opt['multiline'] = 0
  447. end
  448. let ks = matchlist(m[2], '\vk(.)')
  449. if len(ks) > 0
  450. let opt['key'] = ks[1]
  451. let c = opt['key']
  452. end
  453. let close = m[1]
  454. end
  455. call AutoPairsMap(o)
  456. if o != c && c != '' && opt['mapclose']
  457. call AutoPairsMap(c)
  458. end
  459. let b:AutoPairsList += [[open, close, opt]]
  460. endfor
  461. " sort pairs by length, longer pair should have higher priority
  462. let b:AutoPairsList = sort(b:AutoPairsList, "s:sortByLength")
  463. for item in b:AutoPairsList
  464. let [open, close, opt] = item
  465. if open == "'" && open == close
  466. let item[0] = '\v(^|\W)\zs'''
  467. end
  468. endfor
  469. for key in split(b:AutoPairsMoveCharacter, '\s*')
  470. let escaped_key = substitute(key, "'", "''", 'g')
  471. execute 'inoremap <silent> <buffer> <M-'.key."> <C-R>=AutoPairsMoveCharacter('".escaped_key."')<CR>"
  472. endfor
  473. " Still use <buffer> level mapping for <BS> <SPACE>
  474. if g:AutoPairsMapBS
  475. " Use <C-R> instead of <expr> for issue #14 sometimes press BS output strange words
  476. execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
  477. end
  478. if g:AutoPairsMapCh
  479. execute 'inoremap <buffer> <silent> <C-h> <C-R>=AutoPairsDelete()<CR>'
  480. endif
  481. if g:AutoPairsMapSpace
  482. " Try to respect abbreviations on a <SPACE>
  483. let do_abbrev = ""
  484. if v:version == 703 && has("patch489") || v:version > 703
  485. let do_abbrev = "<C-]>"
  486. endif
  487. execute 'inoremap <buffer> <silent> <SPACE> '.do_abbrev.'<C-R>=AutoPairsSpace()<CR>'
  488. end
  489. if g:AutoPairsShortcutFastWrap != ''
  490. execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
  491. end
  492. if g:AutoPairsShortcutBackInsert != ''
  493. execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutBackInsert.' <C-R>=AutoPairsBackInsert()<CR>'
  494. end
  495. if g:AutoPairsShortcutToggle != ''
  496. " use <expr> to ensure showing the status when toggle
  497. execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
  498. execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
  499. end
  500. if g:AutoPairsShortcutJump != ''
  501. execute 'inoremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' <ESC>:call AutoPairsJump()<CR>a'
  502. execute 'noremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()<CR>'
  503. end
  504. if &keymap != ''
  505. let l:imsearch = &imsearch
  506. let l:iminsert = &iminsert
  507. let l:imdisable = &imdisable
  508. execute 'setlocal keymap=' . &keymap
  509. execute 'setlocal imsearch=' . l:imsearch
  510. execute 'setlocal iminsert=' . l:iminsert
  511. if l:imdisable
  512. execute 'setlocal imdisable'
  513. else
  514. execute 'setlocal noimdisable'
  515. end
  516. end
  517. endf
  518. func! s:ExpandMap(map)
  519. let map = a:map
  520. let map = substitute(map, '\(<Plug>\w\+\)', '\=maparg(submatch(1), "i")', 'g')
  521. let map = substitute(map, '\(<Plug>([^)]*)\)', '\=maparg(submatch(1), "i")', 'g')
  522. return map
  523. endf
  524. func! AutoPairsTryInit()
  525. if exists('b:autopairs_loaded')
  526. return
  527. end
  528. " for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
  529. "
  530. " vim-endwise doesn't support <Plug>AutoPairsReturn
  531. " when use <Plug>AutoPairsReturn will cause <Plug> isn't expanded
  532. "
  533. " supertab doesn't support <SID>AutoPairsReturn
  534. " when use <SID>AutoPairsReturn will cause Duplicated <CR>
  535. "
  536. " and when load after vim-endwise will cause unexpected endwise inserted.
  537. " so always load AutoPairs at last
  538. " Buffer level keys mapping
  539. " comptible with other plugin
  540. if g:AutoPairsMapCR
  541. if v:version == 703 && has('patch32') || v:version > 703
  542. " VIM 7.3 supports advancer maparg which could get <expr> info
  543. " then auto-pairs could remap <CR> in any case.
  544. let info = maparg('<CR>', 'i', 0, 1)
  545. if empty(info)
  546. let old_cr = '<CR>'
  547. let is_expr = 0
  548. else
  549. let old_cr = info['rhs']
  550. let old_cr = s:ExpandMap(old_cr)
  551. let old_cr = substitute(old_cr, '<SID>', '<SNR>' . info['sid'] . '_', 'g')
  552. let is_expr = info['expr']
  553. let wrapper_name = '<SID>AutoPairsOldCRWrapper73'
  554. endif
  555. else
  556. " VIM version less than 7.3
  557. " the mapping's <expr> info is lost, so guess it is expr or not, it's
  558. " not accurate.
  559. let old_cr = maparg('<CR>', 'i')
  560. if old_cr == ''
  561. let old_cr = '<CR>'
  562. let is_expr = 0
  563. else
  564. let old_cr = s:ExpandMap(old_cr)
  565. " old_cr contain (, I guess the old cr is in expr mode
  566. let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V<C-R>'
  567. " The old_cr start with " it must be in expr mode
  568. let is_expr = is_expr || old_cr =~ '\v^"'
  569. let wrapper_name = '<SID>AutoPairsOldCRWrapper'
  570. end
  571. end
  572. if old_cr !~ 'AutoPairsReturn'
  573. if is_expr
  574. " remap <expr> to `name` to avoid mix expr and non-expr mode
  575. execute 'inoremap <buffer> <expr> <script> '. wrapper_name . ' ' . old_cr
  576. let old_cr = wrapper_name
  577. end
  578. " Always silent mapping
  579. execute 'inoremap <script> <buffer> <silent> <CR> '.old_cr.'<SID>AutoPairsReturn'
  580. end
  581. endif
  582. call AutoPairsInit()
  583. endf
  584. " Always silent the command
  585. inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
  586. imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
  587. au BufEnter * :call AutoPairsTryInit()