Skip to content

Commit

Permalink
Allow using {}, [] and <> for function surround
Browse files Browse the repository at this point in the history
If the function name ends in "{", "[" or "<", use that as a delimiter
instead of "(".
  • Loading branch information
miseran committed Jul 7, 2017
1 parent 772ab95 commit 3ff5c2c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugin/surround.vim
Expand Up @@ -224,8 +224,15 @@ function! s:wrap(string,char,type,removed,special)
let fnc = input('function: ')
if fnc != ""
let s:input = fnc."\<CR>"
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
Expand Down

0 comments on commit 3ff5c2c

Please sign in to comment.