diff --git a/plugin/surround.vim b/plugin/surround.vim index 85e96e8..f397361 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -90,16 +90,15 @@ " vmap s Vsurround " vmap S VSurround " < -" Finally, there is an experimental insert mode mapping on . Beware that -" this won't work on terminals with flow control (if you accidentally freeze -" your terminal, use to unfreeze it). The mapping inserts the specified -" surroundings and puts the cursor between them. If, immediately after -" and before the replacement, a second or carriage return is pressed, -" the prefix, cursor, and suffix will be placed on three separate lines. If -" this is a common use case you can add a mapping for it as well. -" > -" imap Isurround -" < +" *i_CTRL-G_s* *i_CTRL-G_S* +" Finally, there is an experimental insert mode mapping on s and . +" Beware that the latter won't work on terminals with flow control (if you +" accidentally freeze your terminal, use to unfreeze it). The mapping +" inserts the specified surroundings and puts the cursor between them. If, +" immediately after the mapping and before the replacement, a second or +" carriage return is pressed, the prefix, cursor, and suffix will be placed on +" three separate lines. S (not s) also exhibits this behavior. +" " Targets: *surround-targets* " " The |ds| and |cs| commands both take a target as their first argument. The @@ -638,7 +637,7 @@ function! s:opfunc(type,...) " {{{1 let reg_type = getregtype(reg) let type = a:type if a:type == "char" - silent exe 'norm! `[v`]"'.reg."y" + silent exe 'norm! v`[o`]"'.reg."y" let type = 'v' elseif a:type == "line" silent exe 'norm! `[V`]"'.reg."y" @@ -652,9 +651,9 @@ function! s:opfunc(type,...) " {{{1 return s:beep() endif let keeper = getreg(reg) - if type == "v" - let append = matchstr(keeper,'\s*$') - let keeper = substitute(keeper,'\s*$','','') + if type == "v" && a:type != "v" + let append = matchstr(keeper,'\_s\@Isurround","i") && !mapcheck("","i") imap Isurround endif + imap s Isurround + imap S ISurround "Implemented internally instead "imap ISurround endif