Skip to content

Commit 3181a65

Browse files
author
Miseran
committed
Allow using {}, [] and <> for function surround
If the function name ends in "{", "[" or "<", use that as a delimiter instead of "(".
1 parent 772ab95 commit 3181a65

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plugin/surround.vim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,15 @@ function! s:wrap(string,char,type,removed,special)
224224
let fnc = input('function: ')
225225
if fnc != ""
226226
let s:input = fnc."\<CR>"
227-
let before = substitute(fnc,'($','','').'('
228-
let after = ')'
227+
let lastchar = strpart(fnc,strlen(fnc)-1,1)
228+
let lastidx = stridx(pairs,lastchar)
229+
if lastidx >= 0 && lastidx % 3 == 1
230+
let before = fnc
231+
let after = strpart(pairs,lastidx+1,1)
232+
else
233+
let before = fnc.'('
234+
let after = ')'
235+
endif
229236
if newchar ==# 'F'
230237
let before .= ' '
231238
let after = ' ' . after

0 commit comments

Comments
 (0)