Bump to Vim 7

This commit is contained in:
Tim Pope 2011-08-29 01:22:25 -04:00
parent 2e600335db
commit 21d7375644
2 changed files with 22 additions and 35 deletions

View File

@ -100,9 +100,7 @@ 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
possible targets are based closely on the |text-objects| provided by Vim. possible targets are based closely on the |text-objects| provided by Vim.
In order for a target to work, the corresponding text object must be All targets are currently just one character.
supported in the version of Vim used (Vim 7 adds several text objects, and
thus is highly recommended). All targets are currently just one character.
Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves
and their counterparts. If the opening mark is used, contained whitespace is and their counterparts. If the opening mark is used, contained whitespace is

View File

@ -3,7 +3,7 @@
" Version: 1.90 " Version: 1.90
" GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim " GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim
if exists("g:loaded_surround") || &cp if exists("g:loaded_surround") || &cp || v:version < 700
finish finish
endif endif
let g:loaded_surround = 1 let g:loaded_surround = 1
@ -21,10 +21,10 @@ endfunction
function! s:inputtarget() function! s:inputtarget()
let c = s:getchar() let c = s:getchar()
while c =~ '^\d\+$' while c =~ '^\d\+$'
let c = c . s:getchar() let c .= s:getchar()
endwhile endwhile
if c == " " if c == " "
let c = c . s:getchar() let c .= s:getchar()
endif endif
if c =~ "\<Esc>\|\<C-C>\|\0" if c =~ "\<Esc>\|\<C-C>\|\0"
return "" return ""
@ -36,7 +36,7 @@ endfunction
function! s:inputreplacement() function! s:inputreplacement()
let c = s:getchar() let c = s:getchar()
if c == " " if c == " "
let c = c . s:getchar() let c .= s:getchar()
endif endif
if c =~ "\<Esc>" || c =~ "\<C-C>" if c =~ "\<Esc>" || c =~ "\<C-C>"
return "" return ""
@ -75,19 +75,9 @@ function! s:extractafter(str)
endif endif
endfunction endfunction
function! s:repeat(str,count)
let cnt = a:count
let str = ""
while cnt > 0
let str = str . a:str
let cnt = cnt - 1
endwhile
return str
endfunction
function! s:fixindent(str,spc) function! s:fixindent(str,spc)
let str = substitute(a:str,'\t',s:repeat(' ',&sw),'g') let str = substitute(a:str,'\t',repeat(' ',&sw),'g')
let spc = substitute(a:spc,'\t',s:repeat(' ',&sw),'g') let spc = substitute(a:spc,'\t',repeat(' ',&sw),'g')
let str = substitute(str,'\(\n\|\%^\).\@=','\1'.spc,'g') let str = substitute(str,'\(\n\|\%^\).\@=','\1'.spc,'g')
if ! &et if ! &et
let str = substitute(str,'\s\{'.&ts.'\}',"\t",'g') let str = substitute(str,'\s\{'.&ts.'\}',"\t",'g')
@ -97,15 +87,14 @@ endfunction
function! s:process(string) function! s:process(string)
let i = 0 let i = 0
while i < 7 for i in range(7)
let i = i + 1
let repl_{i} = '' let repl_{i} = ''
let m = matchstr(a:string,nr2char(i).'.\{-\}\ze'.nr2char(i)) let m = matchstr(a:string,nr2char(i).'.\{-\}\ze'.nr2char(i))
if m != '' if m != ''
let m = substitute(strpart(m,1),'\r.*','','') let m = substitute(strpart(m,1),'\r.*','','')
let repl_{i} = input(substitute(m,':\s*$','','').': ') let repl_{i} = input(substitute(m,':\s*$','','').': ')
endif endif
endwhile endfor
let s = "" let s = ""
let i = 0 let i = 0
while i < strlen(a:string) while i < strlen(a:string)
@ -113,7 +102,7 @@ function! s:process(string)
if char2nr(char) < 8 if char2nr(char) < 8
let next = stridx(a:string,char,i+1) let next = stridx(a:string,char,i+1)
if next == -1 if next == -1
let s = s . char let s .= char
else else
let insertion = repl_{char2nr(char)} let insertion = repl_{char2nr(char)}
let subs = strpart(a:string,i+1,next-i-1) let subs = strpart(a:string,i+1,next-i-1)
@ -124,13 +113,13 @@ function! s:process(string)
let r = stridx(sub,"\r") let r = stridx(sub,"\r")
let insertion = substitute(insertion,strpart(sub,0,r),strpart(sub,r+1),'') let insertion = substitute(insertion,strpart(sub,0,r),strpart(sub,r+1),'')
endwhile endwhile
let s = s . insertion let s .= insertion
let i = next let i = next
endif endif
else else
let s = s . char let s .= char
endif endif
let i = i + 1 let i += 1
endwhile endwhile
return s return s
endfunction endfunction
@ -199,7 +188,7 @@ function! s:wrap(string,char,type,...)
endif endif
if newchar == "\<C-T>" || newchar == "," if newchar == "\<C-T>" || newchar == ","
if type ==# "v" || type ==# "V" if type ==# "v" || type ==# "V"
let before = before . "\n\t" let before .= "\n\t"
endif endif
if type ==# "v" if type ==# "v"
let after = "\n". after let after = "\n". after
@ -210,7 +199,7 @@ function! s:wrap(string,char,type,...)
" LaTeX " LaTeX
let env = input('\begin{') let env = input('\begin{')
let env = '{' . env let env = '{' . env
let env = env . s:closematch(env) let env .= s:closematch(env)
echo '\begin'.env echo '\begin'.env
if env != "" if env != ""
let before = '\begin'.env let before = '\begin'.env
@ -222,7 +211,7 @@ function! s:wrap(string,char,type,...)
let before = substitute(fnc,'($','','').'(' let before = substitute(fnc,'($','','').'('
let after = ')' let after = ')'
if newchar ==# 'F' if newchar ==# 'F'
let before = before . ' ' let before .= ' '
let after = ' ' . after let after = ' ' . after
endif endif
endif endif
@ -249,14 +238,14 @@ function! s:wrap(string,char,type,...)
let after = initspaces.after let after = initspaces.after
endif endif
if keeper !~ '\n$' && after !~ '^\n' if keeper !~ '\n$' && after !~ '^\n'
let keeper = keeper . "\n" let keeper .= "\n"
elseif keeper =~ '\n$' && after =~ '^\n' elseif keeper =~ '\n$' && after =~ '^\n'
let after = strpart(after,1) let after = strpart(after,1)
endif endif
if before !~ '\n\s*$' if before !~ '\n\s*$'
let before = before . "\n" let before .= "\n"
if special if special
let before = before . "\t" let before .= "\t"
endif endif
endif endif
endif endif
@ -300,7 +289,7 @@ function! s:insert(...) " {{{1
let char = s:inputreplacement() let char = s:inputreplacement()
while char == "\<CR>" || char == "\<C-S>" while char == "\<CR>" || char == "\<C-S>"
" TODO: use total count for additional blank lines " TODO: use total count for additional blank lines
let linemode = linemode + 1 let linemode += 1
let char = s:inputreplacement() let char = s:inputreplacement()
endwhile endwhile
if char == "" if char == ""