From 3181a6525d85bb7c291be495879b070836447d90 Mon Sep 17 00:00:00 2001 From: Miseran Date: Fri, 27 Mar 2015 23:11:55 +0100 Subject: [PATCH] Allow using {}, [] and <> for function surround If the function name ends in "{", "[" or "<", use that as a delimiter instead of "(". --- plugin/surround.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/surround.vim b/plugin/surround.vim index 82b016e..54e0cc5 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -224,8 +224,15 @@ function! s:wrap(string,char,type,removed,special) let fnc = input('function: ') if fnc != "" let s:input = fnc."\" - let before = substitute(fnc,'($','','').'(' - let after = ')' + let lastchar = strpart(fnc,strlen(fnc)-1,1) + let lastidx = stridx(pairs,lastchar) + if lastidx >= 0 && lastidx % 3 == 1 + let before = fnc + let after = strpart(pairs,lastidx+1,1) + else + let before = fnc.'(' + let after = ')' + endif if newchar ==# 'F' let before .= ' ' let after = ' ' . after