Changeset 338 for lang/vim/surround/trunk
- Timestamp:
- 10/02/07 16:12:51 (16 months ago)
- Files:
-
- 1 modified
-
lang/vim/surround/trunk/plugin/surround.vim (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/vim/surround/trunk/plugin/surround.vim
r336 r338 1 " surround.vim - Surrounding text objects 2 " Author: Tim Pope <vimNOSPAM@tpope.info> 3 " ModifiedBy: kana <http://nicht.s8.xrea.com> 4 " BasedOn: Id: surround.vim,v 1.26 2007-07-31 14:20:47 tpope Exp 5 " License: same as the original one, i.e., same as Vim itself. 6 " $Id$ "{{{1 7 " Original Header "{{{2 8 " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1 9 " surround.vim - Surroundings 2 10 " Author: Tim Pope <vimNOSPAM@tpope.info> … … 10 18 " 11 19 " Licensed under the same terms as Vim itself. 12 13 " ============================================================================20 " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 21 " "}}}2 14 22 15 23 " Exit quickly when: … … 19 27 finish 20 28 endif 21 let g:loaded_surround = 122 29 23 30 let s:cpo_save = &cpo 24 31 set cpo&vim 25 32 26 " Input functions {{{1 33 34 35 36 " Implementation "{{{1 37 " Input functions "{{{2 27 38 28 39 function! s:getchar() … … 72 83 endfunction 73 84 74 " }}}1 75 76 " Wrapping functions {{{1 85 86 " Wrapping functions "{{{2 77 87 78 88 function! s:extractbefore(str) … … 330 340 call setreg(a:reg,new,type) 331 341 endfunction 332 " }}}1 333 334 function! s:insert(...) " {{{1342 343 344 function! s:insert(...) "{{{2 335 345 " Optional argument causes the result to appear on 3 lines, not 1 336 346 "call inputsave() … … 378 388 let &clipboard = cb_save 379 389 return "\<Del>" 380 endfunction " }}}1 381 382 function! s:reindent() " {{{1 390 endfunction 391 392 393 function! s:reindent() "{{{2 383 394 if exists("b:surround_indent") ? b:surround_indent : (exists("g:surround_indent") && g:surround_indent) 384 395 silent norm! '[='] 385 396 endif 386 endfunction " }}}1 387 388 function! s:dosurround(...) "{{{1 397 endfunction 398 399 400 function! s:dosurround(...) "{{{2 389 401 " ([target-surrounding-object-char, [new-surrounding-object-char]]) 390 " adjust arguments "{{{ 2402 " adjust arguments "{{{3 391 403 let scount = v:count1 392 404 let char = (a:0 ? a:1 : s:inputtarget()) … … 414 426 endif 415 427 416 " save and initialize some values "{{{ 2428 " save and initialize some values "{{{3 417 429 let cb_save = &clipboard 418 430 set clipboard-=unnamed … … 422 434 call setreg('"',"") 423 435 424 " move the target text range into @@, then delete surroudings "{{{ 2436 " move the target text range into @@, then delete surroudings "{{{3 425 437 let strcount = (scount == 1 ? "" : scount) 426 438 let user_defined_object = s:get_user_defined_object(char) … … 499 511 endif 500 512 501 " surround @@ new objects "{{{ 2513 " surround @@ new objects "{{{3 502 514 call setreg('"',keeper,regtype) 503 515 if newchar != "" … … 505 517 endif 506 518 507 " put the result into the original position, then reindent "{{{ 2519 " put the result into the original position, then reindent "{{{3 508 520 silent exe 'norm! ""'.pcmd.'`[' 509 521 if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n' … … 515 527 endif 516 528 517 " restore the original value, set some values for later use "{{{ 2529 " restore the original value, set some values for later use "{{{3 518 530 call setreg('"',removed,regtype) 519 531 let s:lastdel = removed 520 532 let &clipboard = cb_save 521 endfunction " }}}1 522 523 function! s:changesurround() " {{{1 533 endfunction 534 535 536 function! s:changesurround() "{{{2 524 537 let a = s:inputtarget() 525 538 if a == "" … … 531 544 endif 532 545 call s:dosurround(a,b) 533 endfunction " }}}1 534 535 function! s:opfunc(type,...) " {{{1 546 endfunction 547 548 549 function! s:opfunc(type,...) "{{{2 536 550 let char = s:inputreplacement() 537 551 if char == "" … … 588 602 function! s:opfunc2(arg) 589 603 call s:opfunc(a:arg,1) 590 endfunction " }}}1 591 592 function! s:closematch(str) " {{{1 604 endfunction 605 606 607 function! s:closematch(str) "{{{2 593 608 " Close an open (, {, [, or < on the command line. 594 609 let tail = matchstr(a:str,'.[^\[\](){}<>]*$') … … 604 619 return "" 605 620 endif 606 endfunction " }}}1621 endfunction 607 622 608 " Misc. functions "{{{1 623 624 " Misc. functions "{{{2 625 609 626 function! s:search_literally(pattern, flags) 610 627 return search(s:literalize_pattern(a:pattern), a:flags) … … 634 651 endif 635 652 endfunction 636 "}}}1 653 654 655 656 657 " Key Mappings "{{{1 637 658 638 659 nnoremap <silent> <Plug>Dsurround :<C-U>call <SID>dosurround(<SID>inputtarget())<CR> … … 679 700 endif 680 701 702 703 704 705 " Misc. "{{{1 706 681 707 let &cpo = s:cpo_save 682 708 709 let g:loaded_surround = 1 710 711 712 713 714 " __END__ "{{{1 683 715 " vim:set ft=vim sw=4 sts=4 et:
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)