Changeset 320 for lang/vim/surround/trunk
- Timestamp:
- 10/01/07 04:55:35 (16 months ago)
- Location:
- lang/vim/surround/trunk
- Files:
-
- 2 modified
-
doc/surround.txt (modified) (2 diffs, 1 prop)
-
plugin/surround.vim (modified) (9 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
lang/vim/surround/trunk/doc/surround.txt
- Property svn:keywords set to Id
r318 r320 3 3 Author: Tim Pope <vimNOSPAM@tpope.info> *surround-author* 4 4 License: Same terms as Vim itself (see |license|) 5 6 NOTE: This is a modified version of surround.vim. See |surround-changelog| 7 for the detail of the difference from the original version. 5 8 6 9 This plugin is only available if 'compatible' is not set. … … 222 225 It would be nice if |.| would work to repeat an operation. 223 226 227 228 229 230 CHANGELOG *surround-changelog* 231 232 2007-10-01T00:25:20+09:00 kana <http://nicht.s8.xrea.com/> 233 234 - Support user-defined surrounding objects (|surround-customizing|) as 235 |surround-targets|. The original version (1.26) does not support 236 this feature. 237 238 BUGS: [count] is not supported yet. 239 240 241 242 224 243 vim:tw=78:ts=8:ft=help:norl: -
lang/vim/surround/trunk/plugin/surround.vim
- Property svn:keywords set to Id
r318 r320 2 2 " Author: Tim Pope <vimNOSPAM@tpope.info> 3 3 " GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim 4 " $Id : surround.vim,v 1.26 2007-07-31 14:20:47 tpope Exp$4 " $Id$ 5 5 " 6 6 " See surround.txt for help. This can be accessed by doing … … 173 173 endif 174 174 let idx = stridx(pairs,newchar) 175 let user_defined_object = s:get_user_defined_object(newchar) 175 176 if newchar == ' ' 176 177 let before = '' 177 178 let after = '' 178 elseif exists("b:surround_".char2nr(newchar)) 179 let all = s:process(b:surround_{char2nr(newchar)}) 180 let before = s:extractbefore(all) 181 let after = s:extractafter(all) 182 elseif exists("g:surround_".char2nr(newchar)) 183 let all = s:process(g:surround_{char2nr(newchar)}) 179 elseif len(user_defined_object) 180 let all = s:process(user_defined_object) 184 181 let before = s:extractbefore(all) 185 182 let after = s:extractafter(all) … … 389 386 endfunction " }}}1 390 387 391 function! s:dosurround(...) " {{{1 388 function! s:dosurround(...) "{{{1 389 " ([target-surrounding-object-char, [new-surrounding-object-char]]) 390 " adjust arguments "{{{2 392 391 let scount = v:count1 393 392 let char = (a:0 ? a:1 : s:inputtarget()) … … 414 413 endif 415 414 endif 415 416 " save and initialize some values "{{{2 416 417 let cb_save = &clipboard 417 418 set clipboard-=unnamed … … 420 421 let otype = getregtype('"') 421 422 call setreg('"',"") 423 424 " move the target text range into @@, then delete surroudings "{{{2 422 425 let strcount = (scount == 1 ? "" : scount) 423 if char == '/' 426 let user_defined_object = s:get_user_defined_object(char) 427 if len(user_defined_object) " FIXME: [count] is not supported yet 428 let all = s:process(user_defined_object) 429 let before = s:extractbefore(all) 430 let after = s:extractafter(all) 431 call s:search_literally(before, 'bcW') 432 normal! v 433 call s:search_literally(after, 'ceW') 434 normal! d 435 elseif char == '/' 424 436 exe 'norm '.strcount.'[/d'.strcount.']/' 425 437 else … … 436 448 let oldline = getline('.') 437 449 let oldlnum = line('.') 438 if char ==# "p" 450 if len(user_defined_object) 451 call setreg('"', before.after, '') 452 let keeper = keeper[len(before):] 453 let keeper = keeper[:-(len(after)+1)] 454 elseif char ==# "p" 439 455 "let append = matchstr(keeper,'\n*\%$') 440 456 "let keeper = substitute(keeper,'\n*\%$','','') … … 482 498 let pcmd = "p" 483 499 endif 500 501 " surround @@ new objects "{{{2 484 502 call setreg('"',keeper,regtype) 485 503 if newchar != "" 486 504 call s:wrapreg('"',newchar) 487 505 endif 506 507 " put the result into the original position, then reindent "{{{2 488 508 silent exe 'norm! ""'.pcmd.'`[' 489 509 if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n' … … 494 514 silent norm! cc 495 515 endif 516 517 " restore the original value, set some values for later use "{{{2 496 518 call setreg('"',removed,regtype) 497 519 let s:lastdel = removed … … 583 605 endif 584 606 endfunction " }}}1 607 608 " Misc. functions "{{{1 609 function! s:search_literally(pattern, flags) 610 return search(s:literalize_pattern(a:pattern), a:flags) 611 endfunction 612 613 function! s:literalize_pattern(pattern) 614 return '\V'.substitute(a:pattern, '\', '\\', 'g') 615 endfunction 616 617 function! s:get_user_defined_object(char) 618 if exists("b:surround_".char2nr(a:char)) 619 return b:surround_{char2nr(a:char)} 620 elseif exists("g:surround_".char2nr(a:char)) 621 return g:surround_{char2nr(a:char)} 622 else 623 return '' 624 endif 625 endfunction 626 "}}}1 585 627 586 628 nnoremap <silent> <Plug>Dsurround :<C-U>call <SID>dosurround(<SID>inputtarget())<CR>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)