From c956b65a04a24f72d2a810964253d3fb6ed878b6 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Sat, 11 Feb 2017 23:46:41 -0500 Subject: [PATCH] Support surround character multiplier (Fixes #213) Example: ysiw3" --- plugin/surround.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugin/surround.vim b/plugin/surround.vim index 46f3252..f38fb8b 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -35,6 +35,9 @@ endfunction function! s:inputreplacement() let c = s:getchar() + while c =~ '^\d\+$' + let c .= s:getchar() + endwhile if c == " " let c .= s:getchar() endif @@ -139,6 +142,11 @@ function! s:wrap(string,char,type,removed,special) endif let pairs = "b()B{}r[]a<>" let extraspace = "" + 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 = ' ' @@ -270,6 +278,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