S in blockwise visual mode trims trailing space
This commit is contained in:
parent
07a90d26f3
commit
6916c71a00
@ -1,5 +1,6 @@
|
|||||||
" surround.vim - Surroundings
|
" surround.vim - Surroundings
|
||||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
||||||
|
" GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim
|
||||||
" $Id$
|
" $Id$
|
||||||
" Help is below; it may be read here. Alternatively, after the plugin is
|
" Help is below; it may be read here. Alternatively, after the plugin is
|
||||||
" installed and running, :call SurroundHelp() to install a proper help file.
|
" installed and running, :call SurroundHelp() to install a proper help file.
|
||||||
@ -79,7 +80,8 @@
|
|||||||
"
|
"
|
||||||
" An "S" in visual mode (*vS*) behaves similarly but always places the
|
" An "S" in visual mode (*vS*) behaves similarly but always places the
|
||||||
" surroundings on separate lines. Additionally, the surrounded text is
|
" surroundings on separate lines. Additionally, the surrounded text is
|
||||||
" indented.
|
" indented. In blockwise visual mode, using "S" instead of "s" instead skips
|
||||||
|
" trailing whitespace.
|
||||||
"
|
"
|
||||||
" Note that "s" and "S" already have valid meaning in visual mode, but it is
|
" Note that "s" and "S" already have valid meaning in visual mode, but it is
|
||||||
" identical to "c". If you have muscle memory for "s" and would like to use a
|
" identical to "c". If you have muscle memory for "s" and would like to use a
|
||||||
@ -443,7 +445,6 @@ function! s:wrap(string,char,type,...)
|
|||||||
if type ==# 'V'
|
if type ==# 'V'
|
||||||
let before = initspaces.before
|
let before = initspaces.before
|
||||||
endif
|
endif
|
||||||
let g:initspc = initspaces
|
|
||||||
if before =~ '\n\s*\%$'
|
if before =~ '\n\s*\%$'
|
||||||
if type ==# 'v'
|
if type ==# 'v'
|
||||||
let keeper = initspaces.keeper
|
let keeper = initspaces.keeper
|
||||||
@ -458,7 +459,8 @@ function! s:wrap(string,char,type,...)
|
|||||||
" Really we should be iterating over the buffer
|
" Really we should be iterating over the buffer
|
||||||
let repl = substitute(before,'[\\~]','\\&','g').'\1'.substitute(after,'[\\~]','\\&','g')
|
let repl = substitute(before,'[\\~]','\\&','g').'\1'.substitute(after,'[\\~]','\\&','g')
|
||||||
let repl = substitute(repl,'\n',' ','g')
|
let repl = substitute(repl,'\n',' ','g')
|
||||||
let keeper = substitute(keeper."\n",'\(.\{-\}\)\n',repl.'\n','g')
|
let keeper = substitute(keeper."\n",'\(.\{-\}\)\('.(special ? '\s\{-\}' : '').'\n\)',repl.'\n','g')
|
||||||
|
let keeper = substitute(keeper,'\n\%$','','')
|
||||||
else
|
else
|
||||||
let keeper = before.extraspace.keeper.extraspace.after
|
let keeper = before.extraspace.keeper.extraspace.after
|
||||||
endif
|
endif
|
||||||
@ -467,7 +469,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:wrapreg(reg,char,...)
|
function! s:wrapreg(reg,char,...)
|
||||||
let orig = getreg(a:reg)
|
let orig = getreg(a:reg)
|
||||||
let type = getregtype(a:reg)
|
let type = substitute(getregtype(a:reg),'\d\+$','','')
|
||||||
let special = a:0 ? a:1 : 0
|
let special = a:0 ? a:1 : 0
|
||||||
let new = s:wrap(orig,a:char,type,special)
|
let new = s:wrap(orig,a:char,type,special)
|
||||||
call setreg(a:reg,new,type)
|
call setreg(a:reg,new,type)
|
||||||
@ -652,7 +654,7 @@ function! s:opfunc(type,...) " {{{1
|
|||||||
call setreg(reg,keeper,type)
|
call setreg(reg,keeper,type)
|
||||||
call s:wrapreg(reg,char,a:0)
|
call s:wrapreg(reg,char,a:0)
|
||||||
silent exe 'norm! gv'.(reg == '"' ? '' : '"' . reg).'p`['
|
silent exe 'norm! gv'.(reg == '"' ? '' : '"' . reg).'p`['
|
||||||
if type == 'V' || getreg(reg) =~ '\n'
|
if type == 'V' || (getreg(reg) =~ '\n' && type == 'v')
|
||||||
call s:reindent()
|
call s:reindent()
|
||||||
endif
|
endif
|
||||||
call setreg(reg,reg_save,reg_type)
|
call setreg(reg,reg_save,reg_type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user