jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.09k stars 373 forks source link

Two-character pairs #101

Open TxHawks opened 9 years ago

TxHawks commented 9 years ago

I'm trying to configure the plugin to handle a pair of two characters, so that:

input:    {%
output: {%|%}

I have this in my vimrc:

au Filetype twig,html.twig let b:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`', '{%':'%}'}

but the output I get is {%%|}.

Am I missing something?

jiangmiao commented 9 years ago

Currently auto-pairs doesn't support two character pairs.

adriaanzon commented 8 years ago

I wanted something similar, but for blade:

input:  {!!<space>
output: {!! | !!}

So I put the following abbreviation in my vimrc:

au FileType blade iabbrev <buffer> {!! {!! !!<del><left><left><left>

In your case, that would be:

au FileType twig,html.twig iabbrev <buffer> {% {% %<del><left><left>

This works, but keep in mind that you need to type a space after the abbreviation.

After I put this in my vimrc, I noticed the syntax highlighting in my vimrc was being messed up because of the two braces in the abbreviation. To fix this, I simply put this on the next line:

"}}