<C-G>s in insert mode; fixed bug in ys when selection starts at end of line

This commit is contained in:
Tim Pope 2006-11-07 23:03:52 +00:00
parent 1e4cf6f319
commit b31015ee87

View File

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