Open demon386 opened 6 years ago
Similarly, I wanted to enable it for >:<
so HTML tags are automatically expanded when I press Return inside an empty tag. But of course I didn't want to have the other delimitMate features for the >:<
pair.
I hacked the following together:
imap <silent> <expr> <CR> <SID>delimitMateCR()
imap <silent> <expr> <BS> <SID>delimitMateBS()
imap <silent> <expr> <C-h> <SID>delimitMateBS()
function! s:delimitMateCR()
call s:temporary_matchpairs()
return "\<Plug>delimitMateCR"
endfunction
function! s:delimitMateBS()
call s:temporary_matchpairs()
return "\<Plug>delimitMateBS"
endfunction
" Hack: Temporarily change delimitMate_matchpairs to make delimitMateCR and
" delimitMateBS work with more characters
function! s:temporary_matchpairs()
if exists('s:matchpairs_timer')
call timer_stop(s:matchpairs_timer)
endif
if !exists('b:delimitMate_matchpairs')
let b:delimitMate_matchpairs = g:delimitMate_matchpairs . ',>:<'
silent DelimitMateReload
endif
let s:matchpairs_timer = timer_start(100, {-> execute(['unlet! b:delimitMate_matchpairs', 'DelimitMateReload'])})
endfunction
This temporarily adds >:<
to b:delimitMate_matchpairs
when you press Return or Backspace.
Although this works, it would be nice if delimitMate had an option to specify the characters for delimitMateCR and delimitMateBS.
Hi, I want to be able to enable "delimitMate_expand_cr" only for curly braces {} but not parentheses (), while keeping other functions the same for the two.
Is this possible?