Skip to content

Commit

Permalink
Support surround character multiplier (Fixes tpope#213)
Browse files Browse the repository at this point in the history
Example: ysiw3"
  • Loading branch information
shanesmith committed Feb 12, 2017
1 parent f15d450 commit b97bb84
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugin/surround.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ endfunction

function! s:inputreplacement()
let c = s:getchar()
while c =~ '^\d\+$'
let c .= s:getchar()
endwhile
if c == " " || c == "\\"
let c .= s:getchar()
endif
Expand Down Expand Up @@ -140,6 +143,11 @@ function! s:wrap(string,char,type,removed,special)
let pairs = "b()B{}r[]a<>"
let extraspace = ""
let prepend = ""
let multi = 1
if newchar =~ '^\d\+'
let multi = matchstr(newchar, '^\d\+')
let newchar = substitute(newchar,'^\d\+','','')
endif
if newchar =~ '^ '
let newchar = strpart(newchar,1)
let extraspace = ' '
Expand Down Expand Up @@ -280,6 +288,8 @@ function! s:wrap(string,char,type,removed,special)
endif
endif
endif
let before = repeat(before, multi)
let after = repeat(after, multi)
if type ==# 'V'
let before = initspaces.before
endif
Expand Down

0 comments on commit b97bb84

Please sign in to comment.