Try to work around clipboard=unnamed

This commit is contained in:
Tim Pope 2007-02-11 18:09:45 +00:00
parent 90295205ad
commit c85cef48ca

View File

@ -335,10 +335,10 @@ function! s:insert(...) " {{{1
"if linemode "if linemode
"call setreg('"',substitute(getreg('"'),'^\s\+','',''),'c') "call setreg('"',substitute(getreg('"'),'^\s\+','',''),'c')
"endif "endif
if col('.') > col('$') if col('.') >= col('$')
norm! p`] norm! ""p`]
else else
norm! P`] norm! ""P`]
endif endif
call search('\r','bW') call search('\r','bW')
let @@ = reg_save let @@ = reg_save
@ -380,7 +380,7 @@ function! s:dosurround(...) " {{{1
let original = getreg('"') let original = getreg('"')
let otype = getregtype('"') let otype = getregtype('"')
call setreg('"',"") call setreg('"',"")
exe "norm d".(scount==1 ? "": scount)."i".char exe 'norm d'.(scount==1 ? "": scount)."i".char
"exe "norm vi".char."d" "exe "norm vi".char."d"
let keeper = getreg('"') let keeper = getreg('"')
let okeeper = keeper " for reindent below let okeeper = keeper " for reindent below
@ -436,7 +436,7 @@ function! s:dosurround(...) " {{{1
if newchar != "" if newchar != ""
call s:wrapreg('"',newchar) call s:wrapreg('"',newchar)
endif endif
silent exe "norm! ".pcmd.'`[' silent exe 'norm! ""'.pcmd.'`['
if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n' if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n'
call s:reindent() call s:reindent()
else else
@ -465,21 +465,27 @@ function! s:opfunc(type,...) " {{{1
if char == "" if char == ""
return s:beep() return s:beep()
endif endif
let reg = '"' if &cb =~ 'unnamed'
let reg = 's'
else
let reg = '"'
endif
let sel_save = &selection let sel_save = &selection
let &selection = "inclusive" let &selection = "inclusive"
let reg_save = getreg(reg) let reg_save = getreg(reg)
let reg_type = getregtype(reg) let reg_type = getregtype(reg)
let def_save = getreg('"')
let def_type = getregtype('"')
"call setreg(reg,"\n","c") "call setreg(reg,"\n","c")
let type = a:type let type = a:type
if a:type == "char" if a:type == "char"
silent exe 'norm! v`[o`]"'.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'
let type = 'V' let type = 'V'
elseif a:type ==# "v" || a:type ==# "V" || a:type ==# "\<C-V>" elseif a:type ==# "v" || a:type ==# "V" || a:type ==# "\<C-V>"
silent exe 'norm! gv"'.reg."y" silent exe 'norm! gv"'.reg.'y'
elseif a:type =~ '^\d\+$' elseif a:type =~ '^\d\+$'
let type = 'v' let type = 'v'
silent exe 'norm! ^v'.a:type.'$h"'.reg.'y' silent exe 'norm! ^v'.a:type.'$h"'.reg.'y'
@ -506,6 +512,7 @@ function! s:opfunc(type,...) " {{{1
call s:reindent() call s:reindent()
endif endif
call setreg(reg,reg_save,reg_type) call setreg(reg,reg_save,reg_type)
call setreg('"',def_save,def_type)
let &selection = sel_save let &selection = sel_save
endfunction endfunction