Changeset 9179 for dotfiles/vim/ishihara

Show
Ignore:
Timestamp:
04/09/08 15:44:03 (7 years ago)
Author:
ishihara
Message:

dotfiles/vim/ishihara: GLVS, update plugins

ack.vim: 7796+
Align: 33/39
autocomplpop.vim: 2.3.1
fuzzyfinder.vim: 2.6
snippetsEmu: 1.2.3 / 1.2
YankRing?.vim: 2.2 (3.0 は snippetsEmu とバッティングするので戻した)

Location:
dotfiles/vim/ishihara
Files:
41 added
2 removed
8 modified

Legend:

Unmodified
Added
Removed
  • dotfiles/vim/ishihara/.vim/autoload/Align.vim

    r7191 r9179  
    11" Align: tool to align multiple fields based on one or more separators 
    22"   Author:             Charles E. Campbell, Jr. 
    3 "   Date:               Dec 20, 2007 
     3"   Date:               Mar 06, 2008 
    44"   Version:    33 
    55" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim 
     
    767767 
    768768  " construct an AlignCtrlStack entry 
     769  if !exists("s:AlignSep") 
     770   let s:AlignSep= '' 
     771  endif 
    769772  let s:AlignCtrlStack_{s:AlignCtrlStackQty}= s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle.s:AlignSep 
    770773"  call Decho("AlignPush: AlignCtrlStack_".s:AlignCtrlStackQty."<".s:AlignCtrlStack_{s:AlignCtrlStackQty}.">") 
     
    877880" --------------------------------------------------------------------- 
    878881" s:QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{1 
    879 " However, <q-args> doesn't split at all, so this one returns a list 
    880 " with splits at all whitespace (only!), plus a leading length-of-list. 
     882" However, <q-args> doesn't split at all, so this function returns a list 
     883" of arguments which has been: 
     884"   * split at whitespace 
     885"   * unless inside "..."s.  One may escape characters with a backslash inside double quotes. 
     886" along with a leading length-of-list. 
     887" 
     888"   Examples:   %Align "\""   will align on "s 
     889"               %Align " "    will align on spaces 
     890" 
    881891" The resulting list:  qarglist[0] corresponds to a:0 
    882892"                      qarglist[i] corresponds to a:{i} 
    883893fun! s:QArgSplitter(qarg) 
    884894"  call Dfunc("s:QArgSplitter(qarg<".a:qarg.">)") 
    885   let qarglist   = split(a:qarg) 
     895 
     896  if a:qarg =~ '".*"' 
     897   " handle "..." args, which may include whitespace 
     898   let qarglist = [] 
     899   let args     = a:qarg 
     900"   call Decho("handle quoted arguments: args<".args.">") 
     901   while args != "" 
     902        let iarg   = 0 
     903        let arglen = strlen(args) 
     904"       call Decho("args[".iarg."]<".args[iarg]."> arglen=".arglen) 
     905        " find index to first not-escaped '"' 
     906        while args[iarg] != '"' && iarg < arglen 
     907         if args[iarg] == '\' 
     908          let args= strpart(args,1) 
     909         endif 
     910         let iarg= iarg + 1 
     911        endwhile 
     912"       call Decho("args<".args."> iarg=".iarg." arglen=".arglen) 
     913 
     914        if iarg > 0 
     915         " handle left of quote or remaining section 
     916"        call Decho("handle left of quote or remaining section") 
     917         if args[iarg] == '"' 
     918          let qarglist= qarglist + split(strpart(args,0,iarg-1)) 
     919         else 
     920          let qarglist= qarglist + split(strpart(args,0,iarg)) 
     921         endif 
     922         let args    = strpart(args,iarg) 
     923         let arglen  = strlen(args) 
     924 
     925        elseif iarg < arglen && args[0] == '"' 
     926         " handle "quoted" section 
     927"        call Decho("handle quoted section") 
     928         let iarg= 1 
     929         while args[iarg] != '"' && iarg < arglen 
     930          if args[iarg] == '\' 
     931           let args= strpart(args,1) 
     932          endif 
     933          let iarg= iarg + 1 
     934         endwhile 
     935"        call Decho("args<".args."> iarg=".iarg." arglen=".arglen) 
     936         if args[iarg] == '"' 
     937          call add(qarglist,strpart(args,1,iarg-1)) 
     938          let args= strpart(args,iarg+1) 
     939         else 
     940          let qarglist = qarglist + split(args) 
     941          let args     = "" 
     942         endif 
     943        endif 
     944"       call Decho("qarglist".string(qarglist)." iarg=".iarg." args<".args.">") 
     945   endwhile 
     946 
     947  else 
     948   " split at all whitespace 
     949   let qarglist= split(a:qarg) 
     950  endif 
     951 
    886952  let qarglistlen= len(qarglist) 
    887953  let qarglist   = insert(qarglist,qarglistlen) 
  • dotfiles/vim/ishihara/.vim/doc/Align.txt

    r7191 r9179  
    1 *align.txt*     The Alignment Tool                      Dec 20, 2007 
     1*align.txt*     The Alignment Tool                      Mar 06, 2008 
    22 
    33Author:  Charles E. Campbell, Jr.  <NdrOchip@ScampbellPfamily.AbizM> 
    44          (remove NOSPAM from Campbell's email first) 
    5 Copyright: (c) 2004-2007 by Charles E. Campbell, Jr.    *Align-copyright* 
     5Copyright: (c) 2004-2008 by Charles E. Campbell, Jr.    *Align-copyright* 
    66           The VIM LICENSE applies to Align.vim, AlignMaps.vim, and Align.txt 
    77           (see |copyright|) except use "Align and AlignMaps" instead of "Vim" 
    8            No warranty, express or implied.  Use At-Your-Own-Risk. 
     8           NO WARRANTY, EXPRESS OR IMPLIED.  USE AT-YOUR-OWN-RISK. 
    99 
    1010============================================================================== 
    11 1. Contents                                     *align* *align-contents* {{{1 
     111. Contents                                     *align* *align-contents* 
    1212 
    1313        1. Contents.................: |align-contents| 
    1414        2. Alignment Manual.........: |align-manual| 
    1515        3. Alignment Usage..........: |align-usage| 
     16           Alignment Concepts.......: |align-concepts| 
     17           Alignment Commands.......: |align-commands| 
    1618           Alignment Control........: |align-control| 
    1719             Separators.............: |alignctrl-separators| 
     
    4850 
    4951============================================================================== 
    50 2. Align Manual                 *alignman* *alignmanual* *align-manual* {{{1 
     522. Align Manual                 *alignman* *alignmanual* *align-manual* 
    5153 
    5254        To Enable: put <Align.vim> and <AlignMaps.vim> into your .vim/plugin 
     
    129131 
    130132============================================================================== 
    131 3. Alignment Usage                              *alignusage* *align-usage* {{{1 
    132  
    133 COMMANDS                                                {{{2 
     1333. Alignment Usage                              *alignusage* *align-usage* 
     134 
     135 
     136ALIGNMENT CONCEPTS                      *align-concept* *align-concepts* 
     137 
     138        The typical text to be aligned is considered to be: 
     139 
     140                * composed of two or more fields 
     141                * separated by one or more separator pattern(s): 
     142                * two or more lines 
     143> 
     144                ws field ws separator ws field ws separator ... 
     145                ws field ws separator ws field ws separator ... 
     146< 
     147        where "ws" stands for "white space" such as blanks and/or tabs, 
     148        and "fields" are arbitrary text.  For example, consider > 
     149 
     150                x= y= z= 3; 
     151                xx= yy= zz= 4; 
     152                zzz= yyy= zzz= 5; 
     153                a= b= c= 3; 
     154< 
     155        Assume that it is desired to line up all the "=" signs; these, 
     156        then, are the separators.  The fields are composed of all the 
     157        alphameric text.  Assuming they lie on lines 1-4, one may align 
     158        those "=" signs with: > 
     159                :AlignCtrl l 
     160                :1,4Align = 
     161<       The result is: > 
     162                x   = y   = z   = 3; 
     163                xx  = yy  = zz  = 4; 
     164                zzz = yyy = zzz = 5; 
     165                a   = b   = c   = 3; 
     166 
     167<       Note how each "=" sign is surrounded by a single space; the 
     168        default padding is p1P1 (p1 means one space before the separator, 
     169        and P1 means one space after it).  If you wish to change the 
     170        padding, say to no padding, use  (see |alignctrl-p|) > 
     171                :AlignCtrl lp0P0 
     172 
     173<       Next, note how each field is left justified; that's what the "l" 
     174        (a small letter "ell") does.  If right-justification of the fields 
     175        had been desired, an "r" could've been used: > 
     176                :AlignCtrl r 
     177<       yielding > 
     178                  x =   y =   z = 3; 
     179                 xx =  yy =  zz = 4; 
     180                zzz = yyy = zzz = 5; 
     181                  a =   b =   c = 3; 
     182<       There are more options available for field justification: see 
     183        |alignctrl-c|. 
     184 
     185        Separators, although commonly only one character long, are actually 
     186        specified by regular expressions (see |regexp|), and one may left 
     187        justify, right justify, or center them, too (see |alignctrl-<|). 
     188 
     189        Assume that for some reason a left-right-left-right-... justification 
     190        sequence was wished.  This wish is simply achieved with > 
     191                :AlignCtrl lr 
     192                :1,4Align = 
     193<       because the justification commands are considered to be "cylic"; ie. 
     194        lr is the same as lrlrlrlrlrlrlr... 
     195 
     196        There's a lot more discussed under |alignctrl|; hopefully the examples 
     197        there will help, too. 
     198 
     199 
     200ALIGNMENT COMMANDS                      *align-command* *align-commands* 
     201 
    134202        The <Align.vim> script includes two primary commands and two 
    135203        minor commands: 
     
    180248                            was last used. 
    181249< 
    182 ALIGNMENT OPTIONS                       *align-options* {{{2 
     250 
     251ALIGNMENT OPTIONS                       *align-option* *align-options* 
    183252 
    184253                    *align-utf8* *align-utf* *align-codepoint* *align-strlen* 
     
    191260                        let g:Align_xstrlen= 1: 
    192261< 
    193         Number of spacing codepoints (Latin a + combining circumflex is one spacing~ 
    194         codepoint; a hard tab is one; wide and narrow CJK are one each; etc.)~ 
     262        Number of spacing codepoints (Latin a + combining circumflex is one~ 
     263        spacing codepoint; a hard tab is one; wide and narrow CJK are one~ 
     264        each; etc.)~ 
    195265> 
    196266                        let g:Align_xstrlen= 2 
    197267< 
    198268        Virtual length (counting, for instance, tabs as anything between 1 and~ 
    199         'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately~ 
    200         preceded by lam, one otherwise, etc.)~ 
     269        'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when~ 
     270        immediately preceded by lam, one otherwise, etc.)~ 
    201271> 
    202272                        let g:Align_xstrlen= 2 
     
    204274        By putting one of these settings into your <.vimrc>, Align will use an 
    205275        internal (interpreted) function to determine a string's length instead 
    206         of the Vim's built-in |strlen()| function.  As the function is 
     276        of the built-in to Vim's |strlen()| function.  As the function is 
    207277        interpreted, Align will run a bit slower but will handle such strings 
    208278        correctly.  The last setting (g:Align_xstrlen= 2) probably will run 
    209         the slowest but be the most accurate. 
    210  
    211  
    212 ALIGNMENT CONTROL                       *alignctrl* *align-control*     {{{2 
    213 > 
    214         AlignCtrl   [=Clrc-+:pPIWw] [..list-of-separator-patterns..] 
    215 < 
    216         The AlignCtrl command doesn't do the alignment operation itself; instead, 
    217         it permits the user to specify various alignment options before the 
    218         alignment is done. 
     279        the slowest but be the most accurate.  
     280        (thanks to Tony Mechelynck for these) 
     281 
     282 
     283ALIGNMENT CONTROL                               *alignctrl* *align-control* 
     284 
     285        This command doesn't do the alignment operation itself; instead, it 
     286        controls the subsequent alignment operation(s). 
    219287 
    220288        The first argument to AlignCtrl is a string which may contain one or 
     
    224292        separator. 
    225293 
    226          
    227         Separators                              *alignctrl-separators* {{{3 
    228  
    229294        The typical text line is considered to be composed of two or more 
    230295        fields separated by one or more separator pattern(s): 
     
    234299        stands for "white space" such as blanks and/or tabs. 
    235300 
    236         As a result, separators may  not have white space (tabs or blanks) on 
     301         
     302        Separators                              *alignctrl-separators* 
     303 
     304        As a result, separators may not have white space (tabs or blanks) on 
    237305        their outsides (ie.  ":  :" is fine as a separator, but " :: " is 
    238306        not).  Usually such separators are not needed. 
     
    250318 
    251319 
    252         ---                                             *alignctrl-w* {{{3 
     320        ---                                             *alignctrl-w* 
    253321        wWI     INITIAL WHITE SPACE                     *alignctrl-W* 
    254322        ---                                             *alignctrl-I* 
     
    259327 
    260328        Example: Leading white space options: > 
    261                          +---------------+-------------------+----------------+ 
    262                          |AlignCtrl w= :=|  AlignCtrl W= :=  |AlignCtrl I= := | 
    263       +------------------+---------------+-------------------+----------------+ 
    264       |     Original     |   w option    |     W option      |    I option    | 
    265       +------------------+---------------+-------------------+----------------+ 
    266       |   a := baaa      |a     := baaa  |   a      : = baaa |  a     := baaa | 
    267       | caaaa := deeee   |caaaa := deeee | caaaa    : = deeee|  caaaa := deeee| 
    268       |       ee := f    |ee    := f     |       ee : = f    |  ee    := f    | 
    269       +------------------+---------------+-------------------+----------------+ 
     329                         +---------------+-------------------+-----------------+ 
     330                         |AlignCtrl w= :=|  AlignCtrl W= :=  | AlignCtrl I= := | 
     331      +------------------+---------------+-------------------+-----------------+ 
     332      |     Original     |   w option    |     W option      |     I option    | 
     333      +------------------+---------------+-------------------+-----------------+ 
     334      |   a := baaa      |a     := baaa  |   a      : = baaa |   a     := baaa | 
     335      | caaaa := deeee   |caaaa := deeee | caaaa    : = deeee|   caaaa := deeee| 
     336      |       ee := f    |ee    := f     |       ee : = f    |   ee    := f    | 
     337      +------------------+---------------+-------------------+-----------------+ 
    270338< 
    271339        The original has at least one leading white space on every line. 
    272340        Using Align with w eliminated each line's leading white space. 
    273341        Using Align with W preserved  each line's leading white space. 
    274         Using Align with I applied the first line's leading two spaces 
    275         to each line. 
    276  
    277  
    278         ------                                          *alignctrl-l* {{{3 
     342        Using Align with I applied the first line's leading white space 
     343                           (three spaces) to each line. 
     344 
     345 
     346        ------                                          *alignctrl-l* 
    279347        lrc-+:  FIELD JUSTIFICATION                     *alignctrl-r* 
    280348        ------                                          *alignctrl-c* 
     
    312380        Even more separator control is available.  With "-+:": 
    313381 
    314             - : skip treating the separator as a separator.     *alignctrl--* {{{3 
     382            - : skip treating the separator as a separator.     *alignctrl--* 
    315383            + : repeat use of the last "lrc" justification      *alignctrl-+* 
    316384            : : treat the rest of the line as a single field    *alignctrl-:* 
     
    360428 
    361429 
    362         ---                                                     *alignctrl-=* {{{3 
     430        ---                                                     *alignctrl-=* 
    363431        =C      CYCLIC VS ALL-ACTIVE SEPARATORS                 *alignctrl-C* 
    364432        --- 
     
    457525< 
    458526 
    459         ---                                             *alignctrl-<* {{{3 
     527        ---                                             *alignctrl-<* 
    460528        <>|     SEPARATOR JUSTIFICATION                 *alignctrl->* 
    461529        ---                                             *alignctrl-|* 
     
    485553< 
    486554 
    487         ---                                             *alignctrl-g* {{{3 
     555        ---                                             *alignctrl-g* 
    488556        gv      SELECTIVE APPLICATION                   *alignctrl-v* 
    489557        --- 
     
    531599 
    532600        --- 
    533          m      MAP SUPPORT                             *alignctrl-m* {{{3 
     601         m      MAP SUPPORT                             *alignctrl-m* 
    534602        --- 
    535603 
     
    543611 
    544612        --- 
    545         p###                                            *alignctrl-p* {{{3 
     613        p###                                            *alignctrl-p* 
    546614        P###    PADDING                                 *alignctrl-P* 
    547615        --- 
     
    571639                etc. 
    572640 
    573         ---------------                         *alignctrl-settings* {{{3 
     641        ---------------                         *alignctrl-settings* 
    574642        No option given         DISPLAY STATUS  *alignctrl-* 
    575643        ---------------                         *alignctrl-no-option* 
     
    598666< 
    599667 
    600 ALIGNMENT                                               *align-align* {{{2 
    601 > 
    602         [range]Align  [..list-of-separators..] 
    603         [range]Align! [AlignCtrl settings] [..list-of-separators..] 
    604 < 
    605         Once the alignment control options (see |alignctrl|) have been 
    606         entered, the user specifies a range of lines for the Align 
    607         command/function to do its thing.  Alignment is often done on a 
    608         line-range basis, but one may also restrict alignment to a visual 
    609         block using ctrl-v.  For any visual mode, one types the colon (:) and 
    610         then "Align". 
    611  
    612         One may, of course, specify a range of lines where the |range| is the 
    613         usual Vim-powered set of possibilities; the list of separators is the 
    614         same as that provided via AlignCtrl.  There is only one list of 
    615         separators, but either :AlignCtrl or :Align can be used to specify that 
    616         list. 
    617  
    618         The alternative form of the Align command can handle both alignment 
     668ALIGNMENT                                               *align-align* 
     669 
     670        Once the alignment control has been determined, the user specifies a 
     671        range of lines for the Align command/function to do its thing. 
     672        Alignment is often done on a line-range basis, but one may also 
     673        restrict alignment to a visual block using ctrl-v.  For any visual 
     674        mode, one types the colon (:) and then "Align".  One may, of course, 
     675        specify a range of lines: > 
     676 
     677                :[range]Align [list-of-separators] 
     678< 
     679        where the |range| is the usual Vim-powered set of possibilities; the 
     680        list of separators is the same as the AlignCtrl capability.  There is 
     681        only one list of separators, but either AlignCtrl or Align can be used 
     682        to specify that list. 
     683 
     684        An alternative form of the Align command can handle both alignment 
    619685        control and the separator list: > 
    620686 
    621687                :[range]Align! [alignment-control-string] [list-of-separators] 
    622688< 
    623         The alignment control string provided this way will be applied only 
    624         for this particular application of Align (it uses |alignctrl-m|).  The 
    625         "g pattern" and "v pattern" alignment controls (see |alignctrl-g| and 
    626         |alignctrl-v|) are also available via this form of the Align command. 
     689        The alignment control string will be applied only for this particular 
     690        application of Align (it uses |alignctrl-m|).  The "g pattern" and 
     691        "v pattern" alignment controls (see |alignctrl-g| and |alignctrl-v|) 
     692        are also available via this form of the Align command. 
    627693 
    628694        Align makes two passes over the text to be aligned.  The first pass 
    629695        determines how many fields there are and determines the maximum sizes 
    630696        of each field; these sizes are then stored in a vector.  The second 
    631         pass pads the fields (left/right/centered as specified) to bring its 
     697        pass pads the field (left/right/centered as specified) to bring its 
    632698        length up to the maximum size of the field.  Then the separator and 
    633699        its AlignCtrl-specified padding is appended. 
     
    649715                 || Delete current line, install newly aligned line 
    650716 
    651         The g and v AlignCtrl patterns cause the passes skip over lines for 
    652         alignment, either by requiring that the g-pattern be present or that 
    653         the v-pattern not be present. 
     717        The g and v AlignCtrl patterns cause the passes not to consider lines 
     718        for alignment, either by requiring that the g-pattern be present or 
     719        that the v-pattern not be present. 
    654720 
    655721        The whitespace on either side of a separator is ignored. 
    656722 
    657723 
    658 ALIGNMENT MAPS                          *alignmaps* *align-maps* {{{2 
     724ALIGNMENT MAPS                          *alignmaps* *align-maps* 
    659725 
    660726        There are a number of maps using AlignCtrl() and Align() in the 
     
    665731        compatibility. 
    666732 
    667         ALIGNMENT MAP LISTING   {{{3 ~ 
    668733          \a,   : useful for breaking up comma-separated 
    669734                  declarations prior to \adec                   |alignmap-a,| 
     
    676741          \anum : useful for aligning numbers                   |alignmap-anum| 
    677742                  NOTE: For the visual-mode use of \anum, <vis.vim> is needed! 
    678                   See http://mysite.verizon.net/astronaut/vim/index.html#VIS 
     743                    See http://mysite.verizon.net/astronaut/vim/index.html#VIS 
    679744          \aenum: align a European-style number                 |alignmap-anum| 
    680745          \aunum: align a USA-style number                      |alignmap-anum| 
    681746          \adec : useful for aligning declarations              |alignmap-adec| 
    682747          \adef : useful for aligning definitions               |alignmap-adef| 
    683           \afnc : useful for aligning ansi-c style functions'   |alignmap-afnc| 
    684                   argument lists 
     748          \afnc : useful for aligning ansi-c style functions' 
     749                  argument lists                                |alignmap-afnc| 
    685750          \adcom: a variant of \acom, restricted to comment     |alignmap-adcom| 
    686751                  containing lines only, but also only for 
     
    714779          \m=   : like \t= but aligns with %... style comments 
    715780 
    716         The leading backslash is actually <leader> (see |mapleader| on how to 
    717         customize the leader to be whatever you prefer).  These maps all use 
    718         the <Align.vim> package and are defined in the <AlignMaps.vim> file. 
     781        The leading backslash is actually <leader> (see |mapleader| for how to 
     782        customize the leader to be whatever you like).  These maps use the 
     783        <Align.vim> package and are defined in the <AlignMaps.vim> file. 
    719784        Although the maps use AlignCtrl options, they typically use the "m" 
    720         option which pushes and pops the current options (AlignPush).  The 
    721         associated Align call which follows will then AlignPop the user's 
    722         original options back. 
    723  
    724         ALIGNMENT MAP USE WITH MARK AND MOVE {{{3 ~ 
     785        option which pushes the options (AlignPush).  The associated Align 
     786        call which follows will then AlignPop the user's original options 
     787        back. 
     788 
     789        ALIGNMENT MAP USE WITH MARK AND MOVE~ 
    725790        In the examples below, one may select the text with a "ma" at the 
    726791        first line, move to the last line, then execute the map. 
    727792 
    728         ALIGNMENT MAP USE WITH VISUAL MODE {{{3 ~ 
     793        ALIGNMENT MAP USE WITH VISUAL MODE~ 
    729794        Alternatively, one may select the text with the "V" visual mode 
    730795        selector. 
    731796 
    732         ALIGNMENT MAP USE WITH MENUS {{{3 ~ 
     797        ALIGNMENT MAP USE WITH MENUS~ 
    733798        One may use the mark-and-move style (ma, move, use the menu) or 
    734799        the visual mode style (use the V visual mode, move, then select 
    735800        the alignment map with menu selection).  The alignment map menu 
    736         items are under the heading "DrChip.AlignMaps". 
     801        items are under DrChip.AlignMaps . 
    737802 
    738803        One may change the top level menu name to whatever is wished; by 
     
    744809        must be included). 
    745810 
    746         COMPLEX ALIGNMENT MAP METHOD {{{3 ~ 
     811        COMPLEX ALIGNMENT MAP METHOD~ 
    747812        For those complex alignment maps which do alignment on constructs 
    748813        (e.g. \acom, \adec, etc), a series of substitutes is used to insert 
     
    753818        doing the requested job, and then converting them back. 
    754819 
    755         As an example, consider \adec (as of v39b of AlignMaps.vim): 
    756  
    757           map <silent> <Leader>adec     The map is set up to be silent (ie. 
    758                                         not report on qty of substitutes made, 
    759                                         etc).  The <Leader> (see |mapleader|) 
    760                                         allows the user to specify his/her 
    761                                         preferred map-leader character. 
    762  
    763           <SID>WS                       The wrapper-start map calls the 
    764                                         AlignWrapperStart() function, which 
    765                                         saves certain problematic user 
    766                                         options, sets up fencepost blank lines 
    767                                         around the area to be processed, and 
    768                                         sets some friendly-to-align options. 
    769                                         It also pushes the user's Alignment 
    770                                         options on a stack. 
    771  
    772           :'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR> 
    773                                         This substitute retains any initial 
    774                                         whitespace and insures that there is 
    775                                         separation between any leading *& 
    776                                         characters and the beginning of the 
    777                                         line. 
    778  
    779           :'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR> 
    780                                         For any line not a comment, leading 
    781                                         non-white space characters are forced 
    782                                         to be followed by a single space (as 
    783                                         opposed to multiple whitespace 
    784                                         characters). 
    785  
    786           :'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR> 
    787                                         For any lines not a comment (or part 
    788                                         of a multi-line C comment), whitespace 
    789                                         following a [not-a-/][*&] is removed. 
    790  
    791           :'y,'zv/^\s*[*/]/s/^\(\s*\%(\K\k*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\) 
    792           \([*(&]*\)\s*\([a-zA-Z0-9_()]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\= 
    793           \s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR> 
    794                                         This substitute (all one line, but 
    795                                         split so it can fit on a help page), 
    796                                         is the declaration-construct recognition 
    797                                         workhorse.  Basically it splits a 
    798                                         declaration into components separated 
    799                                         by @ and # signs. 
    800  
    801           :'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR> 
    802                                         Places an @ sign before the ending ...*/ 
    803                                         in C comments (except for those lines 
    804                                         that are just beginning of line 
    805                                         followed by spaces to */). 
    806  
    807           :'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR> 
    808                                         For those lines without comments, @s 
    809                                         are placed at the end-of-line. 
    810  
    811           :'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR> 
    812                                         Cleans up some situations where the 
    813                                         previous @@@@@ appending ended up 
    814                                         at the beginning of lines and there's 
    815                                         continuing comment involved. 
    816                                          
    817           'yjma'zk                      Preparation for alignment by marking 
    818                                         the region. 
    819  
    820           :AlignCtrl v ^\s*[*/#]<CR>    Don't align comment-only lines. 
    821  
    822           <Leader>t@                    Align all the @s inserted above. 
    823  
    824           :'y,'zv/^\s*[*/]/s/@ //ge<CR> 
    825           :'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR> 
    826           :'y,'zv/^#/s/# //e<CR> 
    827           :'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR> 
    828           :'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR> 
    829           :'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR> 
    830           :'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR> 
    831           :'y,'zs/^[*]/ */e<CR> 
    832                                         These are all clean-up substitutes, 
    833                                         removing @s and #s, some unnecessary 
    834                                         spaces, etc. 
    835  
    836           <SID>WE                       Reverse the AlignWrapperStart() with 
    837                                         AlignWrapperEnd(): AlignPop the 
    838                                         alignment settings, restore window 
    839                                         position, remove fencepost lines, and 
    840                                         restore user options. 
    841  
    842  
    843         --------------------------- 
    844         Alignment Map Examples: \a,                     *alignmap-a,* {{{3 
     820 
     821        --------------------------- 
     822        Alignment Map Examples: \a,                             *alignmap-a,* 
    845823        --------------------------- 
    846824 
     
    858836 
    859837        --------------------------- 
    860         Alignment Map Examples: \a?                     *alignmap-a?* {{{3 
     838        Alignment Map Examples: \a?                             *alignmap-a?* 
    861839        --------------------------- 
    862840 
     
    875853 
    876854        --------------------------- 
    877         Alignment Map Examples: \a<                     *alignmap-a<* {{{3 
     855        Alignment Map Examples: \a<                             *alignmap-a<* 
    878856        --------------------------- 
    879857 
     
    892870 
    893871        --------------------------- 
    894         Alignment Map Examples: \a=                     *alignmap-a=* {{{3 
     872        Alignment Map Examples: \a=                             *alignmap-a=* 
    895873        --------------------------- 
    896874 
     
    907885 
    908886        --------------------------- 
    909         Alignment Map Examples: \abox                   *alignmap-abox* {{{3 
     887        Alignment Map Examples: \abox                           *alignmap-abox* 
    910888        --------------------------- 
    911889 
     
    926904 
    927905        --------------------------- 
    928         Alignment Map Examples: \acom                   *alignmap-acom* {{{3 
     906        Alignment Map Examples: \acom                           *alignmap-acom* 
    929907        --------------------------- 
    930908 
     
    943921 
    944922        --------------------------- 
    945         Alignment Map Examples: \anum                   *alignmap-anum* {{{3 
     923        Alignment Map Examples: \anum                           *alignmap-anum* 
    946924        --------------------------- 
    947925 
     
    995973 
    996974        --------------------------- 
    997         Alignment Map Examples: \ascom                  *alignmap-ascom* {{{3 
     975        Alignment Map Examples: \ascom                          *alignmap-ascom* 
    998976        --------------------------- 
    999977 
     
    1010988 
    1011989        --------------------------- 
    1012         Alignment Map Examples: \adec                   *alignmap-adec* {{{3 
     990        Alignment Map Examples: \adec                           *alignmap-adec* 
    1013991        --------------------------- 
    1014992 
     
    10551033 
    10561034        --------------------------- 
    1057         Alignment Map Examples: \adef                   *alignmap-adef* {{{3 
     1035        Alignment Map Examples: \adef                           *alignmap-adef* 
    10581036        --------------------------- 
    10591037 
     
    10721050 
    10731051        --------------------------- 
    1074         Alignment Map Examples: \afnc                   *alignmap-afnc* {{{3 
     1052        Alignment Map Examples: \afnc                           *alignmap-afnc* 
    10751053        --------------------------- 
    10761054 
     
    11021080 
    11031081        --------------------------- 
    1104         Alignment Map Examples: \adcom                  *alignmap-adcom* {{{3 
     1082        Alignment Map Examples: \adcom                          *alignmap-adcom* 
    11051083        --------------------------- 
    11061084 
     
    11251103 
    11261104        --------------------------- 
    1127         Alignment Map Examples: \aocom                  *alignmap-aocom* {{{3 
     1105        Alignment Map Examples: \aocom                          *alignmap-aocom* 
    11281106        --------------------------- 
    11291107 
     
    11441122 
    11451123        --------------------------- 
    1146         Alignment Map Examples: \tsp                    *alignmap-tsp* {{{3 
     1124        Alignment Map Examples: \tsp                            *alignmap-tsp* 
    11471125        --------------------------- 
    11481126 
     
    11681146 
    11691147        --------------------------- 
    1170         Alignment Map Examples: \tsq                    *alignmap-tsq* {{{3 
     1148        Alignment Map Examples: \tsq                            *alignmap-tsq* 
    11711149        --------------------------- 
    11721150 
     
    11861164 
    11871165        --------------------------- 
    1188         Alignment Map Examples: \tt                     *alignmap-tt* {{{3 
     1166        Alignment Map Examples: \tt                             *alignmap-tt* 
    11891167        --------------------------- 
    11901168 
     
    12101188 
    12111189        ---------------------------- 
    1212         Alignment Map Examples: \tml                    *alignmap-tml* {{{3 
     1190        Alignment Map Examples: \tml                            *alignmap-tml* 
    12131191        ---------------------------- 
    12141192 
     
    12311209 
    12321210        --------------------------- 
    1233         Alignment Map Examples: \t=                     *alignmap-t=* {{{3 
     1211        Alignment Map Examples: \t=                             *alignmap-t=* 
    12341212        --------------------------- 
    12351213 
     
    12461224 
    12471225        --------------------------- 
    1248         Alignment Map Examples: \T=                     *alignmap-T=* {{{3 
     1226        Alignment Map Examples: \T=                             *alignmap-T=* 
    12491227        --------------------------- 
    12501228 
     
    12611239 
    12621240        --------------------------- 
    1263         Alignment Map Examples: \Htd                    *alignmap-Htd* {{{3 
     1241        Alignment Map Examples: \Htd                            *alignmap-Htd* 
    12641242        --------------------------- 
    12651243 
     
    12791257                            used to represent characters and their effects 
    12801258                            on string lengths.  See |align-strlen|. 
     1259                          * Align now accepts "..." -- so it can accept 
     1260                            whitespace as separators. 
    12811261        32 : Aug 18, 2007 * uses |<q-args>| instead of |<f-args>| plus a 
    12821262                            custom argument splitter to allow patterns with 
     
    13381318 
    13391319ALIGNMENT MAP HISTORY                                   *alignmap-history* {{{2 
     1320        v39   Mar 06, 2008 : * \t= only does /* ... */ aligning when in *.c 
     1321                               *.cpp files. 
    13401322        v38   Aug 18, 2007 : * \tt altered so that it works with the new 
    13411323                               use of |<q-args>| plus a custom argument 
     
    13461328        v35   Sep 01, 2006 : * \t= and cousins used "`"s.  They now use \xff 
    13471329                               characters. 
    1348                              * \acom can now work with doxygen style /// comments 
     1330                             * \acom now works with doxygen style /// comments 
    13491331                             * <char-0xff> used in \t= \T= \w= and \m= instead 
    13501332                               of backquotes. 
  • dotfiles/vim/ishihara/.vim/doc/yankring.txt

    r7191 r9179  
    1 *yankring.txt*      For Vim version 7.0.  
    2  
    3 Author:         David Fishburn                             September 7, 2007 
    4 Version:        3.0 
     1*yankring.txt*      For Vim version 6.2 and 7.0.  
     2 
     3Author:         David Fishburn                             October 19, 2005 
     4Version:        2.2 
    55 
    66For instructions on installing this file, type 
     
    3434       5.15 YRMapsDelete......................: |YRMapsDelete| 
    3535       5.16 YRSearch..........................: |YRSearch| 
    36        5.17 YRRunAfterMaps....................: |yankring-custom-maps| 
    3736    6. Tutorial...............................: |yankring-tutorial| 
    3837       6.1  YRShow............................: |YRShow-example| 
     
    5554information see |quote_number|. 
    5655 
    57 Vim does not provide any mechanism to reference previously yanked text.   
     56Vim does not provide any mechanism to reference previous yanked text.   
    5857In Emacs this feature is called the "kill ring". 
    5958 
     
    6160and deleted text.  After text has been pasted, it can be replaced with 
    6261a previous value from the yankring. 
    63  
    64 As of version 3.0, the yankring's content will persist (by default)  
    65 between starting and stopping Vim. 
    6662 
    6763The plugin can be toggled on and off, and supports: 
     
    106102        the element is limited to the above default.  > 
    107103            let g:yankring_max_display = 70 
    108     yankring_persist   
    109 <       Default: 1 
    110         If you have enabled the storing of global variables in the |viminfo| 
    111         file, the yankring will be default persist the contents of the ring 
    112         between starting and stopping Vim.  To disable this feature: > 
    113             let g:yankring_persist = 0 
    114104    yankring_dot_repeat_yank 
    115105<       Default: Based on the Vim cpoption setting 
     
    318308 
    319309 
    320 ============================================================================== 
    3213104. Using the YankRing Window:                    *yankring-window* 
    322311 
     
    372361 
    373362 
    374 ============================================================================== 
    3753635. Commands:                                     *yankring-commands* 
    376364 
     
    961949============================================================================== 
    9629507. History                                       *yankring-history* 
    963  
    964   3.0: September 7, 2007:  
    965          NF: Converted the yankring to use the new Vim7's List object which 
    966              means it is no longer compatible with Vim6. 
    967          NF: By default the yankring will now maintain the yankring's items 
    968              persistently by default.  It does this via the |viminfo| file. 
    969              This means the contents are the yankring rely on the internal 
    970              variables of only 1 Vim instance. 
    971          BF: YRToggle was not unmapping 'gp' and 'gP'. 
    972          BF: YRSearch prompted the user for a regex even if one was provided 
    973              on the command line. 
    974          BF: If g:yankring_manage_numbered_reg is enabled, the "." operator 
    975              did not correctly repeat the previous action (Pedro DeRose). 
    976  
    977   2.2: November 1, 2005:  
    978          NF: Added 'x' to the list of yankring_n_keys.  This is very useful 
    979              in visual mode since it can delete a lot of characters. 
    980951 
    981952  2.2: October 19, 2005:  
  • dotfiles/vim/ishihara/.vim/plugin/AlignMaps.vim

    r7191 r9179  
    11" AlignMaps:   Alignment maps based upon <Align.vim> 
    22" Maintainer:  Dr. Charles E. Campbell, Jr. <Charles.Campbell@gsfc.nasa.gov> 
    3 " Date:        Dec 20, 2007 
     3" Date:        Mar 06, 2008 
    44" Version:     39 
    55" 
     
    157157map <silent> <Leader>afnc  :set lz<CR>:silent call <SID>Afnc()<CR>:set nolz<CR> 
    158158if exists("g:alignmaps_usanumber") 
    159  map <silent> <Leader>anum  <SID>WS:'a,'zs/\([0-9.]\)\s\+\zs\([-+]\=\d\)/@\1/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [.@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(\.\)\(\s\+\)\([0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE 
     159" map <silent> <Leader>anum  <SID>WS 
     160"       \:'a,'zs/\([-+]\)\=\(\d\+\%([eE][-+]\=\d\+\)\=\)\ze\%($\|[^@]\)/@\1@\2@@#/ge<CR> 
     161"       \:'a,'zs/\([-+]\)\=\(\d*\)\(\.\)\(\d*\([eE][-+]\=\d\+\)\=\)/@\1@\2@\3@\4#/ge<CR> 
     162"    \:AlignCtrl mp0P0r<CR> 
     163"    \:'a,'zAlign [@#]<CR> 
     164"    \:'a,'zs/@//ge<CR> 
     165"    \:'a,'zs/#/ /ge<CR> 
     166"    \<SID>WE 
     167 map <silent> <Leader>anum  <SID>WS:'a,'zs/\([0-9.]\)\s\+\zs\([-+]\=\d\)/@\1/ge<CR> 
     168 \:'a,'zs/\.@/\.0@/ge<CR> 
     169 \:AlignCtrl mp0P0r<CR> 
     170 \:'a,'zAlign [.@]<CR> 
     171 \:'a,'zs/@/ /ge<CR> 
     172 \:'a,'zs/\(\.\)\(\s\+\)\([0-9.,eE+]\+\)/\1\3\2/ge<CR> 
     173 \:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR> 
     174 \<SID>WE 
    160175elseif exists("g:alignmaps_euronumber") 
    161176 map <silent> <Leader>anum  <SID>WS:'a,'zs/\([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [,@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(,\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE 
     
    195210map <silent> <Leader>t;   <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:'y,'zs/\( *\);/;\1/ge<CR><SID>WE 
    196211map <silent> <Leader>t<   <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE 
    197 map <silent> <Leader>t=   <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zs/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk<Leader>t@:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/<Char-0xff>/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE 
     212map <silent> <Leader>t=   <SID>WS:call <SID>Equals()<CR><SID>WE 
    198213map <silent> <Leader>w=   <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk<Leader>t@:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE 
    199214map <silent> <Leader>t?   <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE 
    200215map <silent> <Leader>t~   <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE 
    201216map <silent> <Leader>m=   <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zs/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk<Leader>t@:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE 
    202 map <silent> <Leader>tab  <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0xff>",'g'),'\')/<CR> 
    203   \:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0xff>"<bar>else<bar>exe "AlignCtrl mI=l \<Char-0xff>"<bar>endif<CR> 
    204   \:'a,.Align<CR> 
    205   \:exe "'y+1,'z-1s/\<Char-0xff>/".((&ts == 1)? '\t' : ' ')."/g"<CR> 
    206   \<SID>WE 
     217map <silent> <Leader>tab  <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0xff>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0xff>"<bar>else<bar>exe "AlignCtrl mI=l \<Char-0xff>"<bar>endif<CR>:'a,.Align<CR>:exe "'y+1,'z-1s/\<Char-0xff>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE 
    207218map <silent> <Leader>tml  <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE 
    208219map <silent> <Leader>tsp  <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE 
     
    331342 
    332343" --------------------------------------------------------------------- 
     344" s:Equals: {{{2 
     345fun! s:Equals() 
     346"  call Dfunc("s:Equals()") 
     347  'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e 
     348  'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge 
     349  'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge 
     350  'a,'zs/!=/\="!\<Char-0xff>"/ge 
     351  norm g'zk 
     352  AlignCtrl mIp1P1=l = 
     353  AlignCtrl g = 
     354  'a,'z-1Align 
     355  'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge 
     356  'a,'z-1s/\( \+\);/;\1/ge 
     357  if &ft == "c" || &ft == "cpp" 
     358   'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e 
     359   'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e 
     360   exe norm "'zk<Leader>t@" 
     361   'y,'zs/^\(\s*\) @/\1/e 
     362  endif 
     363  'a,'z-1s/<Char-0xff>/=/ge 
     364  'y,'zs/ @//eg 
     365"  call Dret("s:Equals") 
     366endfun 
     367 
     368" --------------------------------------------------------------------- 
    333369" Afnc: useful for splitting one-line function beginnings {{{1 
    334370"            into one line per argument format 
    335 fun! <SID>Afnc() 
     371fun! s:Afnc() 
    336372"  call Dfunc("Afnc()") 
    337373 
  • dotfiles/vim/ishihara/.vim/plugin/autocomplpop.vim

    r7191 r9179  
    1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
     1"============================================================================= 
    22" autocomplpop.vim - Automatically open the popup menu for completion. 
    3 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    4 " 
    5 " Last Change:  12-Feb-2008. 
    6 " Author:       Takeshi Nishida <ns9tks(at)gmail.com> 
    7 " Version:      1.6.1, for Vim 7.1 
    8 " Licence:      MIT Licence 
    9 " URL:          http://www.vim.org/scripts/script.php?script_id=1879 
    10 " 
    11 "----------------------------------------------------------------------------- 
    12 " Description: 
     3"============================================================================= 
     4" 
     5" Author:  Takeshi Nishida <ns9tks(at)gmail.com> 
     6" Version: 2.3.1, for Vim 7.1 
     7" Licence: MIT Licence 
     8" URL:     http://www.vim.org/scripts/script.php?script_id=1879 
     9" 
     10" GetLatestVimScripts: 1879 1 :AutoInstall: autocomplpop.vim 
     11" 
     12"============================================================================= 
     13" DOCUMENT: (Japanese: http://vim.g.hatena.ne.jp/keyword/autocomplpop.vim) 
     14" 
     15" Description: ---------------------------------------------------------- {{{1 
    1316"   Install this plugin and your vim comes to automatically opens the popup 
    14 "   menu for completion when you input a few characters in a insert mode. This 
    15 "   plugin works by mapping alphanumeric characters and some symbols. 
    16 " 
    17 "----------------------------------------------------------------------------- 
    18 " Installation: 
     17"   menu for completion when you enter characters or move the cursor in Insert 
     18"   mode. 
     19" 
     20" Installation: --------------------------------------------------------- {{{1 
    1921"   Drop this file in your plugin directory. 
    2022" 
    21 "----------------------------------------------------------------------------- 
    22 " Usage: 
     23" Usage: ---------------------------------------------------------------- {{{1 
    2324"   If this plugin has been installed, the auto-popup is enabled at startup by 
    2425"   default. 
     
    3031"        consists of two keyword character. 
    3132"     2. The keyword completion is attempted in Scheme file if the text before 
    32 "        the cursor consists of '(' + a keyword character. 
     33"        the cursor consists of "(" + a keyword character. 
    3334"     3. The filename completion is attempted if the text before the cursor 
    3435"        consists of a filename character + a path separator + 0 or more 
    3536"        filename characters. 
    3637"     4. The omni completion is attempted in Ruby file if the text before the 
    37 "        cursor consists of '.' or '::'. (Ruby interface is required.) 
     38"        cursor consists of "." or "::". (Ruby interface is required.) 
     39"     5. The omni completion is attempted in Python file if the text before 
     40"        the cursor consists of ".". (Python interface is required.) 
     41"     6. The omni completion is attempted in HTML/XHTML file if the text 
     42"        before the cursor consists of "<" or "</". 
     43"     7. The omni completion is attempted in CSS file if the text before the 
     44"        cursor consists of ":", ";", "{", "@", "!", or in the start of line 
     45"        with blank characters and keyword characters. 
    3846" 
    3947"   This behavior is customizable. 
     
    4149"   Commands: 
    4250"     :AutoComplPopEnable 
    43 "       - makes mappings for the auto-popup. 
     51"       - makes autocommands for the auto-popup. 
    4452"     :AutoComplPopDisable 
    45 "       - removes mappings for the auto-popup. 
    46 "     :AutoComplPopLock 
    47 "       - suspends the auto-popup. 
    48 "     :AutoComplPopUnlock 
    49 "       - resumes the auto-popup after :AutoComplPopLock. 
    50 " 
    51 "----------------------------------------------------------------------------- 
    52 " Options: 
     53"       - removes autocommands for the auto-popup. 
     54" 
     55" Options: -------------------------------------------------------------- {{{1 
    5356"   g:AutoComplPop_NotEnableAtStartup: 
    5457"     The auto-popup is not enabled at startup if this is non-zero. 
    55 " 
    56 "   g:AutoComplPop_MapList: 
    57 "     This is a list. Each string of this list is mapped as trigger to open 
    58 "     the popup menu. 
    5958" 
    6059"   g:AutoComplPop_IgnoreCaseOption 
     
    8180"         It automatically repeats a completion if non-zero is set. 
    8281" 
    83 "----------------------------------------------------------------------------- 
    84 " Thanks: 
     82" Thanks: --------------------------------------------------------------- {{{1 
    8583"   vimtip #1386 
    8684" 
    87 "----------------------------------------------------------------------------- 
    88 " ChangeLog: 
     85" ChangeLog: ------------------------------------------------------------ {{{1 
     86"   2.3.1: 
     87"     - Changed to set 'lazyredraw' while a popup menu is visible to avoid 
     88"       flickering. 
     89"     - Changed a behavior for CSS. 
     90"     - Added support for GetLatestVimScripts. 
     91" 
     92"   2.3: 
     93"     - Added a behavior for Python to support omni completion. 
     94"     - Added a behavior for CSS to support omni completion. 
     95" 
     96"   2.2: 
     97"     - Changed not to work when 'paste' option is set. 
     98"     - Fixed AutoComplPopEnable command and AutoComplPopDisable command to 
     99"       map/unmap "i" and "R". 
     100" 
     101"   2.1: 
     102"     - Fixed the problem caused by "." command in Normal mode. 
     103"     - Changed to map "i" and "R" to feed completion command after starting 
     104"       Insert mode. 
     105"     - Avoided the problem caused by Windows IME. 
     106" 
     107"   2.0: 
     108"     - Changed to use CursorMovedI event to feed a completion command instead 
     109"       of key mapping. Now the auto-popup is triggered by moving the cursor. 
     110"     - Changed to feed completion command after starting Insert mode. 
     111"     - Removed g:AutoComplPop_MapList option. 
     112" 
     113"   1.7: 
     114"     - Added behaviors for HTML/XHTML. Now supports the omni completion for 
     115"       HTML/XHTML. 
     116"     - Changed not to show expressions for CTRL-R =. 
     117"     - Changed not to set 'nolazyredraw' while a popup menu is visible. 
     118" 
    89119"   1.6.1: 
    90 "     - Changed not to trigger the filename competion by a text which has 
     120"     - Changed not to trigger the filename completion by a text which has 
    91121"       multi-byte characters. 
     122" 
    92123"   1.6: 
    93124"     - Redesigned g:AutoComplPop_Behavior option. 
     
    146177"       - First release. 
    147178" 
    148 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    149  
    150 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    151 " INCLUDE GUARD: 
    152 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    153  
    154 if exists('loaded_autocomplpop') || v:version < 700 
     179" }}}1 
     180"============================================================================= 
     181 
     182" INCLUDE GUARD: ======================================================== {{{1 
     183if v:version < 701 
     184  echoerr "Sorry, Autocomplpop doesn't support this version of Vim." 
    155185  finish 
     186elseif exists('loaded_autocomplpop') 
     187  finish 
    156188endif 
    157189let loaded_autocomplpop = 1 
    158190 
    159191 
    160 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    161 " INITIALIZATION FUNCTION: 
    162 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    163  
    164 function! <SID>Initialize() 
    165   "------------------------------------------------------------------------- 
    166   " CONSTANTS 
    167   let s:map_list = [] 
    168   let s:lock_count = 0 
    169  
    170   "------------------------------------------------------------------------- 
    171   " OPTIONS 
    172   "......................................................................... 
    173   if !exists('g:AutoComplPop_NotEnableAtStartup') 
    174     let g:AutoComplPop_NotEnableAtStartup = 0 
    175   endif 
    176   "......................................................................... 
    177   if !exists('g:AutoComplPop_MapList') 
    178     let g:AutoComplPop_MapList = [ 
    179           \ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
    180           \ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 
    181           \ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 
    182           \ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 
    183           \ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
    184           \ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '/', '\', ] 
    185   endif 
    186   "......................................................................... 
    187   if !exists('g:AutoComplPop_IgnoreCaseOption') 
    188     let g:AutoComplPop_IgnoreCaseOption = 0 
    189   endif 
    190   "......................................................................... 
    191   if !exists('g:AutoComplPop_CompleteOption') 
    192     let g:AutoComplPop_CompleteOption = '.,w,b,k' 
    193   endif 
    194  
    195   "......................................................................... 
    196   if !exists('g:AutoComplPop_CompleteoptPreview') 
    197     let g:AutoComplPop_CompleteoptPreview = 0 
    198   endif 
    199   "......................................................................... 
    200   if !exists('g:AutoComplPop_Behavior') 
    201     let g:AutoComplPop_Behavior = {} 
    202   endif 
    203   call extend(g:AutoComplPop_Behavior, { 
    204         \   '*' : [ 
    205         \     { 
    206         \       'command'  : "\<C-n>", 
    207         \       'pattern'  : '\k\k$', 
    208         \       'excluded' : '^$', 
    209         \       'repeat'   : 0, 
    210         \     }, 
    211         \     { 
    212         \       'command'  : "\<C-x>\<C-f>", 
    213         \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
    214         \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
    215         \       'repeat'   : 1, 
    216         \     }, 
    217         \   ], 
    218         \   'ruby' : [ 
    219         \     { 
    220         \       'command'  : "\<C-n>", 
    221         \       'pattern'  : '\k\k$', 
    222         \       'excluded' : '^$', 
    223         \       'repeat'   : 0, 
    224         \     }, 
    225         \     { 
    226         \       'command'  : "\<C-x>\<C-f>", 
    227         \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
    228         \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
    229         \       'repeat'   : 1, 
    230         \     }, 
    231         \     { 
    232         \       'command'  : "\<C-x>\<C-o>", 
    233         \       'pattern'  : '\([^. \t]\.\|^:\|\W:\)$', 
    234         \       'excluded' : (has('ruby') ? '^$' : '.*'), 
    235         \       'repeat'   : 0, 
    236         \     }, 
    237         \   ], 
    238         \   'scheme' : [ 
    239         \     { 
    240         \       'command'  : "\<C-n>", 
    241         \       'pattern'  : '\k\k$', 
    242         \       'excluded' : '^$', 
    243         \       'repeat'   : 0, 
    244         \     }, 
    245         \     { 
    246         \       'command'  : "\<C-n>", 
    247         \       'pattern'  : '(\k$', 
    248         \       'excluded' : '^$', 
    249         \       'repeat'   : 0, 
    250         \     }, 
    251         \     { 
    252         \       'command'  : "\<C-x>\<C-f>", 
    253         \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
    254         \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
    255         \       'repeat'   : 1, 
    256         \     }, 
    257         \   ], 
    258         \ } ,'keep') 
    259   "......................................................................... 
    260  
    261   "------------------------------------------------------------------------- 
    262   " COMMANDS 
    263   command! -bar -narg=0 AutoComplPopEnable  call <SID>Enable() 
    264   command! -bar -narg=0 AutoComplPopDisable call <SID>Disable() 
    265   command! -bar -narg=0 AutoComplPopLock    call <SID>Lock() 
    266   command! -bar -narg=0 AutoComplPopUnlock  call <SID>Unlock() 
    267  
    268   "------------------------------------------------------------------------- 
    269   " AUTOCOMMANDS 
    270   augroup AutoComplPop_GlobalAutoCommand 
    271     autocmd! 
    272     autocmd CursorMovedI * call <SID>OnCursorMovedI() 
    273     autocmd InsertLeave  * call <SID>OnInsertLeave() 
     192" FUNCTION: ============================================================= {{{1 
     193"----------------------------------------------------------------------------- 
     194function! s:GetSidPrefix() 
     195  return matchstr(expand('<sfile>'), '<SNR>\d\+_') 
     196endfunction 
     197 
     198"----------------------------------------------------------------------------- 
     199function! s:GetPopupFeeder() 
     200  return s:PopupFeeder 
     201endfunction 
     202 
     203"----------------------------------------------------------------------------- 
     204function! s:Enable() 
     205  " NOTE: CursorMovedI is not triggered while the pupup menu is visible. And 
     206  "       it will be triggered when pupup menu is disappeared. 
     207 
     208  augroup AutoComplPopGlobalAutoCommand 
     209    autocmd InsertEnter  * let s:PopupFeeder.last_pos = [] | unlet s:PopupFeeder.last_pos 
     210    autocmd InsertLeave  * call s:PopupFeeder.finish() 
     211    autocmd CursorMovedI * call s:PopupFeeder.feed() 
    274212  augroup END 
    275213 
    276   "------------------------------------------------------------------------- 
    277   " MAPPING 
    278  
    279   "------------------------------------------------------------------------- 
    280   " ETC 
    281   if !g:AutoComplPop_NotEnableAtStartup 
    282     AutoComplPopEnable 
    283   endif 
    284  
    285 endfunction 
    286  
    287  
    288 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    289 " FUNCTIONS: 
    290 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    291  
    292 "----------------------------------------------------------------------------- 
    293 function! <SID>Enable() 
    294   if !empty(s:map_list) 
    295     call <SID>Disable() 
    296   endif 
    297  
    298   let s:map_list = deepcopy(g:AutoComplPop_MapList) 
    299  
    300   for item in s:map_list 
    301     execute 'inoremap <silent> ' . item . ' ' . item . "\<C-r>=<SID>FeedPopup()\<CR>" 
    302   endfor 
    303 endfunction 
    304  
    305  
    306 "----------------------------------------------------------------------------- 
    307 function! <SID>Disable() 
    308   if !empty(s:map_list) 
    309     for item in s:map_list 
    310       execute 'iunmap ' . item 
    311     endfor 
    312  
    313     unlet s:map_list[0:] 
    314     let s:lock_count = 0 
    315   endif 
    316 endfunction 
    317  
    318 "----------------------------------------------------------------------------- 
    319 function! <SID>Lock() 
    320   let s:lock_count += 1 
    321 endfunction 
    322  
    323 "----------------------------------------------------------------------------- 
    324 function! <SID>Unlock() 
    325   let s:lock_count -= 1 
    326   if s:lock_count < 0 
    327     let s:lock_count = 0 
    328     throw "autocomplpop: not locked" 
    329   endif 
    330 endfunction 
    331  
    332  
    333 "----------------------------------------------------------------------------- 
    334 function! <SID>SetOrRestoreOption(set_or_restore) 
    335   if a:set_or_restore && !exists('s:_completeopt') 
    336     let s:_completeopt = &completeopt 
    337     let   &completeopt = 'menuone' . (g:AutoComplPop_CompleteoptPreview ? ',preview' : '') 
    338     let s:_complete    = &complete 
    339     let   &complete    = g:AutoComplPop_CompleteOption 
    340     let s:_ignorecase  = &ignorecase 
    341     let   &ignorecase  = g:AutoComplPop_IgnoreCaseOption 
    342     let s:_lazyredraw  = &lazyredraw 
    343     let   &lazyredraw  = 0 
    344   elseif !a:set_or_restore && exists('s:_completeopt') 
    345     let     &completeopt = s:_completeopt 
    346     unlet s:_completeopt 
    347     let     &complete    = s:_complete 
    348     unlet s:_complete 
    349     let     &ignorecase  = s:_ignorecase 
    350     unlet s:_ignorecase 
    351     let     &lazyredraw  = s:_lazyredraw 
    352     unlet s:_lazyredraw 
    353   endif 
    354 endfunction 
    355  
    356  
    357 "----------------------------------------------------------------------------- 
    358 function! <SID>FeedPopup() 
    359   if s:lock_count == 0 && !pumvisible() 
    360     call <SID>SetOrRestoreOption(1) 
    361     let s:req_popup = 1 
    362     return '' 
    363   else 
    364     " The popup menu is hidden by "\<C-r>" for users who set 'lazyredraw'. 
    365     " To show it, return "\<Down>\<Up>" 
     214  nnoremap <silent> i i<C-r>=<SID>GetPopupFeeder().feed()<CR> 
     215  nnoremap <silent> R R<C-r>=<SID>GetPopupFeeder().feed()<CR> 
     216endfunction 
     217 
     218"----------------------------------------------------------------------------- 
     219function! s:Disable() 
     220  autocmd! AutoComplPopGlobalAutoCommand 
     221  nunmap i 
     222  nunmap R 
     223endfunction 
     224 
     225 
     226" OBJECT: PopupFeeder: ================================================== {{{1 
     227let s:PopupFeeder = { 'behavs' : [], 'lock_count' : 0 } 
     228"----------------------------------------------------------------------------- 
     229function! s:PopupFeeder.feed() 
     230  if self.lock_count > 0 || &paste 
    366231    return '' 
    367232  endif 
    368 endfunction 
    369  
    370 "----------------------------------------------------------------------------- 
    371 function! <SID>OnCursorMovedI() 
    372   " NOTE: CursorMovedI is not triggered while the pupup menu is visible. And 
    373   "       it will be triggered when pupup menu is disappeared. 
    374   if pumvisible() 
    375     " do nothing 
    376   elseif exists('s:behav_last') && s:behav_last.repeat 
    377     if <SID>MatchesBehavior(s:behav_last) 
    378       let s:behav_rest = [s:behav_last] 
    379       call feedkeys("\<C-r>=g:AutoComplPop_HandlePopupMenu(1)\<CR>", 'n') 
    380     endif 
    381     unlet s:behav_last 
    382   elseif exists('s:req_popup') 
    383     unlet s:req_popup 
    384     let ftype = (has_key(g:AutoComplPop_Behavior, &filetype) ? &filetype : '*') 
    385     let s:behav_rest = filter(copy(g:AutoComplPop_Behavior[ftype]), 
    386           \                   '<SID>MatchesBehavior(v:val)') 
    387     call feedkeys("\<C-r>=g:AutoComplPop_HandlePopupMenu(1)\<CR>", 'n') 
     233 
     234  let cursor_moved = self.check_cursor_and_update() 
     235  if exists('self.behavs[0]') && self.behavs[0].repeat 
     236    let self.behavs = (self.behavs[0].repeat ? [ self.behavs[0] ] : []) 
     237  elseif cursor_moved  
     238    let self.behavs = copy(exists('g:AutoComplPop_Behavior[&filetype]') ? g:AutoComplPop_Behavior[&filetype] 
     239          \                                                             : g:AutoComplPop_Behavior['*']) 
    388240  else 
    389     call <SID>SetOrRestoreOption(0) 
     241    let self.behavs = [] 
    390242  endif 
    391243 
    392 endfunction 
    393  
    394 "----------------------------------------------------------------------------- 
    395 function! <SID>MatchesBehavior(behav) 
    396   let text = strpart(getline('.'), 0, col('.') - 1) 
    397   return text =~ a:behav.pattern && text !~ a:behav.excluded 
    398 endfunction 
    399  
    400 "----------------------------------------------------------------------------- 
    401 function! g:AutoComplPop_HandlePopupMenu(first) 
    402   echo "" 
     244  let cur_text = strpart(getline('.'), 0, col('.') - 1) 
     245  call filter(self.behavs, 'cur_text =~ v:val.pattern && cur_text !~ v:val.excluded') 
     246 
     247  if empty(self.behavs) 
     248    call self.finish() 
     249    return '' 
     250  endif 
     251 
     252  " In case of dividing words by symbols while popup menu is visible, 
     253  " popup is not available unless input <C-e> or try popup once. 
     254  " (E.g. "for(int", "ab==cd") So duplicates first completion. 
     255  call insert(self.behavs, self.behavs[0]) 
     256 
     257  call s:OptionManager.set('completeopt', 'menuone' . (g:AutoComplPop_CompleteoptPreview ? ',preview' : '')) 
     258  call s:OptionManager.set('complete', g:AutoComplPop_CompleteOption) 
     259  call s:OptionManager.set('ignorecase', g:AutoComplPop_IgnoreCaseOption) 
     260  call s:OptionManager.set('lazyredraw', 1) 
     261 
     262  " use <Plug> for silence instead of <C-r>= 
     263  call feedkeys(self.behavs[0].command . "\<Plug>AutocomplpopOnPopupPost", 'm') 
     264  return '' " for <C-r>= 
     265endfunction 
     266 
     267"----------------------------------------------------------------------------- 
     268function! s:PopupFeeder.finish() 
     269  let self.behavs = [] 
     270  call s:OptionManager.restore_all() 
     271endfunction 
     272 
     273"----------------------------------------------------------------------------- 
     274function! s:PopupFeeder.lock() 
     275  let self.lock_count += 1 
     276endfunction 
     277 
     278"----------------------------------------------------------------------------- 
     279function! s:PopupFeeder.unlock() 
     280  let self.lock_count -= 1 
     281  if self.lock_count < 0 
     282    let self.lock_count = 0 
     283    throw "autocomplpop.vim: not locked" 
     284  endif 
     285endfunction 
     286 
     287"----------------------------------------------------------------------------- 
     288function! s:PopupFeeder.check_cursor_and_update() 
     289  let prev_pos = (exists('self.last_pos') ? self.last_pos : [-1, -1, -1, -1]) 
     290  let self.last_pos = getpos('.') 
     291 
     292  if has('multi_byte_ime') 
     293    return (prev_pos[1] != self.last_pos[1] || prev_pos[2] + 1 == self.last_pos[2] || 
     294          \ prev_pos[2] > self.last_pos[2]) 
     295  else 
     296    return (prev_pos != self.last_pos) 
     297  endif 
     298endfunction 
     299 
     300"----------------------------------------------------------------------------- 
     301function! s:PopupFeeder.on_popup_post() 
    403302  if pumvisible() 
    404303    " a command to restore to original text and select the first match 
    405304    return "\<C-p>\<Down>" 
    406   elseif len(s:behav_rest) 
    407     if a:first 
    408       " In case of dividing words by symbols while popup menu is visible, 
    409       " popup is not available unless input <C-e> or try popup once. (vim's bug?) 
    410       " E.g. "for(int", "ab==cd" 
    411       " So duplicates first completion. 
    412       let s:behav_last = s:behav_rest[0] 
    413       return s:behav_last.command . "\<C-r>=g:AutoComplPop_HandlePopupMenu(0)\<CR>" 
    414     else 
    415       let s:behav_last = remove(s:behav_rest, 0) 
    416       return "\<C-e>" . s:behav_last.command . "\<C-r>=g:AutoComplPop_HandlePopupMenu(0)\<CR>" 
    417     endif 
     305  elseif exists('self.behavs[1]') 
     306    call remove(self.behavs, 0) 
     307    return printf("\<C-e>%s\<C-r>=%sGetPopupFeeder().on_popup_post()\<CR>", 
     308          \       self.behavs[0].command, s:GetSidPrefix()) 
    418309  else 
    419     unlet! s:behav_last 
    420     call <SID>SetOrRestoreOption(0) 
    421     return (a:first ? "" : "\<C-e>") 
     310    call self.finish() 
     311    return "\<C-e>" 
    422312  endif 
    423313endfunction 
    424314 
    425 "----------------------------------------------------------------------------- 
    426 function! <SID>OnInsertLeave() 
    427   call <SID>SetOrRestoreOption(0) 
    428 endfunction 
    429  
    430  
    431 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    432 " INITIALIZE: 
    433 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    434 call <SID>Initialize() 
    435  
    436 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    437  
     315 
     316" OBJECT: OptionManager: sets or restores temporary options ============= {{{1 
     317let s:OptionManager = { 'originals' : {} } 
     318"----------------------------------------------------------------------------- 
     319function! s:OptionManager.set(name, value) 
     320  call extend(self.originals, { a:name : eval('&' . a:name) }, 'keep') 
     321  execute printf('let &%s = a:value', a:name) 
     322endfunction 
     323 
     324"----------------------------------------------------------------------------- 
     325function! s:OptionManager.restore_all() 
     326  for [name, value] in items(self.originals) 
     327    execute printf('let &%s = value', name) 
     328  endfor 
     329  let self.originals = {} 
     330endfunction 
     331 
     332" }}}1 
     333 
     334" INITIALIZATION: GLOBAL OPTIONS: ======================================= {{{1 
     335"........................................................................... 
     336if !exists('g:AutoComplPop_NotEnableAtStartup') 
     337  let g:AutoComplPop_NotEnableAtStartup = 0 
     338endif 
     339"......................................................................... 
     340if !exists('g:AutoComplPop_IgnoreCaseOption') 
     341  let g:AutoComplPop_IgnoreCaseOption = 0 
     342endif 
     343"......................................................................... 
     344if !exists('g:AutoComplPop_CompleteOption') 
     345  let g:AutoComplPop_CompleteOption = '.,w,b,k' 
     346endif 
     347 
     348"......................................................................... 
     349if !exists('g:AutoComplPop_CompleteoptPreview') 
     350  let g:AutoComplPop_CompleteoptPreview = 0 
     351endif 
     352"......................................................................... 
     353if !exists('g:AutoComplPop_Behavior') 
     354  let g:AutoComplPop_Behavior = {} 
     355endif 
     356call extend(g:AutoComplPop_Behavior, { 
     357      \   '*' : [ 
     358      \     { 
     359      \       'command'  : "\<C-n>", 
     360      \       'pattern'  : '\k\k$', 
     361      \       'excluded' : '^$', 
     362      \       'repeat'   : 0, 
     363      \     }, 
     364      \     { 
     365      \       'command'  : "\<C-x>\<C-f>", 
     366      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     367      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     368      \       'repeat'   : 1, 
     369      \     }, 
     370      \   ], 
     371      \   'ruby' : [ 
     372      \     { 
     373      \       'command'  : "\<C-n>", 
     374      \       'pattern'  : '\k\k$', 
     375      \       'excluded' : '^$', 
     376      \       'repeat'   : 0, 
     377      \     }, 
     378      \     { 
     379      \       'command'  : "\<C-x>\<C-f>", 
     380      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     381      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     382      \       'repeat'   : 1, 
     383      \     }, 
     384      \     { 
     385      \       'command'  : "\<C-x>\<C-o>", 
     386      \       'pattern'  : '\([^. \t]\.\|^:\|\W:\)$', 
     387      \       'excluded' : (has('ruby') ? '^$' : '.*'), 
     388      \       'repeat'   : 0, 
     389      \     }, 
     390      \   ], 
     391      \   'python' : [ 
     392      \     { 
     393      \       'command'  : "\<C-n>", 
     394      \       'pattern'  : '\k\k$', 
     395      \       'excluded' : '^$', 
     396      \       'repeat'   : 0, 
     397      \     }, 
     398      \     { 
     399      \       'command'  : "\<C-x>\<C-f>", 
     400      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     401      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     402      \       'repeat'   : 1, 
     403      \     }, 
     404      \     { 
     405      \       'command'  : "\<C-x>\<C-o>", 
     406      \       'pattern'  : '\k\.$', 
     407      \       'excluded' : (has('python') ? '^$' : '.*'), 
     408      \       'repeat'   : 0, 
     409      \     }, 
     410      \   ], 
     411      \   'html' : [ 
     412      \     { 
     413      \       'command'  : "\<C-n>", 
     414      \       'pattern'  : '\k\k$', 
     415      \       'excluded' : '^$', 
     416      \       'repeat'   : 0, 
     417      \     }, 
     418      \     { 
     419      \       'command'  : "\<C-x>\<C-f>", 
     420      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     421      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     422      \       'repeat'   : 1, 
     423      \     }, 
     424      \     { 
     425      \       'command'  : "\<C-x>\<C-o>", 
     426      \       'pattern'  : '\(<\k*\|<\/\k*\|<[^>]* \)$', 
     427      \       'excluded' : '^$', 
     428      \       'repeat'   : 1, 
     429      \     }, 
     430      \   ], 
     431      \   'xhtml' : [ 
     432      \     { 
     433      \       'command'  : "\<C-n>", 
     434      \       'pattern'  : '\k\k$', 
     435      \       'excluded' : '^$', 
     436      \       'repeat'   : 0, 
     437      \     }, 
     438      \     { 
     439      \       'command'  : "\<C-x>\<C-f>", 
     440      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     441      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     442      \       'repeat'   : 1, 
     443      \     }, 
     444      \     { 
     445      \       'command'  : "\<C-x>\<C-o>", 
     446      \       'pattern'  : '\(<\k*\|<\/\k*\|<[^>]* \)$', 
     447      \       'excluded' : '^$', 
     448      \       'repeat'   : 1, 
     449      \     }, 
     450      \   ], 
     451      \   'css' : [ 
     452      \     { 
     453      \       'command'  : "\<C-n>", 
     454      \       'pattern'  : '\k\k$', 
     455      \       'excluded' : '^$', 
     456      \       'repeat'   : 0, 
     457      \     }, 
     458      \     { 
     459      \       'command'  : "\<C-x>\<C-f>", 
     460      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     461      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     462      \       'repeat'   : 1, 
     463      \     }, 
     464      \     { 
     465      \       'command'  : "\<C-x>\<C-o>", 
     466      \       'pattern'  : '[:@!]\s*\k*$\|\(^\|[;{]\)\s\+\k\+$', 
     467      \       'excluded' : '^$', 
     468      \       'repeat'   : 1, 
     469      \     }, 
     470      \   ], 
     471      \   'scheme' : [ 
     472      \     { 
     473      \       'command'  : "\<C-n>", 
     474      \       'pattern'  : '\k\k$', 
     475      \       'excluded' : '^$', 
     476      \       'repeat'   : 0, 
     477      \     }, 
     478      \     { 
     479      \       'command'  : "\<C-n>", 
     480      \       'pattern'  : '(\k$', 
     481      \       'excluded' : '^$', 
     482      \       'repeat'   : 0, 
     483      \     }, 
     484      \     { 
     485      \       'command'  : "\<C-x>\<C-f>", 
     486      \       'pattern'  : (has('win32') || has('win64') ? '\f[/\\]\f*$' : '\f[/]\f*$'), 
     487      \       'excluded' : '[*/\\][/\\]\f*$\|[^[:print:]]\f*$', 
     488      \       'repeat'   : 1, 
     489      \     }, 
     490      \   ], 
     491      \ } ,'keep') 
     492 
     493" INITIALIZATION: COMMANDS, AUTOCOMMANDS, MAPPINGS, ETC.: =============== {{{1 
     494command! -bar -narg=0 AutoComplPopEnable  call s:Enable() 
     495command! -bar -narg=0 AutoComplPopDisable call s:Disable() 
     496command! -bar -narg=0 AutoComplPopLock    call s:PopupFeeder.lock() 
     497command! -bar -narg=0 AutoComplPopUnlock  call s:PopupFeeder.unlock() 
     498 
     499inoremap <silent> <expr> <Plug>AutocomplpopOnPopupPost <SID>GetPopupFeeder().on_popup_post() 
     500 
     501if !g:AutoComplPop_NotEnableAtStartup 
     502  AutoComplPopEnable 
     503endif 
     504 
     505" }}}1 
     506"============================================================================= 
     507" vim: set fdm=marker: 
  • dotfiles/vim/ishihara/.vim/plugin/fuzzyfinder.vim

    r7191 r9179  
    1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
     1"============================================================================= 
    22" fuzzyfinder.vim : The fuzzy/partial pattern explorer for 
    3 "                   buffer/file/MRU/favorite/tag/etc. 
    4 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
     3"                   buffer/file/MRU/command/favorite/tag/etc. 
     4"============================================================================= 
    55" 
    66" Author:  Takeshi Nishida <ns9tks(at)gmail(dot)com> 
    7 " Version: 2.5, for Vim 7.1 
     7" Version: 2.6, for Vim 7.1 
    88" Licence: MIT Licence 
    99" URL:     http://www.vim.org/scripts/script.php?script_id=1984 
    1010" 
    11 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    12 " DOCUMENT: 
    13 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    14 " Description: {{{1 
     11"============================================================================= 
     12" DOCUMENT: (Japanese: http://vim.g.hatena.ne.jp/keyword/fuzzyfinder.vim) 
     13" 
     14" Description: ---------------------------------------------------------- {{{1 
    1515"   Fuzzyfinder provides convenient ways to quickly reach the buffer/file you 
    1616"   want. Fuzzyfinder finds matching files/buffers with a fuzzy/partial 
     
    3636"     - File mode 
    3737"     - MRU-file mode (most recently used files) 
     38"     - MRU-command mode (most recently used command-lines) 
    3839"     - Favorite-file mode 
    3940"     - Directory mode (yet another :cd command) 
     
    4344"   Fuzzyfinder supports the multibyte. 
    4445" 
    45 "----------------------------------------------------------------------------- 
    46 " Installation: {{{1 
     46" Installation: --------------------------------------------------------- {{{1 
    4747"   Drop this file in your plugin directory. 
    4848" 
    49 "----------------------------------------------------------------------------- 
    50 " Usage: {{{1 
     49" Usage: ---------------------------------------------------------------- {{{1 
    5150"   Starting Fuzzyfinder: 
    5251"     You can start Fuzzyfinder by the following commands: 
     
    5554"       :FuzzyFinderFile        - launchs file-mode Fuzzyfinder. 
    5655"       :FuzzyFinderMruFile     - launchs MRU-file-mode Fuzzyfinder. 
     56"       :FuzzyFinderMruCmd      - launchs MRU-command-mode Fuzzyfinder. 
    5757"       :FuzzyFinderFavFile     - launchs favorite-file-mode Fuzzyfinder. 
    5858"       :FuzzyFinderDir         - launchs directory-mode Fuzzyfinder. 
     
    7979" 
    8080"     If entered pattern matched the item exactly, the item is shown first. 
    81 "     Same applies to the item number in the buffer/MRU/favorite mode.  The 
     81"     Same applies to the item number in the buffer/MRU/favorite mode. The 
    8282"     item whose file name has longer prefix matching is placed upper. The 
    8383"     item which matched more sequentially is placed upper. It lets the first 
    8484"     item into selected in completion menu. 
    8585" 
    86 "     You can open the selected item in various ways: 
     86"     You can open a selected item in various ways: 
    8787"       <CR>  - opens in a previous window. 
    8888"       <C-j> - opens in a split window. 
    8989"       <C-k> - opens in a vertical-split window. 
    9090"       <C-]> - opens in a new tab page. 
    91 "     These key mappings are customizable. 
    92 " 
    93 "     To cancel and return to previous window, leave the insert mode. 
    94 " 
    95 "     To Switch the mode without leaving a insert mode, use <C-l> or <C-o>. 
     91"     In MRU-command mode, <CR> executes a selected command and others just 
     92"     put it into a command-line. These key mappings are customizable. 
     93" 
     94"     To cancel and return to previous window, leave Insert mode. 
     95" 
     96"     To Switch the mode without leaving Insert mode, use <C-l> or <C-o>. 
    9697"     This key mapping is customizable. 
    9798" 
     
    127128"     set as below: 
    128129" 
    129 "       let g:FuzzyFinderOptions.File.abbrev_map  = { 
     130"       let g:FuzzyFinderOptions.Base.abbrev_map  = { 
    130131"             \   "^WORK" : [ 
    131132"             \     "~/project/**/src/", 
     
    150151"     Fuzzyfinder writes information of the MRU, favorite, etc to the file by 
    151152"     default (~/.vimfuzzyfinder). 
     153 
     154"     :FuzzyFinderEditInfo command is helpful in editing your information 
     155"     file. This command read the information file in new unnamed buffer. 
     156"     Close the buffer and the information file will be updated. 
    152157" 
    153158"   About Cache: 
     
    158163"     Migemo is a search method for Japanese language. 
    159164" 
    160 "----------------------------------------------------------------------------- 
    161 " Options: {{{1 
     165" Options: -------------------------------------------------------------- {{{1 
    162166"   You can set options via g:FuzzyFinderOptions which is a dictionary. See 
    163167"   the folded section named "INITIALIZATION: GLOBAL OPTIONS:" for details. To 
     
    165169"   OPTIONS into your vimrc file and edit those values. 
    166170" 
    167 "----------------------------------------------------------------------------- 
    168 " Setting Example: {{{1 
     171" Setting Example: ------------------------------------------------------ {{{1 
    169172"   let g:FuzzyFinderOptions = { 'Base':{}, 'Buffer':{}, 'File':{}, 'MruFile':{}, 'FavFile':{}, 'Dir':{}, 'Tag':{}, 'TaggedFile':{}} 
    170173"   let g:FuzzyFinderOptions.Base.ignore_case = 1 
    171 "   let g:FuzzyFinderOptions.File.abbrev_map  = { 
     174"   let g:FuzzyFinderOptions.Base.abbrev_map  = { 
    172175"         \   '\C^VR' : [ 
    173176"         \     '$VIMRUNTIME/**', 
     
    178181"         \ } 
    179182"   let g:FuzzyFinderOptions.MruFile.max_item = 400 
     183"   let g:FuzzyFinderOptions.MruCmd.max_item = 400 
    180184"   nnoremap <silent> <C-n>      :FuzzyFinderBuffer<CR> 
    181185"   nnoremap <silent> <C-p>      :FuzzyFinderFile<CR> 
    182186"   nnoremap <silent> <C-p>      :FuzzyFinderFile <C-r>=expand('%:~:.')[:-1-len(expand('%:~:.:t'))]<CR><CR> 
    183187"   nnoremap <silent> <C-f><C-n> :FuzzyFinderMruFile<CR> 
     188"   nnoremap <silent> <C-f><C-p> :FuzzyFinderMruCmd<CR> 
    184189"   nnoremap <silent> <C-f><C-f> :FuzzyFinderFavFile<CR> 
    185190"   nnoremap <silent> <C-f><C-d> :FuzzyFinderDir <C-r>=fnamemodify('.', ':p')<CR><CR> 
     
    188193"   nnoremap <silent> <C-]>      :FuzzyFinderTag! <C-r>=expand('<cword>')<CR><CR> 
    189194" 
    190 "----------------------------------------------------------------------------- 
    191 " Thanks: {{{1 
     195" Special Thanks: ------------------------------------------------------- {{{1 
    192196"   Vincent Wang 
    193197"   Ingo Karkat 
     
    195199"   Brian Doyle 
    196200"   id:secondlife 
    197 " 
    198 "----------------------------------------------------------------------------- 
    199 " ChangeLog: {{{1 
     201"   Matt Tolton 
     202" 
     203" ChangeLog: ------------------------------------------------------------ {{{1 
     204"   2.6: 
     205"     - Revived MRU-command mode. The problem with a command-line abbreviation 
     206"       was solved. 
     207"     - Changed the specification of the information file. 
     208"     - Added :FuzzyFinderEditInfo command. 
     209 
     210"   2.5.1: 
     211"     - Fixed to be able to match "foo/./bar" by "foo/**/bar" in File mode. 
     212"     - Fixed to be able to open a space-containing file in File mode. 
     213"     - Fixed to honor the current working directory properly in File mode. 
     214" 
    200215"   2.5: 
    201216"     - Fixed the bug that a wrong initial text is entered after switching to a 
     
    223238"     - Restructured the option system AGAIN. Sorry :p 
    224239"     - Changed to inherit a typed text when switching a mode without leaving 
    225 "       a insert mode. 
     240"       Insert mode. 
    226241"     - Changed commands which launch explorers to be able to take a argument 
    227242"       for initial text. 
     
    251266"   1.5: 
    252267"     - Added the directory mode. 
    253 "     - Fixed the bug that it caused an error when switch a mode in the insert 
     268"     - Fixed the bug that it caused an error when switch a mode in Insert 
    254269"       mode. 
    255270"     - Changed g:FuzzyFinder_KeySwitchMode type to a list. 
     
    332347"     - First release. 
    333348" 
    334 "----------------------------------------------------------------------------- 
    335349" }}}1 
    336  
    337 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    338 " INCLUDE GUARD: 
    339 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    340  
    341 " INCLUDE GUARD {{{1 
    342 if exists('loaded_fuzzyfinder') || v:version < 700 
     350"============================================================================= 
     351 
     352" INCLUDE GUARD: ======================================================== {{{1 
     353if v:version < 701 
     354  echoerr "Sorry, Fuzzyfinder doesn't support this version of Vim." 
     355  finish 
     356elseif exists('loaded_fuzzyfinder') 
    343357  finish 
    344358endif 
    345359let loaded_fuzzyfinder = 1 
    346 " }}}1 
    347  
    348 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    349 " FUNCTIONS: 
    350 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    351  
    352 function! s:Initialize() 
    353   " INITIALIZATION: GLOBAL OPTIONS: {{{1 
    354   "........................................................................... 
    355   " stores user-defined g:FuzzyFinderOptions {{{2 
    356   let user_options = (exists('g:FuzzyFinderOptions') ? g:FuzzyFinderOptions : {}) " }}}2 
    357  
    358   " Initializes g:FuzzyFinderOptions. 
    359   let g:FuzzyFinderOptions = { 'Base':{}, 'Buffer':{}, 'File':{}, 'MruFile':{}, 'FavFile':{}, 'Dir':{}, 'Tag':{}, 'TaggedFile':{}} 
    360   "........................................................................... 
    361   " [All Mode] This is mapped to select completion item or finish input and 
    362   " open a buffer/file in previous window. 
    363   let g:FuzzyFinderOptions.Base.key_open = '<CR>' 
    364   " [All Mode] This is mapped to select completion item or finish input and 
    365   " open a buffer/file in split new window 
    366   let g:FuzzyFinderOptions.Base.key_open_split = '<C-j>' 
    367   " [All Mode] This is mapped to select completion item or finish input and 
    368   " open a buffer/file in vertical-split new window. 
    369   let g:FuzzyFinderOptions.Base.key_open_vsplit = '<C-k>' 
    370   " [All Mode] This is mapped to select completion item or finish input and 
    371   " open a buffer/file in a new tab page. 
    372   let g:FuzzyFinderOptions.Base.key_open_tab = '<C-]>' 
    373   " [All Mode] This is mapped to switch to the next mode. 
    374   let g:FuzzyFinderOptions.Base.key_next_mode = '<C-l>' 
    375   " [All Mode] This is mapped to switch to the previous mode. 
    376   let g:FuzzyFinderOptions.Base.key_prev_mode = '<C-o>' 
    377   " [All Mode] This is mapped to temporarily switch whether or not to ignore 
    378   " case. 
    379   let g:FuzzyFinderOptions.Base.key_ignore_case = '<C-t>' 
    380   " [All Mode] This is the file name to write information of the MRU, etc. If 
    381   " "" was set, it does not write to the file. 
    382   let g:FuzzyFinderOptions.Base.info_file = '~/.vimfuzzyfinder' 
    383   " [All Mode] It does not start a completion if a length of entered text is 
    384   " less than this. 
    385   let g:FuzzyFinderOptions.Base.min_length = 0 
    386   " [All Mode] It ignores case in search patterns if non-zero is set. 
    387   let g:FuzzyFinderOptions.Base.ignore_case = 1 
    388   " [All Mode] It does not remove caches of completion lists at the end of 
    389   " explorer to reuse at the next time if non-zero was set. 
    390   let g:FuzzyFinderOptions.Base.lasting_cache = 1 
    391   " [All Mode] It uses Migemo if non-zero is set. 
    392   let g:FuzzyFinderOptions.Base.migemo_support = 0 
    393   "........................................................................... 
    394   " [Buffer Mode] It disables all functions of this mode if zero was set. 
    395   let g:FuzzyFinderOptions.Buffer.mode_available = 1 
    396   " [Buffer Mode] This is a dictionary. Each value must be a list. All matchs 
    397   " of a key in entered text is expanded with the value. 
    398   let g:FuzzyFinderOptions.Buffer.abbrev_map = {} 
    399   " [Buffer Mode] The items whose :ls-indicators match this are excluded from 
    400   " the completion list. 
    401   let g:FuzzyFinderOptions.Buffer.excluded_indicator = '[u\-]' 
    402   "........................................................................... 
    403   " [File Mode] It disables all functions of this mode if zero was set. 
    404   let g:FuzzyFinderOptions.File.mode_available = 1 
    405   " [File Mode] This is a dictionary. Each value must be a list. All matchs of 
    406   " a key in entered text is expanded with a value. 
    407   let g:FuzzyFinderOptions.File.abbrev_map = {} 
    408   " [File Mode] The items matching this are excluded from the completion list. 
    409   let g:FuzzyFinderOptions.File.excluded_path = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|((^|[/\\])\.[/\\]$)' 
    410   " [File Mode] If a number of matched items was over this, the completion 
    411   " process is aborted. 
    412   let g:FuzzyFinderOptions.File.matching_limit = 200 
    413   "........................................................................... 
    414   " [Mru-File Mode] It disables all functions of this mode if zero was set. 
    415   let g:FuzzyFinderOptions.MruFile.mode_available = 1 
    416   " [Mru-File Mode] This is a dictionary. Each value must be a list. All 
    417   " matchs of a key in entered text is expanded with a value.  
    418   let g:FuzzyFinderOptions.MruFile.abbrev_map = {} 
    419   " [Mru-File Mode] The items matching this are excluded from the completion 
    420   " list. 
    421   let g:FuzzyFinderOptions.MruFile.excluded_path = '\v\~$|\.bak$|\.swp$' 
    422   " [Mru-File Mode] It ignores special buffers if non-zero was set. 
    423   let g:FuzzyFinderOptions.MruFile.no_special_buffer = 1 
    424   " [Mru-File Mode] This is a string to format registered time. See :help 
    425   " strftime() for details. 
    426   let g:FuzzyFinderOptions.MruFile.time_format = '(%x %H:%M:%S)' 
    427   " [Mru-File Mode] This is an upper limit of MRU items to be stored. 
    428   let g:FuzzyFinderOptions.MruFile.max_item = 99 
    429   "........................................................................... 
    430   " [Favorite-File Mode] It disables all functions of this mode if zero was 
    431   " set. 
    432   let g:FuzzyFinderOptions.FavFile.mode_available = 1 
    433   " [Favorite-File Mode] This is a dictionary. Each value must be a list. All 
    434   " matchs of a key in entered text is expanded with a value.  
    435   let g:FuzzyFinderOptions.FavFile.abbrev_map = {} 
    436   " [Favorite-File Mode] This is a string to format registered time. See :help 
    437   " strftime() for details. 
    438   let g:FuzzyFinderOptions.FavFile.time_format = '(%x %H:%M:%S)' 
    439   "........................................................................... 
    440   " [Directory Mode] It disables all functions of this mode if zero was set. 
    441   let g:FuzzyFinderOptions.Dir.mode_available = 1 
    442   " [Directory Mode] This is a dictionary. Each value must be a list. All 
    443   " matchs of a key in entered text is expanded with a value.  
    444   let g:FuzzyFinderOptions.Dir.abbrev_map = {} 
    445   " [Directory Mode] The items matching this are excluded from the completion 
    446   " list. 
    447   let g:FuzzyFinderOptions.Dir.excluded_path = '\v(^|[/\\])\.{1,2}[/\\]$' 
    448   "........................................................................... 
    449   " [Tag Mode] It disables all functions of this mode if zero was set. 
    450   let g:FuzzyFinderOptions.Tag.mode_available = 1 
    451   " [Tag Mode] This is a dictionary. Each value must be a list. All matchs of 
    452   " a key in entered text is expanded with a value.  
    453   let g:FuzzyFinderOptions.Tag.abbrev_map = {} 
    454   " [Tag Mode] The items matching this are excluded from the completion list. 
    455   let g:FuzzyFinderOptions.Tag.excluded_path = '\v\~$|\.bak$|\.swp$' 
    456   " [Tag Mode] If a number of matched items was over this, the completion 
    457   " process is aborted. 
    458   let g:FuzzyFinderOptions.Tag.matching_limit = 200 
    459   "........................................................................... 
    460   " [Tagged-File Mode] It disables all functions of this mode if zero was set. 
    461   let g:FuzzyFinderOptions.TaggedFile.mode_available = 1 
    462   " [Tagged-File Mode] This is a dictionary. Each value must be a list. All 
    463   " matchs of a key in entered text is expanded with a value.  
    464   let g:FuzzyFinderOptions.TaggedFile.abbrev_map = {} 
    465   " [Tagged-File Mode] If a number of matched items was over this, the 
    466   " completion process is aborted. 
    467   let g:FuzzyFinderOptions.TaggedFile.matching_limit = 200 
    468  
    469   "........................................................................... 
    470   " hidden options {{{2 
    471   let g:FuzzyFinderOptions.Base.info_version = 104 
    472   let g:FuzzyFinderOptions.Base.path_separator = (has('win32') || has('win64') ? '\' : '/') 
    473   let g:FuzzyFinderOptions.Base.prompt = '>' 
    474   let g:FuzzyFinderOptions.Base.matching_rate_base = 10000000 
    475   let g:FuzzyFinderOptions.Base.sid_prefix = matchstr(expand('<sfile>'), '<SNR>\d\+_') " global name of 's:' 
    476   let g:FuzzyFinderOptions.Base.msg_rm_info = "==================================================\n" . 
    477         \                                     "  Your fuzzyfinder information file is no longer \n"  . 
    478         \                                     "  supported. Please remove\n"                         . 
    479         \                                     "  \"%s\".\n"                                          . 
    480         \                                     "==================================================" 
    481  
    482   " overwrites default values of g:FuzzyFinderOptions with user-defined values {{{2 
    483   call map(user_options, 'extend(g:FuzzyFinderOptions[v:key], v:val, ''force'')') 
    484   call map(copy(g:FuzzyFinderMode), 'v:val.extend_options()') 
    485   " }}}2 
    486  
    487   " INITIALIZATION: COMMANDS AND AUTOCOMMANDS: {{{1 
    488   "........................................................................... 
    489   augroup FuzzyFinderGlobalAutoCommand 
    490     autocmd! 
    491     autocmd BufEnter     * for m in s:GetAvailableModes() | call m.on_buf_enter() | endfor 
    492     autocmd BufWritePost * for m in s:GetAvailableModes() | call m.on_buf_write_post() | endfor 
    493   augroup END 
    494  
    495   command! -bang -narg=? -complete=buffer FuzzyFinderBuffer      call g:FuzzyFinderMode.Buffer.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    496   command! -bang -narg=? -complete=file   FuzzyFinderFile        call g:FuzzyFinderMode.File.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    497   command! -bang -narg=? -complete=file   FuzzyFinderMruFile     call g:FuzzyFinderMode.MruFile.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    498   command! -bang -narg=? -complete=file   FuzzyFinderFavFile     call g:FuzzyFinderMode.FavFile.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    499   command! -bang -narg=? -complete=dir    FuzzyFinderDir         call g:FuzzyFinderMode.Dir.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    500   command! -bang -narg=? -complete=tag    FuzzyFinderTag         call g:FuzzyFinderMode.Tag.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    501   command! -bang -narg=? -complete=file   FuzzyFinderTaggedFile  call g:FuzzyFinderMode.TaggedFile.launch(<q-args>, len('<bang>'), s:GetCurrentTagFiles()) 
    502   command! -bang -narg=? -complete=file   FuzzyFinderAddFavFile  call g:FuzzyFinderMode.FavFile.add(<q-args>, 1) 
    503   command! -bang -narg=0                  FuzzyFinderRemoveCache for m in s:GetAvailableModes() | call m.empty_cache_if_existed(1) | endfor 
    504  
    505 " }}}1 
    506 endfunction 
    507  
    508 " CORE FUNCTIONS: {{{1 
     360 
     361 
     362" FUNCTION: CORE FUNCTIONS: ============================================= {{{1 
    509363"----------------------------------------------------------------------------- 
    510364function! s:GetAvailableModes() 
     
    512366endfunction 
    513367 
    514  
    515 " LIST FUNCTIONS: {{{1 
     368"----------------------------------------------------------------------------- 
     369function! s:GetSidPrefix() 
     370  return matchstr(expand('<sfile>'), '<SNR>\d\+_') 
     371endfunction 
     372 
     373"----------------------------------------------------------------------------- 
     374function! s:OnCmdCR() 
     375  for m in s:GetAvailableModes() 
     376    call m.on_command_pre(getcmdtype() . getcmdline()) 
     377  endfor 
     378 
     379  " this is not mapped again (:help recursive_mapping) 
     380  return "\<CR>" 
     381endfunction 
     382 
     383" FUNCTION: LIST FUNCTIONS: ============================================= {{{1 
    516384"----------------------------------------------------------------------------- 
    517385function! s:Unique(in) 
     
    535403 
    536404"----------------------------------------------------------------------------- 
     405" [ [0], [1,2], [3] ] -> [ 0, 1, 2, 3 ] 
    537406function! s:Concat(in) 
    538407  let result = [] 
     
    540409    let result += l 
    541410  endfor 
     411  return result 
     412endfunction 
     413 
     414"----------------------------------------------------------------------------- 
     415" [ [ 0, 1 ], [ 2, 3, 4 ], ] -> [ [0,2], [0,3], [0,4], [1,2], [1,3], [1,4] ] 
     416function! s:CartesianProduct(lists) 
     417  if empty(a:lists) 
     418    return [] 
     419  endif 
     420 
     421  "let result = map((a:lists[0]), '[v:val]') 
     422  let result = [ [] ] 
     423  for l in a:lists 
     424    let temp = [] 
     425    for r in result 
     426      let temp += map(copy(l), 'add(copy(r), v:val)') 
     427    endfor 
     428    let result = temp 
     429  endfor 
     430 
    542431  return result 
    543432endfunction 
     
    572461endfunction 
    573462 
    574 " MISC: {{{1 
     463" FUNCTION: MISC: ======================================================= {{{1 
    575464"----------------------------------------------------------------------------- 
    576465function! s:ConvertWildcardToRegexp(expr) 
     
    596485 
    597486  return s:Unique(result) 
     487endfunction 
     488 
     489"----------------------------------------------------------------------------- 
     490" "**" is expanded to ["**", "."]. E.g.: "foo/**/bar" -> [ "foo/./bar", "foo/**/bar" ] 
     491function! s:ExpandEx(dir) 
     492  if a:dir !~ '\S' 
     493    return [''] 
     494  endif 
     495 
     496  " [ ["foo/"], ["**/", "./" ], ["bar/"] ] 
     497  let lists = [] 
     498  for i in split(a:dir, '[/\\]\zs') 
     499    let m = matchlist(i, '^\*\{2,}\([/\\]*\)$') 
     500    call add(lists, (empty(m) ? [i] : [i, '.' . m[1]])) 
     501  endfor 
     502 
     503  " expand wlidcards 
     504  return split(join(map(s:CartesianProduct(lists), 'expand(join(v:val, ""))'), "\n"), "\n") 
    598505endfunction 
    599506 
     
    656563endfunction 
    657564 
    658 " }}}1 
    659  
    660 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    661 " OBJECTS: 
    662 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    663  
    664 " FuzzyFinderMode: Base: launch {{{1 
     565 
     566" OBJECT: FuzzyFinderMode: Base: launch ================================= {{{1 
    665567let g:FuzzyFinderMode = { 'Base' : {} } 
    666568"----------------------------------------------------------------------------- 
     
    671573  let self.tag_files = a:tag_files " to get local value of current buffer 
    672574  let self.last_col = -1 
    673   call self.read_info_from_file() 
     575  call s:InfoFileManager.load() 
    674576  if !self.mode_available 
    675577    echo 'This mode is not available: ' . self.to_str() 
     
    682584 
    683585  " local autocommands 
    684   augroup FuzzyFinderLocalAutoCommand 
     586  augroup FuzzyfinderLocal 
    685587    autocmd! 
    686588    execute 'autocmd CursorMovedI <buffer>        call ' . self.to_str('on_cursor_moved_i()') 
     
    706608  call self.on_mode_enter() 
    707609 
    708   " Starts insert mode and makes CursorMovedI event now. Command prompt is 
     610  " Starts Insert mode and makes CursorMovedI event now. Command prompt is 
    709611  " needed to forces a completion menu to update every typing. 
    710612  call setline(1, self.prompt . a:initial_text) 
     
    712614endfunction 
    713615 
    714 " FuzzyFinderMode: Base: EVENT HANDLERS {{{1 
     616" OBJECT: FuzzyFinderMode: Base: EVENT HANDLERS ========================= {{{1 
    715617"----------------------------------------------------------------------------- 
    716618function! g:FuzzyFinderMode.Base.on_cursor_moved_i() 
     
    761663 
    762664"----------------------------------------------------------------------------- 
     665function! g:FuzzyFinderMode.Base.on_command_pre(cmd) 
     666endfunction 
     667 
     668"----------------------------------------------------------------------------- 
    763669function! g:FuzzyFinderMode.Base.on_cr(index, check_dir) 
    764670  if pumvisible() 
     
    790696        \   ':vsplit ', 
    791697        \   ':tabedit ', 
    792         \ ][a:mode] . a:expr . "\<CR>" 
     698        \ ][a:mode] . escape(a:expr, ' ') . "\<CR>" 
    793699endfunction 
    794700 
     
    808714endfunction 
    809715 
    810 " FuzzyFinderMode: Base: INFO FILE {{{1 
    811 "----------------------------------------------------------------------------- 
    812 function! g:FuzzyFinderMode.Base.read_info_from_file() 
    813   let s:info = {} 
    814  
    815   try 
    816     let lines = filter(map(readfile(expand(self.info_file)), 
    817           \                'matchlist(v:val, "^\\([^\\t]\\+\\)\\t\\(.*\\)$")'), 
    818           \            '!empty(v:val)') 
    819   catch /.*/  
    820     return 
    821   endtry 
    822  
    823   let lines = filter(map(readfile(expand(self.info_file)), 
    824         \                'matchlist(v:val, "^\\([^\\t]\\+\\)\\t\\(.*\\)$")'), 
    825         \            '!empty(v:val)') 
    826  
    827   for line in lines 
    828     if line[1] == 'version' && line[2] != self.info_version 
    829       echo printf(self.msg_rm_info, expand(self.info_file)) 
    830       let self.info_file = '' 
    831       return 
    832     endif 
    833  
    834     let s:info[line[1]] = (exists('s:info[line[1]]') ? s:info[line[1]] : []) + [ eval(line[2]) ] 
    835   endfor 
    836 endfunction 
    837  
    838 "----------------------------------------------------------------------------- 
    839 function! g:FuzzyFinderMode.Base.write_info_to_file() 
    840   let s:info.version = [self.info_version] 
    841   let lines = [] 
    842   for [key, value] in items(s:info) 
    843     let lines += map(copy(value), 'key . "\t" . string(v:val)') 
    844   endfor 
    845  
    846   try 
    847     call writefile(lines, expand(self.info_file)) 
    848   catch /.*/  
    849   endtry 
    850 endfunction 
    851  
    852 " FuzzyFinderMode: Base: COMPLETION {{{1 
     716" OBJECT: FuzzyFinderMode: Base: INFO =================================== {{{1 
     717"----------------------------------------------------------------------------- 
     718" export string list 
     719function! g:FuzzyFinderMode.Base.serialize_info() 
     720  let header = self.to_key() . "\t" 
     721  return map(copy(self.info), 'header . string(v:val)') 
     722endfunction 
     723 
     724"----------------------------------------------------------------------------- 
     725" import related items from string list 
     726function! g:FuzzyFinderMode.Base.deserialize_info(lines) 
     727  let header = self.to_key() . "\t" 
     728  let self.info = map(filter(copy(a:lines), 'v:val[: len(header) - 1] ==# header'), 
     729        \             'eval(v:val[len(header) :])') 
     730endfunction 
     731 
     732" OBJECT: FuzzyFinderMode: Base: COMPLETION ============================= {{{1 
    853733"----------------------------------------------------------------------------- 
    854734function! g:FuzzyFinderMode.Base.complete(findstart, base) 
     
    883763        \        "  return %s.complete(a:findstart, a:base)\n" . 
    884764        \        "endfunction", a:name, self.to_str()) 
    885   return self.sid_prefix . a:name 
     765  return s:GetSidPrefix() . a:name 
    886766endfunction 
    887767 
     
    976856" glob with caching-feature, etc. 
    977857function! g:FuzzyFinderMode.Base.glob_ex(dir, file, excluded, matching_limit) 
    978   let key = (a:dir =~ '\S' ? a:dir : ' ') 
     858  let key = fnamemodify(a:dir, ':p') 
    979859 
    980860  call extend(self, { 'cache' : {} }, 'keep') 
    981861  if !exists('self.cache[key]') 
    982862    echo 'Caching file list...' 
    983     let dirs = (key =~ '\S' ? split(expand(a:dir), "\n") : [""]) 
     863    let dirs = s:ExpandEx(a:dir) 
    984864    let self.cache[key] = s:Concat(map(copy(dirs), 'split(glob(v:val . ".*"), "\n") + ' . 
    985           \                               'split(glob(v:val . "*" ), "\n")')) 
     865          \                            'split(glob(v:val . "*" ), "\n")')) 
    986866 
    987867    if len(dirs) <= 1 
     
    1004884 
    1005885 
    1006 " FuzzyFinderMode: Base: MISC {{{1 
     886" OBJECT: FuzzyFinderMode: Base: MISC =================================== {{{1 
    1007887"----------------------------------------------------------------------------- 
    1008888function! g:FuzzyFinderMode.Base.empty_cache_if_existed(force) 
     
    1061941" }}}2 
    1062942 
    1063 " FuzzyFinderMode: Buffer: {{{1 
     943" OBJECT: FuzzyFinderMode: Buffer: ====================================== {{{1 
    1064944let g:FuzzyFinderMode.Buffer = copy(g:FuzzyFinderMode.Base) 
    1065945"----------------------------------------------------------------------------- 
     
    1076956 
    1077957"----------------------------------------------------------------------------- 
    1078 unlet g:FuzzyFinderMode.Buffer.on_open 
    1079958function! g:FuzzyFinderMode.Buffer.on_open(expr, mode) 
    1080959  " attempts to convert the path to the number for handling unnamed buffer 
    1081   let buf = a:expr 
     960  let buf = escape(a:expr, ' ') 
    1082961  for buf_info in s:GetBuffers() 
    1083     if buf == buf_info.path 
     962    if buf == escape(buf_info.path, ' ') 
    1084963      let buf = buf_info.nr 
    1085964      break 
     
    1095974 
    1096975 
    1097 " FuzzyFinderMode: File: {{{1 
     976" OBJECT: FuzzyFinderMode: File: ======================================== {{{1 
    1098977let g:FuzzyFinderMode.File = copy(g:FuzzyFinderMode.Base) 
    1099978"----------------------------------------------------------------------------- 
     
    1115994 
    1116995 
    1117 " FuzzyFinderMode: MruFile: {{{1 
     996" OBJECT: FuzzyFinderMode: MruFile: ===================================== {{{1 
    1118997let g:FuzzyFinderMode.MruFile = copy(g:FuzzyFinderMode.Base) 
    1119998"----------------------------------------------------------------------------- 
     
    11211000  let patterns = self.make_pattern(a:base) 
    11221001 
    1123   if !has_key(s:info, 'mru_file') 
    1124     return [] 
    1125   endif 
    1126  
    11271002  echo '[' . self.to_key() . '] pattern:' . patterns.wi . (self.migemo_support ? ' + migemo' : '') 
    11281003 
     
    11321007 
    11331008"----------------------------------------------------------------------------- 
    1134 unlet g:FuzzyFinderMode.MruFile.on_mode_enter 
    11351009function! g:FuzzyFinderMode.MruFile.on_mode_enter() 
    1136   let self.cache = s:MakeNumberedList(map(copy(s:info.mru_file), 
     1010  let self.cache = s:MakeNumberedList(map(copy(self.info), 
    11371011        \                                 '{ ''path'' : fnamemodify(v:val.path, '':~:.''),' . 
    11381012        \                                 '  ''time'' : strftime(self.time_format, v:val.time) }'), 1) 
     
    11401014 
    11411015"----------------------------------------------------------------------------- 
    1142 unlet g:FuzzyFinderMode.MruFile.on_buf_enter 
    11431016function! g:FuzzyFinderMode.MruFile.on_buf_enter() 
    11441017  call self.update_info() 
     
    11461019 
    11471020"----------------------------------------------------------------------------- 
    1148 unlet g:FuzzyFinderMode.MruFile.on_buf_write_post 
    11491021function! g:FuzzyFinderMode.MruFile.on_buf_write_post() 
    11501022  call self.update_info() 
     
    11531025"----------------------------------------------------------------------------- 
    11541026function! g:FuzzyFinderMode.MruFile.update_info() 
    1155   call self.read_info_from_file() 
    1156  
    1157   " current-buffer information 
    1158   let cur_buf = { 
     1027  call s:InfoFileManager.load() 
     1028 
     1029  let item = { 
    11591030        \   'path' : (!self.no_special_buffer || empty(&buftype) ? expand('%:p') : ''), 
    11601031        \   'time' : localtime() 
    11611032        \ } 
    11621033 
    1163   call extend(s:info, { 'mru_file' : [] }, 'keep') 
    1164   let s:info.mru_file = filter(insert(filter(s:info.mru_file,'v:val.path != cur_buf.path'), cur_buf), 
    1165         \                      'v:val.path !~ self.excluded_path && filereadable(v:val.path)' 
    1166         \                     )[0 : self.max_item - 1] 
    1167  
    1168   call self.write_info_to_file() 
    1169 endfunction 
    1170  
    1171  
    1172 " FuzzyFinderMode: FavFile: {{{1 
     1034  let self.info = filter(insert(filter(self.info,'v:val.path != item.path'), item), 
     1035        \                'v:val.path !~ self.excluded_path && filereadable(v:val.path)' 
     1036        \               )[0 : self.max_item - 1] 
     1037 
     1038  call s:InfoFileManager.save() 
     1039endfunction 
     1040 
     1041 
     1042" OBJECT: FuzzyFinderMode: MruCmd: ====================================== {{{1 
     1043let g:FuzzyFinderMode.MruCmd = copy(g:FuzzyFinderMode.Base) 
     1044"----------------------------------------------------------------------------- 
     1045function! g:FuzzyFinderMode.MruCmd.on_complete(base) 
     1046  let patterns = self.make_pattern(a:base) 
     1047 
     1048  echo '[' . self.to_key() . '] pattern:' . patterns.wi . (self.migemo_support ? ' + migemo' : '') 
     1049 
     1050  return map(filter(copy(self.cache), 'v:val[0] == patterns.base || v:val[1].command =~ patterns.re'), 
     1051        \    'self.format_completion_item(v:val[1].command, v:val[0], v:val[1].command, v:val[1].time, a:base, 0)') 
     1052endfunction 
     1053 
     1054"----------------------------------------------------------------------------- 
     1055function! g:FuzzyFinderMode.MruCmd.on_open(expr, mode) 
     1056  " use feedkeys to remap <CR> 
     1057  return a:expr . [ 
     1058        \   "\<C-r>=feedkeys(\"\\<CR>\", 'm')?'':''\<CR>", 
     1059        \   "", 
     1060        \   "", 
     1061        \   "", 
     1062        \ ][a:mode] 
     1063endfunction 
     1064 
     1065"----------------------------------------------------------------------------- 
     1066function! g:FuzzyFinderMode.MruCmd.on_mode_enter() 
     1067  let self.cache = s:MakeNumberedList(map(copy(self.info), 
     1068        \                                 '{ ''command'' : v:val.command,' . 
     1069        \                                 '  ''time'' : strftime(self.time_format, v:val.time) }'), 1) 
     1070endfunction 
     1071 
     1072"----------------------------------------------------------------------------- 
     1073function! g:FuzzyFinderMode.MruCmd.on_command_pre(cmd) 
     1074  call self.update_info(a:cmd) 
     1075endfunction 
     1076 
     1077"----------------------------------------------------------------------------- 
     1078function! g:FuzzyFinderMode.MruCmd.update_info(cmd) 
     1079  call s:InfoFileManager.load() 
     1080 
     1081  let item = { 'command' : a:cmd, 'time' : localtime() } 
     1082 
     1083  let self.info = filter(insert(filter(self.info,'v:val.command != item.command'), item), 
     1084        \                'v:val.command !~ self.excluded_command')[0 : self.max_item - 1] 
     1085 
     1086  call s:InfoFileManager.save() 
     1087endfunction 
     1088 
     1089 
     1090" OBJECT: FuzzyFinderMode: FavFile: ===================================== {{{1 
    11731091let g:FuzzyFinderMode.FavFile = copy(g:FuzzyFinderMode.Base) 
    11741092"----------------------------------------------------------------------------- 
     
    11761094  let patterns = self.make_pattern(a:base) 
    11771095 
    1178   if !has_key(s:info, 'fav_file') 
    1179     return [] 
    1180   endif 
    1181  
    11821096  echo '[' . self.to_key() . '] pattern:' . patterns.wi . (self.migemo_support ? ' + migemo' : '') 
    11831097 
     
    11871101 
    11881102"----------------------------------------------------------------------------- 
    1189 unlet g:FuzzyFinderMode.FavFile.on_mode_enter 
    11901103function! g:FuzzyFinderMode.FavFile.on_mode_enter() 
    1191   let self.cache = s:MakeNumberedList(map(copy(s:info.fav_file), 
     1104  let self.cache = s:MakeNumberedList(map(copy(self.info), 
    11921105        \                                 '{ ''path'' : fnamemodify(v:val.path, '':~:.''),' . 
    11931106        \                                 '  ''time'' : strftime(self.time_format, v:val.time) }'), 1) 
     
    11961109"----------------------------------------------------------------------------- 
    11971110function! g:FuzzyFinderMode.FavFile.add(in_file, adds) 
    1198   call self.read_info_from_file() 
     1111  call s:InfoFileManager.load() 
    11991112 
    12001113  let file = fnamemodify((empty(a:in_file) ? expand('%') : a:in_file), ':p:~') 
    12011114 
    1202   call extend(s:info, { 'fav_file' : [] }, 'keep') 
    1203   let s:info.fav_file = filter(s:info.fav_file, 'v:val.path != file') 
    1204  
     1115  call filter(self.info, 'v:val.path != file') 
    12051116  if a:adds 
    1206     let s:info.fav_file = add(s:info.fav_file, { 'path' : file, 'time' : localtime() }) 
    1207   endif 
    1208  
    1209   call self.write_info_to_file() 
    1210 endfunction 
    1211  
    1212  
    1213 " FuzzyFinderMode: Dir: {{{1 
     1117    call add(self.info, { 'path' : file, 'time' : localtime() }) 
     1118  endif 
     1119 
     1120  call s:InfoFileManager.save() 
     1121endfunction 
     1122 
     1123 
     1124" OBJECT: FuzzyFinderMode: Dir: ========================================= {{{1 
    12141125let g:FuzzyFinderMode.Dir = copy(g:FuzzyFinderMode.Base) 
    12151126"----------------------------------------------------------------------------- 
     
    12361147 
    12371148"----------------------------------------------------------------------------- 
    1238 unlet g:FuzzyFinderMode.Dir.on_open 
    12391149function! g:FuzzyFinderMode.Dir.on_open(expr, mode) 
    1240   return ':cd ' . a:expr . [ 
     1150  return ':cd ' . escape(a:expr, ' ') . [ 
    12411151        \   "\<CR>", 
    12421152        \   "", 
     
    12471157 
    12481158 
    1249 " FuzzyFinderMode: Tag: {{{1 
     1159" OBJECT: FuzzyFinderMode: Tag: ========================================= {{{1 
    12501160let g:FuzzyFinderMode.Tag = copy(g:FuzzyFinderMode.Base) 
    12511161"----------------------------------------------------------------------------- 
     
    12651175 
    12661176"----------------------------------------------------------------------------- 
    1267 unlet g:FuzzyFinderMode.Tag.on_open 
    12681177function! g:FuzzyFinderMode.Tag.on_open(expr, mode) 
    12691178  return [ 
     
    12851194  " cache not created or tags file updated?  
    12861195  call extend(self, { 'cache' : {} }, 'keep') 
    1287   if !exists('self.cache[key]') || len(filter(map(copy(self.tag_files), 'getftime(v:val)'), 
    1288         \                                     'v:val >= self.cache[key].time')) 
     1196  if !exists('self.cache[key]') || max(map(copy(self.tag_files), 'getftime(v:val) >= self.cache[key].time')) 
    12891197    echo 'Caching tag list...' 
    12901198    let self.cache[key] = { 
     
    12991207 
    13001208 
    1301 " FuzzyFinderMode: TaggedFile: {{{1 
     1209" OBJECT: FuzzyFinderMode: TaggedFile: ================================== {{{1 
    13021210let g:FuzzyFinderMode.TaggedFile = copy(g:FuzzyFinderMode.Base) 
    13031211"----------------------------------------------------------------------------- 
     
    13271235  " cache not created or tags file updated?  
    13281236  call extend(self, { 'cache' : {} }, 'keep') 
    1329   if !exists('self.cache[key]') || len(filter(map(copy(self.tag_files), 'getftime(v:val)'), 
    1330         \                                     'v:val >= self.cache[key].time')) 
     1237  if !exists('self.cache[key]') || max(map(copy(self.tag_files), 'getftime(v:val) >= self.cache[key].time')) 
    13311238    echo 'Caching tagged-file list...' 
    13321239    let self.cache[key] = { 
     
    13441251 
    13451252 
    1346 " WindowManager: {{{1 
     1253" OBJECT: WindowManager: manages buffer/window for fuzzyfinder ========== {{{1 
    13471254let s:WindowManager = { 'buf_nr' : -1 } 
    13481255"----------------------------------------------------------------------------- 
    13491256function! s:WindowManager.activate(complete_func) 
    1350   let self.prev_winnr = bufwinnr('%') 
     1257  let self.prev_winnr = winnr() 
    13511258  let cwd = getcwd() 
    13521259 
    13531260  if !bufexists(self.buf_nr) 
    1354     leftabove 1new 
     1261    leftabove 1new +file\ [Fuzzyfinder] 
    13551262    let self.buf_nr = bufnr('%') 
    1356     execute 'file [Fuzzyfinder]' 
    13571263  elseif bufwinnr(self.buf_nr) == -1 
    13581264    execute 'leftabove 1split | buffer ' . self.buf_nr 
     
    13751281  let &l:completefunc = a:complete_func 
    13761282 
     1283  redraw " for 'lazyredraw' 
     1284 
    13771285  " suspend autocomplpop.vim 
    13781286  if exists(':AutoComplPopLock') 
     
    13931301 
    13941302 
    1395 " OptionManager: sets or restores temporary options {{{1 
     1303" OBJECT: OptionManager: sets or restores temporary options ============= {{{1 
    13961304let s:OptionManager = { 'originals' : {} } 
    13971305"----------------------------------------------------------------------------- 
     
    14091317endfunction 
    14101318 
     1319" OBJECT: InfoFileManager: ============================================== {{{1 
     1320let s:InfoFileManager = { 'originals' : {} } 
     1321"----------------------------------------------------------------------------- 
     1322function! s:InfoFileManager.load() 
     1323  for m in s:GetAvailableModes() 
     1324    let m.info = [] 
     1325  endfor 
     1326 
     1327  try 
     1328    let lines = readfile(expand(self.get_info_file())) 
     1329  catch /.*/  
     1330    return 
     1331  endtry 
     1332 
     1333  " compatibility check 
     1334  if !count(lines, self.get_info_version_line()) 
     1335      call self.warn_old_info() 
     1336      let g:FuzzyFinderOptions.Base.info_file = '' 
     1337      return 
     1338  endif 
     1339 
     1340  for m in s:GetAvailableModes() 
     1341    call m.deserialize_info(lines) 
     1342  endfor 
     1343endfunction 
     1344 
     1345"----------------------------------------------------------------------------- 
     1346function! s:InfoFileManager.save() 
     1347  let lines = [ self.get_info_version_line() ] 
     1348  for m in s:GetAvailableModes() 
     1349    let lines += m.serialize_info() 
     1350  endfor 
     1351 
     1352  try 
     1353    call writefile(lines, expand(self.get_info_file())) 
     1354  catch /.*/  
     1355  endtry 
     1356endfunction 
     1357 
     1358"----------------------------------------------------------------------------- 
     1359function! s:InfoFileManager.edit() 
     1360 
     1361  new +file\ [FuzzyfinderInfo] 
     1362 
     1363  setlocal filetype=vim 
     1364  setlocal bufhidden=delete 
     1365  setlocal buftype=nofile 
     1366  setlocal noswapfile 
     1367  "setlocal nobuflisted 
     1368 
     1369  augroup FuzzyfinderInfo 
     1370    autocmd! 
     1371    autocmd BufWinLeave <buffer> call s:InfoFileManager.on_buf_win_leave() 
     1372  augroup END 
     1373 
     1374  execute '0read ' . expand(self.get_info_file()) 
     1375 
     1376  echo 'Close this window to apply changes.' 
     1377endfunction 
     1378 
     1379"----------------------------------------------------------------------------- 
     1380function! s:InfoFileManager.on_buf_win_leave() 
     1381  echohl Question 
     1382  if input('Apply changes? [y/n]: ', 'y') ==? 'y' 
     1383    for m in s:GetAvailableModes() 
     1384      call m.deserialize_info(getline(1, '$')) 
     1385    endfor 
     1386    call self.save() 
     1387  endif 
     1388  echohl None 
     1389endfunction 
     1390 
     1391"----------------------------------------------------------------------------- 
     1392function! s:InfoFileManager.get_info_version_line() 
     1393  return "VERSION\t206" 
     1394endfunction 
     1395 
     1396"----------------------------------------------------------------------------- 
     1397function! s:InfoFileManager.get_info_file() 
     1398  return g:FuzzyFinderOptions.Base.info_file 
     1399endfunction 
     1400 
     1401"----------------------------------------------------------------------------- 
     1402function! s:InfoFileManager.warn_old_info() 
     1403  echohl WarningMsg 
     1404  echo printf("==================================================\n" . 
     1405      \       "  Your Fuzzyfinder information file is no longer  \n" . 
     1406      \       "  supported. Please remove                        \n" . 
     1407      \       "  %-48s\n" . 
     1408      \       "==================================================\n" , 
     1409      \       '"' . expand(self.get_info_file()) . '".') 
     1410  echohl None 
     1411endfunction 
    14111412 
    14121413" }}}1 
    14131414 
    1414 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    1415 " INITIALIZE: 
    1416 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    1417  
    1418 call s:Initialize() 
    1419  
    1420 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
    1421 " vim:fdm=marker 
    1422  
     1415" INITIALIZATION: GLOBAL OPTIONS: ======================================= {{{1 
     1416" stores user-defined g:FuzzyFinderOptions ------------------------------ {{{2 
     1417let user_options = (exists('g:FuzzyFinderOptions') ? g:FuzzyFinderOptions : {}) 
     1418" }}}2 
     1419 
     1420" Initializes g:FuzzyFinderOptions. 
     1421let g:FuzzyFinderOptions = { 'Base':{}, 'Buffer':{}, 'File':{}, 'MruFile':{}, 'MruCmd':{}, 'FavFile':{}, 'Dir':{}, 'Tag':{}, 'TaggedFile':{}} 
     1422"----------------------------------------------------------------------------- 
     1423" [All Mode] This is mapped to select completion item or finish input and 
     1424" open a buffer/file in previous window. 
     1425let g:FuzzyFinderOptions.Base.key_open = '<CR>' 
     1426" [All Mode] This is mapped to select completion item or finish input and 
     1427" open a buffer/file in split new window 
     1428let g:FuzzyFinderOptions.Base.key_open_split = '<C-j>' 
     1429" [All Mode] This is mapped to select completion item or finish input and 
     1430" open a buffer/file in vertical-split new window. 
     1431let g:FuzzyFinderOptions.Base.key_open_vsplit = '<C-k>' 
     1432" [All Mode] This is mapped to select completion item or finish input and 
     1433" open a buffer/file in a new tab page. 
     1434let g:FuzzyFinderOptions.Base.key_open_tab = '<C-]>' 
     1435" [All Mode] This is mapped to switch to the next mode. 
     1436let g:FuzzyFinderOptions.Base.key_next_mode = '<C-l>' 
     1437" [All Mode] This is mapped to switch to the previous mode. 
     1438let g:FuzzyFinderOptions.Base.key_prev_mode = '<C-o>' 
     1439" [All Mode] This is mapped to temporarily switch whether or not to ignore 
     1440" case. 
     1441let g:FuzzyFinderOptions.Base.key_ignore_case = '<C-t>' 
     1442" [All Mode] This is the file name to write information of the MRU, etc. If 
     1443" "" was set, it does not write to the file. 
     1444let g:FuzzyFinderOptions.Base.info_file = '~/.vimfuzzyfinder' 
     1445" [All Mode] It does not start a completion if a length of entered text is 
     1446" less than this. 
     1447let g:FuzzyFinderOptions.Base.min_length = 0 
     1448" [All Mode] This is a dictionary. Each value must be a list. All matchs of a 
     1449" key in entered text is expanded with the value. 
     1450let g:FuzzyFinderOptions.Base.abbrev_map = {} 
     1451" [All Mode] It ignores case in search patterns if non-zero is set. 
     1452let g:FuzzyFinderOptions.Base.ignore_case = 1 
     1453" [All Mode] It does not remove caches of completion lists at the end of 
     1454" explorer to reuse at the next time if non-zero was set. 
     1455let g:FuzzyFinderOptions.Base.lasting_cache = 1 
     1456" [All Mode] It uses Migemo if non-zero is set. 
     1457let g:FuzzyFinderOptions.Base.migemo_support = 0 
     1458"----------------------------------------------------------------------------- 
     1459" [Buffer Mode] It disables all functions of this mode if zero was set. 
     1460let g:FuzzyFinderOptions.Buffer.mode_available = 1 
     1461" [Buffer Mode] The items whose :ls-indicators match this are excluded from 
     1462" the completion list. 
     1463let g:FuzzyFinderOptions.Buffer.excluded_indicator = '[u\-]' 
     1464"----------------------------------------------------------------------------- 
     1465" [File Mode] It disables all functions of this mode if zero was set. 
     1466let g:FuzzyFinderOptions.File.mode_available = 1 
     1467" [File Mode] The items matching this are excluded from the completion list. 
     1468let g:FuzzyFinderOptions.File.excluded_path = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|((^|[/\\])\.[/\\]$)' 
     1469" [File Mode] If a number of matched items was over this, the completion 
     1470" process is aborted. 
     1471let g:FuzzyFinderOptions.File.matching_limit = 200 
     1472"----------------------------------------------------------------------------- 
     1473" [Mru-File Mode] It disables all functions of this mode if zero was set. 
     1474let g:FuzzyFinderOptions.MruFile.mode_available = 1 
     1475" [Mru-File Mode] The items matching this are excluded from the completion 
     1476" list. 
     1477let g:FuzzyFinderOptions.MruFile.excluded_path = '\v\~$|\.bak$|\.swp$' 
     1478" [Mru-File Mode] It ignores special buffers if non-zero was set. 
     1479let g:FuzzyFinderOptions.MruFile.no_special_buffer = 1 
     1480" [Mru-File Mode] This is a string to format registered time. See :help 
     1481" strftime() for details. 
     1482let g:FuzzyFinderOptions.MruFile.time_format = '(%x %H:%M:%S)' 
     1483" [Mru-File Mode] This is an upper limit of MRU items to be stored. 
     1484let g:FuzzyFinderOptions.MruFile.max_item = 99 
     1485"----------------------------------------------------------------------------- 
     1486" [Mru-Cmd Mode] It disables all functions of this mode if zero was set. 
     1487let g:FuzzyFinderOptions.MruCmd.mode_available = 1 
     1488" [Mru-Cmd Mode] The items matching this are excluded from the completion 
     1489" list. 
     1490let g:FuzzyFinderOptions.MruCmd.excluded_command = '^$' 
     1491" [Mru-Cmd Mode] This is a string to format registered time. See :help 
     1492" strftime() for details. 
     1493let g:FuzzyFinderOptions.MruCmd.time_format = '(%x %H:%M:%S)' 
     1494" [Mru-Cmd Mode] This is an upper limit of MRU items to be stored. 
     1495let g:FuzzyFinderOptions.MruCmd.max_item = 99 
     1496"----------------------------------------------------------------------------- 
     1497" [Favorite-File Mode] It disables all functions of this mode if zero was 
     1498" set. 
     1499let g:FuzzyFinderOptions.FavFile.mode_available = 1 
     1500" [Favorite-File Mode] This is a string to format registered time. See :help 
     1501" strftime() for details. 
     1502let g:FuzzyFinderOptions.FavFile.time_format = '(%x %H:%M:%S)' 
     1503"----------------------------------------------------------------------------- 
     1504" [Directory Mode] It disables all functions of this mode if zero was set. 
     1505let g:FuzzyFinderOptions.Dir.mode_available = 1 
     1506" [Directory Mode] The items matching this are excluded from the completion 
     1507" list. 
     1508let g:FuzzyFinderOptions.Dir.excluded_path = '\v(^|[/\\])\.{1,2}[/\\]$' 
     1509"----------------------------------------------------------------------------- 
     1510" [Tag Mode] It disables all functions of this mode if zero was set. 
     1511let g:FuzzyFinderOptions.Tag.mode_available = 1 
     1512" [Tag Mode] The items matching this are excluded from the completion list. 
     1513let g:FuzzyFinderOptions.Tag.excluded_path = '\v\~$|\.bak$|\.swp$' 
     1514" [Tag Mode] If a number of matched items was over this, the completion 
     1515" process is aborted. 
     1516let g:FuzzyFinderOptions.Tag.matching_limit = 200 
     1517"----------------------------------------------------------------------------- 
     1518" [Tagged-File Mode] It disables all functions of this mode if zero was set. 
     1519let g:FuzzyFinderOptions.TaggedFile.mode_available = 1 
     1520" [Tagged-File Mode] If a number of matched items was over this, the 
     1521" completion process is aborted. 
     1522let g:FuzzyFinderOptions.TaggedFile.matching_limit = 200 
     1523 
     1524" hidden options -------------------------------------------------------- {{{2 
     1525let g:FuzzyFinderOptions.Base.path_separator = (has('win32') || has('win64') ? '\' : '/') 
     1526let g:FuzzyFinderOptions.Base.prompt = '>' 
     1527let g:FuzzyFinderOptions.Base.matching_rate_base = 10000000 
     1528 
     1529" overwrites default values of g:FuzzyFinderOptions with user-defined values - {{{2 
     1530call map(user_options, 'extend(g:FuzzyFinderOptions[v:key], v:val, ''force'')') 
     1531call map(copy(g:FuzzyFinderMode), 'v:val.extend_options()') 
     1532" }}}2 
     1533 
     1534" INITIALIZATION: COMMANDS, MAPPINGS, AUTOCOMMANDS, ETC.: =============== {{{1 
     1535"----------------------------------------------------------------------------- 
     1536augroup FuzzyfinderGlobal 
     1537  autocmd! 
     1538  autocmd BufEnter     * for m in s:GetAvailableModes() | call m.on_buf_enter() | endfor 
     1539  autocmd BufWritePost * for m in s:GetAvailableModes() | call m.on_buf_write_post() | endfor 
     1540augroup END 
     1541 
     1542" cnoremap has a problem, which doesn't expand cabbrev. 
     1543cmap <silent> <expr> <CR> <SID>OnCmdCR() 
     1544 
     1545command! -bang -narg=? -complete=buffer FuzzyFinderBuffer      call g:FuzzyFinderMode.Buffer.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1546command! -bang -narg=? -complete=file   FuzzyFinderFile        call g:FuzzyFinderMode.File.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1547command! -bang -narg=? -complete=file   FuzzyFinderMruFile     call g:FuzzyFinderMode.MruFile.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1548command! -bang -narg=? -complete=file   FuzzyFinderMruCmd      call g:FuzzyFinderMode.MruCmd.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1549command! -bang -narg=? -complete=file   FuzzyFinderFavFile     call g:FuzzyFinderMode.FavFile.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1550command! -bang -narg=? -complete=dir    FuzzyFinderDir         call g:FuzzyFinderMode.Dir.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1551command! -bang -narg=? -complete=tag    FuzzyFinderTag         call g:FuzzyFinderMode.Tag.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1552command! -bang -narg=? -complete=file   FuzzyFinderTaggedFile  call g:FuzzyFinderMode.TaggedFile.launch(<q-args>, len(<q-bang>), s:GetCurrentTagFiles()) 
     1553command! -bang -narg=? -complete=file   FuzzyFinderEditInfo    call s:InfoFileManager.edit() 
     1554command! -bang -narg=? -complete=file   FuzzyFinderAddFavFile  call g:FuzzyFinderMode.FavFile.add(<q-args>, 1) 
     1555command! -bang -narg=0                  FuzzyFinderRemoveCache for m in s:GetAvailableModes() | call m.empty_cache_if_existed(1) | endfor 
     1556 
     1557" }}}1 
     1558"============================================================================= 
     1559" vim: set fdm=marker: 
  • dotfiles/vim/ishihara/.vim/plugin/yankring.vim

    r7191 r9179  
    11" yankring.vim - Yank / Delete Ring for Vim 
    22" --------------------------------------------------------------- 
    3 " Version:  3.0 
     3" Version:  2.2 
    44" Authors:  David Fishburn <fishburn@ianywhere.com> 
    5 " Last Modified: Fri 07 Sep 2007 11:20:49 PM Eastern Daylight Time 
     5" Last Modified: Wed Oct 12 2005 11:54:41 AM 
    66" Script:   http://www.vim.org/scripts/script.php?script_id=1234 
    77" Based On: Mocked up version by Yegappan Lakshmanan 
     
    99"  License: GPL (Gnu Public License) 
    1010" GetLatestVimScripts: 1234 1 :AutoInstall: yankring.vim 
    11 " 
    12 " Perl integration with the clipboard: 
    13 "     http://www.xav.com/perl/site/lib/Win32/Clipboard.html 
    14 " 
    1511 
    1612if exists('loaded_yankring') || &cp 
     
    1814endif 
    1915 
    20 if v:version < 700 
    21   echomsg 'yankring: You need at least Vim 7.0' 
     16if v:version < 602 
     17  echomsg 'yankring: You need at least Vim 6.2' 
    2218  finish 
    2319endif 
    2420 
    25 let loaded_yankring = 30 
     21let loaded_yankring = 22 
    2622 
    2723" Allow the user to override the # of yanks/deletes recorded 
     
    4541if !exists('g:yankring_max_display') 
    4642    let g:yankring_max_display = 0 
    47 endif 
    48  
    49 " Check if yankring should persist between Vim instances 
    50 if !exists('g:yankring_persist') 
    51     let g:yankring_persist = 1 
    5243endif 
    5344 
     
    119110" Allow the user to specify what characters to use for the mappings. 
    120111if !exists('g:yankring_n_keys') 
    121     let g:yankring_n_keys = 'x,yy,dd,yw,dw,ye,de,yE,dE,yiw,diw,yaw,daw,y$,d$,Y,D,yG,dG,ygg,dgg' 
     112    let g:yankring_n_keys = 'yy,dd,yw,dw,ye,de,yE,dE,yiw,diw,yaw,daw,y$,d$,Y,D,yG,dG,ygg,dgg' 
    122113endif 
    123114 
     
    169160let s:yr_buffer_last       = -1 
    170161let s:yr_buffer_id         = -1 
    171 let s:yr_elements          = [] 
    172 let s:yr_element_type      = [] 
    173 let s:yr_search            = "" 
    174162 
    175163" Vim window size is changed by the yankring plugin or not 
    176164let s:yankring_winsize_chgd = 0 
    177  
    178 " If the we are persisting the yankring between Vim instances 
    179 " set the scope to be global instead of script level. 
    180 let s:yr_scope = (g:yankring_persist==1?'g':'s') 
    181165 
    182166" Enables or disables the yankring  
     
    215199    endif 
    216200 
    217     if exists(s:yr_scope.':YR_ELEM_'.a:script_var) 
    218         let length = strlen({s:yr_scope}:YR_ELEM_{a:script_var}) 
     201    if exists('s:yr_elem_'.a:script_var) 
     202        let length = strlen(s:yr_elem_{a:script_var}) 
    219203        " Fancy trick to align them all regardless of how many 
    220204        " digits the element # is 
    221205        return a:disp_nbr. 
    222206                    \ strtrans( 
    223                     \ strpart("      ",0,(6-strlen(a:disp_nbr+1))). 
     207                    \ strpart("      ",0,(6-strlen(a:disp_nbr))). 
    224208                    \ ( 
    225209                    \ (length>max_display)? 
    226                     \ (strpart({s:yr_scope}:YR_ELEM_{a:script_var},0,max_display). 
     210                    \ (strpart(s:yr_elem_{a:script_var},0,max_display). 
    227211                    \ '...'): 
    228                     \ ({s:yr_scope}:YR_ELEM_{a:script_var}) 
     212                    \ (s:yr_elem_{a:script_var}) 
    229213                    \ ) 
    230214                    \ ) 
     
    251235    endif 
    252236 
    253     " Reset the search string, since this is automatically called 
    254     " if the yankring window is open.  A previous search must be 
    255     " cleared since we do not want to show new items.  The user can 
    256     " always run the search again. 
    257     let s:yr_search = "" 
    258  
    259237    " List is shown in order of replacement 
    260238    " assuming using previous yanks 
     239     
    261240    let output = "--- YankRing ---\n" 
    262241    let output = output . "Elem  Content\n" 
    263242 
    264     let disp_item_nr = 1 
    265     for elem in s:yr_elements 
    266         let output  = output . s:YRDisplayElem(disp_item_nr, elem) . "\n" 
    267         let disp_item_nr   += 1 
    268     endfor 
     243    let iter = 1 
     244    let elem = s:YRMRUGet('s:yr_elem_order', iter) 
     245 
     246    while iter <= s:yr_count 
     247        let output = output . s:YRDisplayElem(iter, elem) . "\n" 
     248        let iter = iter + 1 
     249        let elem = s:YRMRUGet('s:yr_elem_order', iter) 
     250    endwhile 
    269251 
    270252    if g:yankring_window_use_separate == 1 
     
    327309    endif 
    328310 
    329     if !exists(s:yr_scope.':YR_ELEM_'.elem) 
     311    if !exists('s:yr_elem_'.elem) 
    330312        call s:YRWarningMsg("YR: Elem:".elem." does not exist") 
    331313        return -1 
     
    336318    " let save_reg_type = getregtype(default_buffer) 
    337319    call setreg(default_buffer 
    338                 \ , s:YRGetValElemNbr((elem-1), 'v') 
    339                 \ , s:YRGetValElemNbr((elem-1), 't') 
     320                \ , s:YRGetValElemNbr(elem, 'v') 
     321                \ , s:YRGetValElemNbr(elem, 't') 
    340322                \ ) 
    341323    exec "normal! ".direction 
     
    349331  
    350332 
    351 " Starting the top of the ring it will paste x items from it 
     333" Starting the the top of the ring it will paste x items from it 
    352334function! s:YRGetMultiple(reverse_order, ...)  
    353335    if s:yr_count == 0 
     
    371353    endif 
    372354    if iter < 1  
    373         " The default to only 1 item if no argument is specified 
     355        " The default to only 1 item if no arguement is specified 
    374356        let iter = 1 
    375357    endif 
     
    379361    endif 
    380362    if elem < 1 || elem > s:yr_count 
    381         " The default to only 1 item if no argument is specified 
     363        " The default to only 1 item if no arguement is specified 
    382364        let elem = 1 
    383365    endif 
     
    417399    endif 
    418400 
    419     let s:yr_search = "" 
     401    let search_exp = "" 
    420402    " If the user provided a range, exit after that many 
    421403    " have been displayed 
    422     if a:0 == 0 || (a:0 == 1 && a:1 == "") 
    423         let s:yr_search = input('Enter [optional] regex:') 
     404    if a:0 == 0 
     405        let search_exp = a:1 
    424406    else 
    425         let s:yr_search = a:1 
    426     endif 
    427  
    428     if s:yr_search == "" 
     407        let search_exp = input('Enter [optional] regex:') 
     408    endif 
     409 
     410    if search_exp == "" 
    429411        " Show the entire yankring 
    430412        call s:YRShow(0) 
     
    432414    endif 
    433415 
    434     let disp_item_nr = 1 
     416    let iter        = 1 
    435417 
    436418    " List is shown in order of replacement 
    437419    " assuming using previous yanks 
    438     let output        = "--- YankRing ---\n" 
    439     let output        = output . "Elem  Content\n" 
    440     let search_result = "" 
     420    let output = "--- YankRing ---\n" 
     421    let output = output . "Elem  Content\n" 
     422    let elem          = s:YRMRUGet('s:yr_elem_order', iter) 
    441423    let valid_choices = ',' 
    442424 
    443     for elem in s:yr_elements 
     425    while iter <= s:yr_count 
    444426        let v:errmsg = '' 
    445         if exists(s:yr_scope.':YR_ELEM_'.elem) 
    446             if match({s:yr_scope}:YR_ELEM_{elem}, s:yr_search) > -1 
    447                 let search_result = search_result . s:YRDisplayElem(disp_item_nr, elem) . "\n" 
    448                 let valid_choices = valid_choices . disp_item_nr . ',' 
     427        if exists('s:yr_elem_'.elem) 
     428            if match(s:yr_elem_{elem}, search_exp) > -1 
     429                let output = output . s:YRDisplayElem(iter, elem) . "\n" 
     430                let valid_choices = valid_choices . iter . ',' 
    449431            endif 
    450432            if v:errmsg != '' 
     
    454436            endif 
    455437        endif 
    456         let disp_item_nr += 1 
    457     endfor 
    458  
    459     if search_result == "" 
    460         let output = output . "Search for [".s:yr_search."] did not match any items " 
    461     else 
    462         let output = output . search_result 
    463     endif 
     438        let iter = iter + 1 
     439        let elem = s:YRMRUGet('s:yr_elem_order', iter) 
     440    endwhile 
    464441 
    465442    if g:yankring_window_use_separate == 1 
     
    490467        else 
    491468            call s:YRWarningMsg( "YR: The pattern [" . 
    492                         \ s:yr_search . 
     469                        \ search_exp . 
    493470                        \ "] does not match any items in the yankring" 
    494471                        \ ) 
     
    496473    endif 
    497474 
    498 endfunction 
    499   
    500  
    501 " Resets the common script variables for managing the ring. 
    502 function! s:YRReset() 
    503     let s:yr_next_idx              = 0 
    504     let s:yr_last_paste_idx        = 0 
    505     let s:yr_count                 = 0 
    506     let s:yr_paste_dir             = 'p' 
    507  
    508     " For the . op support 
    509     let s:yr_prev_op_code          = '' 
    510     let s:yr_prev_count            = '' 
    511     let s:yr_prev_reg              = '' 
    512     let s:yr_prev_reg_unnamed      = '' 
    513     let s:yr_prev_reg_small        = '' 
    514     let s:yr_prev_reg_insert       = '' 
    515     let s:yr_prev_reg_expres       = '' 
    516     let s:yr_prev_vis_lstart       = 0 
    517     let s:yr_prev_vis_lend         = 0 
    518     let s:yr_prev_vis_cstart       = 0 
    519     let s:yr_prev_vis_cend         = 0 
    520  
    521     " This is used to determine if the visual selection should be 
    522     " reset prior to issuing the YRReplace 
    523     let s:yr_prev_vis_mode         = 0 
    524 endfunction 
    525   
    526  
    527 " Clears the yankring by simply setting the # of items in it to 0. 
    528 " There is no need physically unlet each variable. 
    529 function! s:YRInit() 
    530     call s:YRReset() 
    531  
    532     " This is the MRU list of items in the yankring 
    533     if !exists( s:yr_scope.':YR_ELEM_ORDER' ) 
    534         let {s:yr_scope}:YR_ELEM_ORDER = "" 
    535     endif 
    536     call s:YRMRUInit( 's:yr_elements', g:yankring_max_history, {s:yr_scope}:YR_ELEM_ORDER ) 
    537  
    538     let s:yr_count    = s:YRMRUSize('s:yr_elements') 
    539  
    540     " We can potentially keep creating new global variables forever 
    541     " since as the rings rotates through values, it will always be 
    542     " increasing.  Add some additional logic to: 
    543     "    a) Check for the current highest value in the ring 
    544     "       by sorting the list and adding 1 
    545     "    b) If the lowest value is larger than g:yankring_max_history,  
    546     "       set the next index item to be 1. 
    547     if !empty(s:yr_elements) 
    548         let sorted_mru    = sort(copy(s:yr_elements)) 
    549         let s:yr_next_idx = get(sorted_mru, -1) + 1 
    550  
    551         if get(sorted_mru, 1) > g:yankring_max_history 
    552             let s:yr_next_idx = 0 
    553         endif 
    554     endif 
    555475endfunction 
    556476  
     
    559479" There is no need physically unlet each variable. 
    560480function! s:YRClear() 
    561     call s:YRReset() 
     481    let s:yr_next_idx         = 1 
     482    let s:yr_last_paste_idx   = 0 
     483    let s:yr_count            = 0 
     484    let s:yr_paste_dir        = 'p' 
     485 
     486    " For the . op support 
     487    let s:yr_prev_op_code     = '' 
     488    let s:yr_prev_count       = '' 
     489    let s:yr_prev_reg         = '' 
     490    let s:yr_prev_reg_unnamed = '' 
     491    let s:yr_prev_reg_small   = '' 
     492    let s:yr_prev_reg_insert  = '' 
     493    let s:yr_prev_reg_expres  = '' 
     494    let s:yr_prev_vis_lstart  = 0 
     495    let s:yr_prev_vis_lend    = 0 
     496    let s:yr_prev_vis_cstart  = 0 
     497    let s:yr_prev_vis_cend    = 0 
     498 
     499    " This is used to determine if the visual selection should be 
     500    " reset prior to issuing the YRReplace 
     501    let s:yr_prev_vis_mode    = 0 
    562502 
    563503    " This is the MRU list of items in the yankring 
    564     call s:YRMRUReset( 's:yr_elements' ) 
     504    let s:yr_elem_order       = "" 
    565505endfunction 
    566506  
     
    628568    " elements from the ring. 
    629569    while v_count > 0  
    630         call s:YRMRUDel('s:yr_elements', elem) 
     570        call s:YRMRUDel('s:yr_elem_order', elem) 
    631571        let v_count = v_count - 1 
    632572    endwhile 
     
    642582    " Add item to list 
    643583    " This will also account for duplicates. 
    644     call s:YRMRUAdd( 's:yr_elements' 
     584    call s:YRMRUAdd( 's:yr_elem_order' 
    645585                \ , getreg(a:value) 
    646586                \ , getregtype(a:value)  
     
    688628    let dorepeat = 0 
    689629 
    690     if g:yankring_manage_numbered_reg == 1 
    691         " When resetting the numbered register we are 
    692         " must ignore the comparision of the " register. 
    693         if s:yr_prev_reg_small  == getreg('-') && 
    694                     \ s:yr_prev_reg_insert == getreg('.') && 
    695                     \ s:yr_prev_reg_expres == histget('=', -1) && 
    696                     \ s:yr_prev_vis_lstart == line("'<") && 
    697                     \ s:yr_prev_vis_lend   == line("'>") && 
    698                     \ s:yr_prev_vis_cstart == col("'<") && 
    699                     \ s:yr_prev_vis_cend   == col("'>") && 
    700                     \ s:yr_prev_chg_lstart == line("'[") && 
    701                     \ s:yr_prev_chg_lend   == line("']") && 
    702                     \ s:yr_prev_chg_cstart == col("'[") && 
    703                     \ s:yr_prev_chg_cend   == col("']")  
    704             let dorepeat = 1 
    705         endif 
    706     else 
    707         " Check the previously recorded value of the registers 
    708         " if they are the same, we need to reissue the previous 
    709         " yankring command. 
    710         " If any are different, the user performed a command 
    711         " command that did not involve the yankring, therefore 
    712         " we should just issue the standard "normal! ." to repeat it. 
    713         if s:yr_prev_reg_unnamed == getreg('"') && 
    714                     \ s:yr_prev_reg_small  == getreg('-') && 
    715                     \ s:yr_prev_reg_insert == getreg('.') && 
    716                     \ s:yr_prev_reg_expres == histget('=', -1) && 
    717                     \ s:yr_prev_vis_lstart == line("'<") && 
    718                     \ s:yr_prev_vis_lend   == line("'>") && 
    719                     \ s:yr_prev_vis_cstart == col("'<") && 
    720                     \ s:yr_prev_vis_cend   == col("'>") && 
    721                     \ s:yr_prev_chg_lstart == line("'[") && 
    722                     \ s:yr_prev_chg_lend   == line("']") && 
    723                     \ s:yr_prev_chg_cstart == col("'[") && 
    724                     \ s:yr_prev_chg_cend   == col("']")  
    725             let dorepeat = 1 
    726         endif 
     630    " Check the previously recorded value of the registers 
     631    " if they are the same, we need to reissue the previous 
     632    " yankring command. 
     633    " If any are different, the user performed a command 
     634    " command that did not involve the yankring, therefore 
     635    " we should just issue the standard "normal! ." to repeat it. 
     636    if s:yr_prev_reg_unnamed == getreg('"') && 
     637                \ s:yr_prev_reg_small  == getreg('-') && 
     638                \ s:yr_prev_reg_insert == getreg('.') && 
     639                \ s:yr_prev_reg_expres == histget('=', -1) && 
     640                \ s:yr_prev_vis_lstart == line("'<") && 
     641                \ s:yr_prev_vis_lend   == line("'>") && 
     642                \ s:yr_prev_vis_cstart == col("'<") && 
     643                \ s:yr_prev_vis_cend   == col("'>") && 
     644                \ s:yr_prev_chg_lstart == line("'[") && 
     645                \ s:yr_prev_chg_lend   == line("']") && 
     646                \ s:yr_prev_chg_cstart == col("'[") && 
     647                \ s:yr_prev_chg_cend   == col("']")  
     648        let dorepeat = 1 
    727649    endif 
    728650    " If we are going to repeat check to see if the 
     
    750672 
    751673        call setreg( (i-1) 
    752                     \ , s:YRGetValElemNbr((i-1),'v') 
    753                     \ , s:YRGetValElemNbr((i-1),'t') 
     674                    \ , s:YRGetValElemNbr(i,'v') 
     675                    \ , s:YRGetValElemNbr(i,'t') 
    754676                    \ ) 
    755         let i += 1 
     677        let i = i + 1 
    756678    endwhile 
    757679endfunction 
     
    841763 
    842764" Handles ranges.  There are visual ranges and command line ranges. 
    843 " Visual ranges are easy, since we pass through and let Vim deal 
     765" Visual ranges are easy, since we passthrough and let Vim deal 
    844766" with those directly. 
    845767" Command line ranges means we must yank the entire line, and not 
     
    953875    if a:replace_last_paste_selection != 1  
    954876        if s:yr_count > 0 
    955             if getreg(default_buffer) != s:YRGetValElemNbr(0,'v') 
     877            if getreg(default_buffer) != s:YRGetValElemNbr(1,'v') 
    956878                " The user has performed a yank / delete operation 
    957879                " outside of the yankring maps.  First, add this  
     
    1014936        let save_reg_type       = getregtype(default_buffer) 
    1015937        call setreg( default_buffer 
    1016                     \ , s:YRGetValElemNbr((s:yr_last_paste_idx-1),'v') 
    1017                     \ , s:YRGetValElemNbr((s:yr_last_paste_idx-1),'t') 
     938                    \ , s:YRGetValElemNbr(s:yr_last_paste_idx,'v') 
     939                    \ , s:YRGetValElemNbr(s:yr_last_paste_idx,'t') 
    1018940                    \ ) 
    1019941 
     
    1037959        let s:yr_last_paste_idx = 1 
    1038960        call setreg(default_buffer 
    1039                     \ , s:YRGetValElemNbr(0,'v') 
    1040                     \ , s:YRGetValElemNbr(0,'t') 
     961                    \ , s:YRGetValElemNbr(1,'v') 
     962                    \ , s:YRGetValElemNbr(1,'t') 
    1041963                    \ ) 
    1042964        exec "normal! ". 
     
    11631085    if g:yankring_paste_n_bkey != '' 
    11641086        exec 'nunmap '.g:yankring_paste_n_bkey 
    1165         if g:yankring_paste_using_g == 1 
    1166             exec 'nunmap g'.g:yankring_paste_n_bkey 
    1167         endif 
    11681087    endif 
    11691088    if g:yankring_paste_n_akey != '' 
    11701089        exec 'nunmap '.g:yankring_paste_n_akey 
    1171         if g:yankring_paste_using_g == 1 
    1172             exec 'nunmap g'.g:yankring_paste_n_akey 
    1173         endif 
    11741090    endif 
    11751091    if g:yankring_paste_v_bkey != '' 
     
    12001116    endif 
    12011117 
    1202     if needed_elem < 0 
     1118    if needed_elem < 1 
    12031119        " The yankring is a ring, so if an element is 
    12041120        " requested beyond the number of elements, we 
    12051121        " must wrap around the ring. 
    1206         " let needed_elem = s:yr_count + needed_elem + 1 
    1207         let needed_elem = s:yr_count + needed_elem  
     1122        let needed_elem = s:yr_count + needed_elem + 1 
    12081123    endif 
    12091124 
     
    12111126    " yankring, not the value.  These are stored within 
    12121127    " script variables. 
    1213     let elem = get(s:yr_elements, needed_elem) 
     1128    " 
     1129    " echo s:YRGetValElemNbr(3, 'v') 
     1130    " - Displays the 3rd element in the yankring 
     1131    " 
     1132    " echo s:YRGetValElemNbr(3, 't') 
     1133    " - Displays the register type of the 3rd element in the yankring 
     1134    let elem = s:YRMRUGet( 's:yr_elem_order', needed_elem ) 
    12141135 
    12151136    if elem >= 0 
    12161137        if a:type == 't' 
    1217             if exists(s:yr_scope.':YR_ELEM_TYPE_'.elem) 
    1218                 return {s:yr_scope}:YR_ELEM_TYPE_{elem} 
     1138            if exists('s:yr_elem_type_'.elem) 
     1139                return s:yr_elem_type_{elem} 
    12191140            endif 
    12201141        else 
    1221             if exists(s:yr_scope.':YR_ELEM_'.elem) 
    1222                 return {s:yr_scope}:YR_ELEM_{elem} 
     1142            if exists('s:yr_elem_'.elem) 
     1143                return s:yr_elem_{elem} 
    12231144            endif 
    12241145        endif 
     
    12301151endfunction 
    12311152 
    1232 function! s:YRMRUInit( mru_list, max_size, initial_values ) 
     1153function! s:YRMRUInit( mru_list ) 
    12331154 
    12341155    " Create the list if required 
    1235     if empty({a:mru_list}) && a:initial_values != '' 
    1236         let {a:mru_list} = split(a:initial_values, ',') 
    1237     endif 
    1238  
    1239     if len({a:mru_list}) > a:max_size 
    1240         " Ensure list does not exceed maximum size 
    1241         call remove({a:mru_list}, a:max_size, -1) 
    1242     endif 
    1243  
    1244     call s:YRMRUExport(a:mru_list) 
     1156    if !exists('{a:mru_list}') 
     1157        let {a:mru_list} = '' 
     1158        return 1 
     1159    endif 
    12451160 
    12461161    return 0 
     
    12491164function! s:YRMRUReset( mru_list ) 
    12501165 
    1251     let {a:mru_list} = [] 
    1252  
    1253     call s:YRMRUExport(a:mru_list) 
     1166    " Verify the list exists 
     1167    if !exists('{a:mru_list}') 
     1168        return -1 
     1169    else 
     1170        let {a:mru_list} = '' 
     1171    endif 
    12541172 
    12551173    return 1 
     
    12571175 
    12581176function! s:YRMRUSize( mru_list ) 
    1259     return len({a:mru_list}) 
     1177 
     1178    " The MRU list has elements of this format: 
     1179    "  \d+#\d+#\d+# 
     1180    " 
     1181    " This function returns how many items are in the MRU 
     1182 
     1183    if !exists('{a:mru_list}') 
     1184        return '-3' 
     1185    endif 
     1186 
     1187    let curr_cnt = strlen( 
     1188                \     substitute({a:mru_list}, '[^#]', '', 'g') 
     1189                \ ) 
     1190         
     1191    return curr_cnt 
     1192 
    12601193endfunction 
    12611194 
    12621195function! s:YRMRUHas( mru_list, find_str ) 
     1196 
     1197    " The MRU list has elements of this format: 
     1198    "  \d+#\d+#\d+# 
     1199    " 
    12631200    " This function will find a string and return the element # 
    1264     let find_idx = index({a:mru_list}, a:find_str) 
    1265  
    1266     return find_idx 
     1201 
     1202    if !exists('{a:mru_list}') 
     1203        return '-3' 
     1204    endif 
     1205 
     1206    let find_idx = match({a:mru_list}, '\(^\|#\)\zs'.a:find_str.'#') 
     1207    " Decho 'Get-'.a:find_str.'  find_idx:'.find_idx 
     1208 
     1209    if find_idx == -1  
     1210        return -1 
     1211    endif 
     1212 
     1213    let end_idx = match({a:mru_list}, '#', find_idx+1) 
     1214 
     1215    let curr_cnt = strlen( 
     1216                \     substitute( 
     1217                \         strpart({a:mru_list}, 0, end_idx+1),  
     1218                \     '[^#]', '', 'g') 
     1219                \ ) 
     1220         
     1221    return curr_cnt 
     1222 
    12671223endfunction 
    12681224 
    12691225function! s:YRMRUGet( mru_list, position ) 
     1226 
     1227    " The MRU list has elements of this format: 
     1228    "  \d+#\d+#\d+# 
     1229    " 
    12701230    " This function will return the value of the item at a:position 
     1231    " 
     1232    if !exists('{a:mru_list}') 
     1233        return '-3' 
     1234    endif 
     1235 
    12711236    " Find the value of one element 
    1272     let value = get({a:mru_list}, a:position, -2) 
     1237    let regex = '\zs\d\+\ze#' 
     1238 
     1239    if a:position > 1 
     1240        " Remove all the elements prior to this element 
     1241        let regex = '\(\d\+#\)\{'.(a:position-1).'}'.regex 
     1242    endif 
     1243    let value = matchstr({a:mru_list}, regex) 
     1244 
     1245    if value == "" 
     1246        " No element at the specified position 
     1247        return '-2' 
     1248    endif 
    12731249 
    12741250    return value 
     1251 
     1252endfunction 
     1253 
     1254function! s:YRMRUGetX( mru_list, find_str, move_to_top ) 
     1255 
     1256    " The MRU list has elements of this format: 
     1257    "  \d+#\d+#\d+# 
     1258    " 
     1259    " This function will find a string and return: 
     1260    "  :tbl_name:tbl_alias:tbl_cols: 
     1261    "  \d+ 
     1262    " 
     1263    " It will also remove that element from the list 
     1264    " Use the Add function to put it back on the TOP of the list 
     1265 
     1266    if !exists('{a:mru_list}') 
     1267        return '-3' 
     1268    endif 
     1269 
     1270    let find_idx = match({a:mru_list}, a:find_str) 
     1271    " Decho 'Get-'.a:find_str.'  find_idx:'.find_idx 
     1272 
     1273    if find_idx == -1  
     1274        return '-2' 
     1275    endif 
     1276 
     1277    let end_idx = match({a:mru_list}, '#', find_idx+1) 
     1278    " Decho 'Get-end_idx-'.end_idx 
     1279 
     1280    if end_idx != -1 
     1281        let element = substitute( strpart({a:mru_list}, 0, end_idx+1), 
     1282                    \ '.*\(:.*:.*:.*:\)#$', '\1', '' )  
     1283        let text_before = strpart({a:mru_list}, 0, (end_idx-strlen(element))) 
     1284        let text_after = strpart({a:mru_list}, end_idx+1) 
     1285        " Decho 'G-before-'.strpart({a:mru_list}, 0, (end_idx-strlen(element))) 
     1286        " Decho 'G-middle-'.element 
     1287        " Decho 'G-after-'.strpart({a:mru_list}, end_idx+1) 
     1288 
     1289        if a:move_to_top == 1 
     1290            let {a:mru_list} = element . '#' . text_before . text_after 
     1291        else 
     1292            let {a:mru_list} = text_before . text_after 
     1293        endif 
     1294 
     1295        " Decho "Get-new-#".{a:mru_list} 
     1296 
     1297        return element 
     1298    endif 
     1299         
     1300    " String not found 
     1301    return '-2' 
     1302 
    12751303endfunction 
    12761304 
    12771305function! s:YRMRUAdd( mru_list, element, element_type ) 
     1306 
    12781307    " Only add new items if they do not already exist in the MRU. 
    12791308    " If the item is found, move it to the start of the MRU. 
    1280     let found      = -1 
    1281     let elem       = '' 
    1282     let elem_index = 0 
    1283     for elem_item in {a:mru_list} 
    1284         let elem = s:YRGetValElemNbr(elem_index, 'v') 
    1285         " If the item has been found, move it to the start of the list 
    1286         " unless of course it is already at the start 
    1287         if elem == a:element && elem_item > 0 
    1288             call remove({a:mru_list}, elem_index) 
    1289             call insert({a:mru_list}, elem_item) 
    1290             let found = elem_index 
    1291             break 
    1292         endif 
    1293         let elem_index += 1 
    1294     endfor 
    1295  
    1296     if found == -1 
    1297         let {s:yr_scope}:YR_ELEM_{s:yr_next_idx}       = a:element 
    1298         let {s:yr_scope}:YR_ELEM_TYPE_{s:yr_next_idx}  = a:element_type 
    1299         let elem_index                                 = s:yr_next_idx 
    1300         let s:yr_next_idx                             += 1 
    1301         call insert({a:mru_list}, elem_index) 
    1302     endif 
     1309    let elem  = "" 
     1310    let found = 0 
     1311    let index = match({a:mru_list}, '\d\+#') 
     1312    while index > -1 
     1313        let elem = matchstr({a:mru_list}, '\d\+\ze#', index) 
     1314        " Safety check 
     1315        if exists('s:yr_elem_'.elem) 
     1316            " If the item already exists in the MRU 
     1317            " - Remove it 
     1318            " - And it will be added back to the front, since 
     1319            "   we always paste from the top of the yankring 
     1320            if s:yr_elem_{elem} == a:element 
     1321                let found = 1 
     1322                " Determine the index position of the next element 
     1323                let next_piece_idx = index + strlen(elem) + 1 
     1324                " Remove this element from the MRU  
     1325                let {a:mru_list} = strpart({a:mru_list}, 0, index) . 
     1326                            \ strpart({a:mru_list}, next_piece_idx)  
     1327                break 
     1328            endif 
     1329        endif 
     1330        let size  = strlen(elem)+1 
     1331        let index = match({a:mru_list}, '\d\+#', (index+size) ) 
     1332    endwhile 
     1333 
     1334    if found == 0 
     1335        let s:yr_elem_{s:yr_next_idx}      = a:element 
     1336        let s:yr_elem_type_{s:yr_next_idx} = a:element_type 
     1337        let elem                           = s:yr_next_idx 
     1338        let s:yr_next_idx                  = s:yr_next_idx + 1 
     1339    endif 
     1340 
     1341    if strlen(elem) != 0 
     1342        " Add the new filename to the beginning of the MRU list 
     1343        let {a:mru_list} = elem.'#'.{a:mru_list} 
     1344        " Decho "A-new-#".{a:mru_list} 
     1345    else 
     1346        call s:YRErrorMsg('YRMRUAdd: No element #,'. 
     1347                    \ ' found:'.found. 
     1348                    \ '  elem:'.elem. 
     1349                    \'  s:yr_next_idx:'.s:yr_next_idx 
     1350                    \ ) 
     1351        return "" 
     1352    endif  
    13031353 
    13041354    " Allow (retain) only g:yankring_max_history in the MRU list. 
     
    13061356    " the list, the list should have only g:yankring_max_history - 1 in it. 
    13071357    let curr_cnt = s:YRMRUSize(a:mru_list) 
     1358    " Decho 'A-items-'.curr_cnt 
    13081359 
    13091360    if curr_cnt > g:yankring_max_history 
    1310         " Since the yankring is full, set the s:yr_next_idx 
     1361        " If the yankring is full, set the s:yr_next_idx 
    13111362        " to the last item in the MRU list 
    1312         " Return -1 if this fails 
    1313         let s:yr_next_idx = get({a:mru_list}, -1, -1) 
    1314         call remove({a:mru_list}, -1) 
    1315  
    1316         if s:yr_next_idx == -1 
    1317             call s:YRErrorMsg( 
    1318                         \ 'YRMRUAdd: Last element not found: '. 
    1319                         \ {a:mru_list}.':'. 
     1363        let s:yr_next_idx = matchstr({a:mru_list}, '.*\zs\d\+\ze#$') 
     1364 
     1365        if s:yr_next_idx == "" 
     1366            call s:YRErrorMsg('YRMRUAdd: Last element not found: '. 
     1367                        \ a:mru_list.':'. 
    13201368                        \ {a:mru_list} 
    13211369                        \ ) 
    13221370        endif 
     1371        " Decho "A-old_list-#".{a:mru_list}."\n" 
     1372        " Strip off the last element from the list 
     1373        let {a:mru_list} = substitute({a:mru_list},  
     1374                    \ '\(.*#\)\d\+#$', '\1', '' )  
     1375        " Decho "A-new_list-#".{a:mru_list}."\n" 
    13231376    endif 
    13241377 
    13251378    let s:yr_count = s:YRMRUSize(a:mru_list) 
    1326  
    1327     call s:YRMRUExport(a:mru_list) 
    13281379 
    13291380    return 1 
     
    13341385    " This regex determines how many elements to keep 
    13351386    " at the front of the yankring 
    1336     call remove({a:mru_list}, a:elem_nbr) 
     1387    let begin_regex = "" 
     1388    if a:elem_nbr > 1 
     1389        let begin_regex = '\(\%(\d\+#\)\{'.(a:elem_nbr-1).'}\)' 
     1390        let sub_parms   = '\1\2' 
     1391    else 
     1392        let sub_parms   = '\1' 
     1393    endif 
     1394 
     1395    " This regex gets 1 element, and the remaining elements 
     1396    " at the end of the yankring 
     1397    let end_regex = "" 
     1398    let end_regex = '\d\+#\(.*\)' 
     1399 
     1400    " Strip off the nth element from the list 
     1401    let {a:mru_list} = substitute({a:mru_list},  
     1402                \ begin_regex . end_regex, sub_parms, '' )  
    13371403 
    13381404    let s:yr_count = s:YRMRUSize(a:mru_list) 
    13391405 
    1340     call s:YRMRUExport(a:mru_list) 
    1341  
    13421406    return 1 
    1343 endfunction 
    1344  
    1345 function! s:YRMRUExport( mru_list ) 
    1346     " Export the List into the variable.  If this is a global variable 
    1347     " a comma separated list is created as a global variable so that 
    1348     " it can be saved within the viminfo file. 
    1349     if s:yr_scope == 'g' 
    1350         let {s:yr_scope}:YR_ELEM_ORDER = join({a:mru_list}, ',') 
    1351     endif 
    13521407endfunction 
    13531408 
     
    13871442 
    13881443    let msg = 'AutoClose='.g:yankring_window_auto_close. 
    1389                 \ ';Cmds:<enter>,[g]p,[p]P,d,r,a,u,q,<space>;Help=?'. 
    1390                 \ (s:yr_search==""?"":';SearchRegEx='.s:yr_search) 
     1444                \ ';Cmds:<enter>,[g]p,[p]P,d,r,a,u,q,<space>;Help=?' 
    13911445 
    13921446    " Toggle help by checking the first line of the buffer 
     
    16891743                    endif 
    16901744                    exec cmd . elem . parms 
    1691                     let iter += 1 
     1745                    let iter = iter + 1 
    16921746                endif 
    16931747                " Search for the next element beginning with a newline character 
     
    17571811" Deleting autocommands first is a good idea especially if we want to reload 
    17581812" the script without restarting vim. 
    1759 " Call YRInit in the VimEnter event so that the global variables have been 
    1760 " restored via the viminfo file.  Calling YRInit prior to this will  
    1761 " not restore the yankring order or items. 
    17621813augroup YankRing 
    17631814    autocmd! 
    1764     autocmd VimEnter * :call <SID>YRInit() 
    17651815    autocmd WinLeave * :call <SID>YRWinLeave() 
    17661816augroup END 
     
    17831833command! -range -bang     -nargs=? YRYankRange   <line1>,<line2>call s:YRYankRange(<bang>0, <args>) 
    17841834 
    1785 " Verify the viminfo setting has !, which is required to  
    1786 " persist global variables 
    1787 if s:yr_scope == 'g' 
    1788     if &viminfo !~ '!' 
    1789         call s:YRWarningMsg('YR: The yankring can only persist if the viminfo setting has a "!" ') 
    1790     endif 
    1791 endif 
     1835" Initialize YankRing 
     1836call s:YRClear() 
    17921837 
    17931838if g:yankring_enabled == 1 
     
    18011846endif 
    18021847 
    1803 call s:YRInit() 
    1804        
    1805  
    1806 " vim:fdm=marker:nowrap:ts=4:expandtab: 
  • dotfiles/vim/ishihara/.vimrc

    r7191 r9179  
    245245 
    246246""" plugin/yankring.vim 
    247 set viminfo+=! 
     247"set viminfo+=! " for v3.0 
    248248 
    249249