Browse files

初次提交

  • Loading branch information...
0 parents commit 19e3f525d439fe18d177b10a36f36a8dc8db084a @lilydjwg committed Oct 25, 2010
Showing with 27,503 additions and 0 deletions.
  1. +6 −0 .VimballRecord
  2. +2 −0 .gitignore
  3. +24 −0 LICENSE.EnhancedCommentify
  4. +2 −0 after/ftplugin/c.vim
  5. +12 −0 after/ftplugin/c_mine.vim
  6. +11 −0 after/ftplugin/cpp.vim
  7. +35 −0 after/plugin/snipMate.vim
  8. +12 −0 after/syntax/c.vim
  9. +323 −0 after/syntax/css/css.vim
  10. +10 −0 after/syntax/css/pseudo.vim
  11. +11 −0 after/syntax/dosini.vim
  12. +11 −0 after/syntax/html.vim
  13. +13 −0 after/syntax/python.vim
  14. +25 −0 after/syntax/sh.vim
  15. +11 −0 after/syntax/tex.vim
  16. +7 −0 after/syntax/vim.vim
  17. +1,036 −0 autoload/Align.vim
  18. +330 −0 autoload/AlignMaps.vim
  19. +1,954 −0 autoload/genutils.vim
  20. +464 −0 autoload/mark.vim
  21. +8,013 −0 autoload/netrw.vim
  22. +361 −0 autoload/netrwFileHandlers.vim
  23. +207 −0 autoload/netrwSettings.vim
  24. +32 −0 autoload/omni/common/debug.vim
  25. +67 −0 autoload/omni/common/utils.vim
  26. +569 −0 autoload/omni/cpp/complete.vim
  27. +126 −0 autoload/omni/cpp/includes.vim
  28. +660 −0 autoload/omni/cpp/items.vim
  29. +82 −0 autoload/omni/cpp/maycomplete.vim
  30. +838 −0 autoload/omni/cpp/namespaces.vim
  31. +96 −0 autoload/omni/cpp/settings.vim
  32. +93 −0 autoload/omni/cpp/tokenizer.vim
  33. +587 −0 autoload/omni/cpp/utils.vim
  34. +433 −0 autoload/snipMate.vim
  35. +943 −0 autoload/vimwiki.vim
  36. +224 −0 autoload/vimwiki_diary.vim
  37. +1,293 −0 autoload/vimwiki_html.vim
  38. +362 −0 autoload/vimwiki_lst.vim
  39. +504 −0 autoload/vimwiki_tbl.vim
  40. +57 −0 autoload/xml/stl_c.vim
  41. +49 −0 autoload/xml/stl_fmt.vim
  42. +25 −0 autoload/xml/stl_sql.vim
  43. +41 −0 autoload/xml/stl_x.vim
  44. +392 −0 autoload/zip.vim
  45. +32 −0 colors/BlackSea.vim
  46. +72 −0 colors/adaryn.vim
  47. +108 −0 colors/anotherdark.vim
  48. +105 −0 colors/asmdev.vim
  49. +59 −0 colors/asu1dark.vim
  50. +71 −0 colors/autumn.vim
  51. +72 −0 colors/autumn_lily.vim
  52. +154 −0 colors/autumnleaf.vim
  53. +64 −0 colors/beachcomber.vim
  54. +115 −0 colors/biogoo.vim
  55. +115 −0 colors/black_angus.vim
  56. +49 −0 colors/blacklight.vim
  57. +62 −0 colors/blueprint.vim
  58. +42 −0 colors/blugrine.vim
  59. +60 −0 colors/borland.vim
  60. +70 −0 colors/breeze.vim
  61. +74 −0 colors/breeze_lily.vim
  62. +83 −0 colors/brookstream.vim
  63. +32 −0 colors/brown.vim
  64. +59 −0 colors/buttercream.vim
  65. +247 −0 colors/calmar256_light.vim
  66. +76 −0 colors/camo.vim
  67. +67 −0 colors/caramel.vim
  68. +110 −0 colors/chela_light.vim
  69. +79 −0 colors/chlordane.vim
  70. +72 −0 colors/corn.vim
  71. +322 −0 colors/crt.vim
  72. +83 −0 colors/dante.vim
  73. +90 −0 colors/darkBlue.vim
  74. +130 −0 colors/darkspectrum.vim
  75. +65 −0 colors/dawn.vim
  76. +98 −0 colors/desertEx.vim
  77. +71 −0 colors/dusk.vim
  78. +66 −0 colors/dw_cyan.vim
  79. +66 −0 colors/dw_green.vim
  80. +66 −0 colors/dw_orange.vim
  81. +159 −0 colors/earendel.vim
  82. +92 −0 colors/eclipse.vim
  83. +69 −0 colors/edo_sea.vim
  84. +89 −0 colors/ekvoli.vim
  85. +79 −0 colors/fine_blue.vim
  86. +71 −0 colors/fine_blue2.vim
  87. +170 −0 colors/fog.vim
  88. +79 −0 colors/freya.vim
  89. +69 −0 colors/fruit.vim
  90. +147 −0 colors/fruity.vim
  91. +138 −0 colors/habilight.vim
  92. +83 −0 colors/hhspring.vim
  93. +83 −0 colors/hhteal.vim
  94. +83 −0 colors/hhviolet.vim
  95. +193 −0 colors/hotoo.vim
  96. +66 −0 colors/impact.vim
  97. +138 −0 colors/inkpot.vim
  98. +212 −0 colors/ir_black.vim
  99. +133 −0 colors/ironman.vim
  100. +410 −0 colors/jellybeans.vim
  101. +150 −0 colors/leo.vim
  102. +215 −0 colors/lettuce.vim
  103. +92 −0 colors/lilydjwg_dark_1.1.vim
  104. +92 −0 colors/lilydjwg_green_1.5.vim
  105. +106 −0 colors/lilydjwg_purple_1.1.vim
  106. +69 −0 colors/lilypink.vim
  107. +340 −0 colors/lucius.vim
  108. +96 −0 colors/manuscript.vim
  109. +47 −0 colors/manxome.vim
  110. +174 −0 colors/marklar.vim
Sorry, we could not display the entire diff because too many files (537) changed.
6 .VimballRecord
@@ -0,0 +1,6 @@
+Align.vba: call delete('/home/lilydjwg/.vim/plugin/AlignPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/AlignMapsPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')|call delete('/home/lilydjwg/.vim/doc/Align.txt')|call delete('/home/lilydjwg/.vim/autoload/Align.vim')|call delete('/home/lilydjwg/.vim/autoload/AlignMaps.vim')
+mark.vba: call delete('/home/lilydjwg/.vim/autoload/mark.vim')|call delete('/home/lilydjwg/.vim/plugin/mark.vim')|call delete('/home/lilydjwg/.vim/doc/mark.txt')
+vis.vba: call delete('/home/lilydjwg/.vim/plugin/vis.vim')|call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')|call delete('/home/lilydjwg/.vim/doc/vis.txt')
+vimwiki-1-0.vba: call delete('/home/lilydjwg/.vim/autoload/vimwiki.vim')|call delete('/home/lilydjwg/.vim/autoload/vimwiki_diary.vim')|call delete('/home/lilydjwg/.vim/autoload/vimwiki_html.vim')|call delete('/home/lilydjwg/.vim/autoload/vimwiki_lst.vim')|call delete('/home/lilydjwg/.vim/autoload/vimwiki_tbl.vim')|call delete('/home/lilydjwg/.vim/doc/vimwiki.txt')|call delete('/home/lilydjwg/.vim/ftplugin/vimwiki.vim')|call delete('/home/lilydjwg/.vim/plugin/vimwiki.vim')|call delete('/home/lilydjwg/.vim/syntax/vimwiki.vim')|call delete('/home/lilydjwg/.vim/syntax/vimwiki_default.vim')|call delete('/home/lilydjwg/.vim/syntax/vimwiki_media.vim')
+cecutil.vba: call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')|call delete('/home/lilydjwg/.vim/doc/cecutil.txt')
+html5.vim-0.26.vba: call delete('/home/lilydjwg/.vim/autoload/xml/aria.vim')
2 .gitignore
@@ -0,0 +1,2 @@
+.netrwhist
+vim_mru_files
24 LICENSE.EnhancedCommentify
@@ -0,0 +1,24 @@
+Copyright (c) 2008 Meikel Brandmeyer, Frankfurt am Main
+All rights reserved.
+
+Redistribution and use in source and binary form are permitted provided
+that the following conditions are met:
+
+1. Redistribition of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
2 after/ftplugin/c.vim
@@ -0,0 +1,2 @@
+" OmniCppComplete initialization
+call omni#cpp#complete#Init()
12 after/ftplugin/c_mine.vim
@@ -0,0 +1,12 @@
+" Vim script file
+" FileType: C (and C++)
+" Author: lilydjwg <lilydjwg@gmail.com>
+" Last Change: 2010年3月30日
+
+" ---------------------------------------------------------------------
+" Settings:
+let b:match_words .= ',\<if\>:\<else\>,\<switch\>:\<case\>:\<default\>'
+" ---------------------------------------------------------------------
+" Vim Modeline:
+" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
+" ---------------------------------------------------------------------
11 after/ftplugin/cpp.vim
@@ -0,0 +1,11 @@
+" Vim script file
+" FileType: C++
+" Author: lilydjwg <lilydjwg@gmail.com>
+" Last Change: 2010年3月11日
+" ---------------------------------------------------------------------
+" Settings:
+let b:match_words .= ',\<try\>:\<catch\>'
+" ---------------------------------------------------------------------
+" Vim Modeline:
+" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
+" ---------------------------------------------------------------------
35 after/plugin/snipMate.vim
@@ -0,0 +1,35 @@
+" These are the mappings for snipMate.vim. Putting it here ensures that it
+" will be mapped after other plugins such as supertab.vim.
+if !exists('loaded_snips') || exists('s:did_snips_mappings')
+ finish
+endif
+let s:did_snips_mappings = 1
+
+ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
+snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
+ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
+snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
+ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr>
+
+" The default mappings for these are annoying & sometimes break snipMate.
+" You can change them back if you want, I've put them here for convenience.
+snor <bs> b<bs>
+snor <right> <esc>a
+snor <left> <esc>bi
+snor ' b<bs>'
+snor ` b<bs>`
+snor % b<bs>%
+snor U b<bs>U
+snor ^ b<bs>^
+snor \ b<bs>\
+snor <c-x> b<bs><c-x>
+
+" By default load snippets in snippets_dir
+if empty(snippets_dir)
+ finish
+endif
+
+call GetSnippets(snippets_dir, '_') " Get global snippets
+
+au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
+" vim:noet:sw=4:ts=4:ft=vim
12 after/syntax/c.vim
@@ -0,0 +1,12 @@
+" Vim syntax file
+" FileType: C/C++
+" Author: lilydjwg
+" Last Change: 2009年12月22日
+
+syntax case match
+
+" 在 MediaWiki 中,这样才正常
+" 不要 keepend,结束的 </code> 不高亮;
+if &ft == 'wiki'
+ syntax region cBlock start="{" end="}" fold transparent keepend
+endif
323 after/syntax/css/css.vim
@@ -0,0 +1,323 @@
+" Language: Colored CSS Color Preview
+" Maintainer: Niklas Hofer <niklas+vim@lanpartei.de>
+" URL: svn://lanpartei.de/vimrc/after/syntax/css.vim
+" Last Change: 2010-09-23
+" Licence: No Warranties. Do whatever you want with this. But please tell me!
+" Version: 0.6
+
+" lilydjwg: too slow in terminal
+if !has("gui_running")
+ finish
+endif
+
+function! s:FGforBG(bg)
+ " takes a 6hex color code and returns a matching color that is visible
+ let pure = substitute(a:bg,'^#','','')
+ let r = eval('0x'.pure[0].pure[1])
+ let g = eval('0x'.pure[2].pure[3])
+ let b = eval('0x'.pure[4].pure[5])
+ if r*30 + g*59 + b*11 > 12000
+ return '#000000'
+ else
+ return '#ffffff'
+ end
+endfunction
+
+function! s:SetMatcher(clr,pat)
+ let group = 'cssColor'.substitute(a:clr,'^#','','')
+ redir => s:currentmatch
+ silent! exe 'syn list '.group
+ redir END
+ if s:currentmatch !~ a:pat.'\/'
+ exe 'syn match '.group.' /'.a:pat.'\>/ contained'
+ exe 'syn cluster cssColors add='.group
+ if has('gui_running')
+ exe 'hi '.group.' guifg='.s:FGforBG(a:clr)
+ exe 'hi '.group.' guibg='.a:clr
+ elseif &t_Co == 256
+ exe 'hi '.group.' ctermfg='.s:Rgb2xterm(s:FGforBG(a:clr))
+ exe 'hi '.group.' ctermbg='.s:Rgb2xterm(a:clr)
+ endif
+ return 1
+ else
+ return 0
+ endif
+endfunction
+
+"" the 6 value iterations in the xterm color cube
+let s:valuerange = [ 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF ]
+"
+"" 16 basic colors
+let s:basic16 = [ [ 0x00, 0x00, 0x00 ], [ 0xCD, 0x00, 0x00 ], [ 0x00, 0xCD, 0x00 ], [ 0xCD, 0xCD, 0x00 ], [ 0x00, 0x00, 0xEE ], [ 0xCD, 0x00, 0xCD ], [ 0x00, 0xCD, 0xCD ], [ 0xE5, 0xE5, 0xE5 ], [ 0x7F, 0x7F, 0x7F ], [ 0xFF, 0x00, 0x00 ], [ 0x00, 0xFF, 0x00 ], [ 0xFF, 0xFF, 0x00 ], [ 0x5C, 0x5C, 0xFF ], [ 0xFF, 0x00, 0xFF ], [ 0x00, 0xFF, 0xFF ], [ 0xFF, 0xFF, 0xFF ] ]
+:
+function! s:Xterm2rgb(color)
+ " 16 basic colors
+ let r=0
+ let g=0
+ let b=0
+ if a:color<16
+ let r = s:basic16[a:color][0]
+ let g = s:basic16[a:color][1]
+ let b = s:basic16[a:color][2]
+ endif
+
+ " color cube color
+ if a:color>=16 && a:color<=232
+ let color=a:color-16
+ let r = s:valuerange[(color/36)%6]
+ let g = s:valuerange[(color/6)%6]
+ let b = s:valuerange[color%6]
+ endif
+
+ " gray tone
+ if a:color>=233 && a:color<=253
+ let r=8+(a:color-232)*0x0a
+ let g=r
+ let b=r
+ endif
+ let rgb=[r,g,b]
+ return rgb
+endfunction
+
+function! s:pow(x, n)
+ let x = a:x
+ for i in range(a:n-1)
+ let x = x*a:x
+ return x
+endfunction
+
+let s:colortable=[]
+for c in range(0, 254)
+ let color = s:Xterm2rgb(c)
+ call add(s:colortable, color)
+endfor
+
+" selects the nearest xterm color for a rgb value like #FF0000
+function! s:Rgb2xterm(color)
+ let best_match=0
+ let smallest_distance = 10000000000
+ let r = eval('0x'.a:color[1].a:color[2])
+ let g = eval('0x'.a:color[3].a:color[4])
+ let b = eval('0x'.a:color[5].a:color[6])
+ for c in range(0,254)
+ let d = s:pow(s:colortable[c][0]-r,2) + s:pow(s:colortable[c][1]-g,2) + s:pow(s:colortable[c][2]-b,2)
+ if d<smallest_distance
+ let smallest_distance = d
+ let best_match = c
+ endif
+ endfor
+ return best_match
+endfunction
+
+function! s:SetNamedColor(clr,name)
+ let group = 'cssColor'.substitute(a:clr,'^#','','')
+ exe 'syn keyword '.group.' '.a:name.' contained'
+ exe 'syn cluster cssColors add='.group
+ if has('gui_running')
+ exe 'hi '.group.' guifg='.s:FGforBG(a:clr)
+ exe 'hi '.group.' guibg='.a:clr
+ elseif &t_Co == 256
+ exe 'hi '.group.' ctermfg='.s:Rgb2xterm(s:FGforBG(a:clr))
+ exe 'hi '.group.' ctermbg='.s:Rgb2xterm(a:clr)
+ endif
+ return 23
+endfunction
+
+function! s:PreviewCSSColorInLine(where)
+ " TODO use cssColor matchdata
+ let foundcolor = matchstr( getline(a:where), '#[0-9A-Fa-f]\{3,6\}\>' )
+ let color = ''
+ if foundcolor != ''
+ if foundcolor =~ '#\x\{6}$'
+ let color = foundcolor
+ elseif foundcolor =~ '#\x\{3}$'
+ let color = substitute(foundcolor, '\(\x\)\(\x\)\(\x\)', '\1\1\2\2\3\3', '')
+ else
+ let color = ''
+ endif
+ if color != ''
+ return s:SetMatcher(color,foundcolor)
+ else
+ return 0
+ endif
+ else
+ return 0
+ endif
+endfunction
+
+if has("gui_running") || &t_Co==256
+ " HACK modify cssDefinition to add @cssColors to its contains
+ redir => s:olddef
+ silent! syn list cssDefinition
+ redir END
+ if s:olddef != ''
+ let s:b = strridx(s:olddef,'matchgroup')
+ if s:b != -1
+ exe 'syn region cssDefinition '.strpart(s:olddef,s:b).',@cssColors'
+ endif
+ endif
+
+ " w3c Colors
+ let i = s:SetNamedColor('#800000', 'maroon')
+ let i = s:SetNamedColor('#ff0000', 'red')
+ let i = s:SetNamedColor('#ffA500', 'orange')
+ let i = s:SetNamedColor('#ffff00', 'yellow')
+ let i = s:SetNamedColor('#808000', 'olive')
+ let i = s:SetNamedColor('#800080', 'purple')
+ let i = s:SetNamedColor('#ff00ff', 'fuchsia')
+ let i = s:SetNamedColor('#ffffff', 'white')
+ let i = s:SetNamedColor('#00ff00', 'lime')
+ let i = s:SetNamedColor('#008000', 'green')
+ let i = s:SetNamedColor('#000080', 'navy')
+ let i = s:SetNamedColor('#0000ff', 'blue')
+ let i = s:SetNamedColor('#00ffff', 'aqua')
+ let i = s:SetNamedColor('#008080', 'teal')
+ let i = s:SetNamedColor('#000000', 'black')
+ let i = s:SetNamedColor('#c0c0c0', 'silver')
+ let i = s:SetNamedColor('#808080', 'gray')
+
+ " extra colors
+ let i = s:SetNamedColor('#F0F8FF','AliceBlue')
+ let i = s:SetNamedColor('#FAEBD7','AntiqueWhite')
+ let i = s:SetNamedColor('#7FFFD4','Aquamarine')
+ let i = s:SetNamedColor('#F0FFFF','Azure')
+ let i = s:SetNamedColor('#F5F5DC','Beige')
+ let i = s:SetNamedColor('#FFE4C4','Bisque')
+ let i = s:SetNamedColor('#FFEBCD','BlanchedAlmond')
+ let i = s:SetNamedColor('#8A2BE2','BlueViolet')
+ let i = s:SetNamedColor('#A52A2A','Brown')
+ let i = s:SetNamedColor('#DEB887','BurlyWood')
+ let i = s:SetNamedColor('#5F9EA0','CadetBlue')
+ let i = s:SetNamedColor('#7FFF00','Chartreuse')
+ let i = s:SetNamedColor('#D2691E','Chocolate')
+ let i = s:SetNamedColor('#FF7F50','Coral')
+ let i = s:SetNamedColor('#6495ED','CornflowerBlue')
+ let i = s:SetNamedColor('#FFF8DC','Cornsilk')
+ let i = s:SetNamedColor('#DC143C','Crimson')
+ let i = s:SetNamedColor('#00FFFF','Cyan')
+ let i = s:SetNamedColor('#00008B','DarkBlue')
+ let i = s:SetNamedColor('#008B8B','DarkCyan')
+ let i = s:SetNamedColor('#B8860B','DarkGoldenRod')
+ let i = s:SetNamedColor('#A9A9A9','DarkGray')
+ let i = s:SetNamedColor('#A9A9A9','DarkGrey')
+ let i = s:SetNamedColor('#006400','DarkGreen')
+ let i = s:SetNamedColor('#BDB76B','DarkKhaki')
+ let i = s:SetNamedColor('#8B008B','DarkMagenta')
+ let i = s:SetNamedColor('#556B2F','DarkOliveGreen')
+ let i = s:SetNamedColor('#FF8C00','Darkorange')
+ let i = s:SetNamedColor('#9932CC','DarkOrchid')
+ let i = s:SetNamedColor('#8B0000','DarkRed')
+ let i = s:SetNamedColor('#E9967A','DarkSalmon')
+ let i = s:SetNamedColor('#8FBC8F','DarkSeaGreen')
+ let i = s:SetNamedColor('#483D8B','DarkSlateBlue')
+ let i = s:SetNamedColor('#2F4F4F','DarkSlateGray')
+ let i = s:SetNamedColor('#2F4F4F','DarkSlateGrey')
+ let i = s:SetNamedColor('#00CED1','DarkTurquoise')
+ let i = s:SetNamedColor('#9400D3','DarkViolet')
+ let i = s:SetNamedColor('#FF1493','DeepPink')
+ let i = s:SetNamedColor('#00BFFF','DeepSkyBlue')
+ let i = s:SetNamedColor('#696969','DimGray')
+ let i = s:SetNamedColor('#696969','DimGrey')
+ let i = s:SetNamedColor('#1E90FF','DodgerBlue')
+ let i = s:SetNamedColor('#B22222','FireBrick')
+ let i = s:SetNamedColor('#FFFAF0','FloralWhite')
+ let i = s:SetNamedColor('#228B22','ForestGreen')
+ let i = s:SetNamedColor('#DCDCDC','Gainsboro')
+ let i = s:SetNamedColor('#F8F8FF','GhostWhite')
+ let i = s:SetNamedColor('#FFD700','Gold')
+ let i = s:SetNamedColor('#DAA520','GoldenRod')
+ let i = s:SetNamedColor('#808080','Grey')
+ let i = s:SetNamedColor('#ADFF2F','GreenYellow')
+ let i = s:SetNamedColor('#F0FFF0','HoneyDew')
+ let i = s:SetNamedColor('#FF69B4','HotPink')
+ let i = s:SetNamedColor('#CD5C5C','IndianRed')
+ let i = s:SetNamedColor('#4B0082','Indigo')
+ let i = s:SetNamedColor('#FFFFF0','Ivory')
+ let i = s:SetNamedColor('#F0E68C','Khaki')
+ let i = s:SetNamedColor('#E6E6FA','Lavender')
+ let i = s:SetNamedColor('#FFF0F5','LavenderBlush')
+ let i = s:SetNamedColor('#7CFC00','LawnGreen')
+ let i = s:SetNamedColor('#FFFACD','LemonChiffon')
+ let i = s:SetNamedColor('#ADD8E6','LightBlue')
+ let i = s:SetNamedColor('#F08080','LightCoral')
+ let i = s:SetNamedColor('#E0FFFF','LightCyan')
+ let i = s:SetNamedColor('#FAFAD2','LightGoldenRodYellow')
+ let i = s:SetNamedColor('#D3D3D3','LightGray')
+ let i = s:SetNamedColor('#D3D3D3','LightGrey')
+ let i = s:SetNamedColor('#90EE90','LightGreen')
+ let i = s:SetNamedColor('#FFB6C1','LightPink')
+ let i = s:SetNamedColor('#FFA07A','LightSalmon')
+ let i = s:SetNamedColor('#20B2AA','LightSeaGreen')
+ let i = s:SetNamedColor('#87CEFA','LightSkyBlue')
+ let i = s:SetNamedColor('#778899','LightSlateGray')
+ let i = s:SetNamedColor('#778899','LightSlateGrey')
+ let i = s:SetNamedColor('#B0C4DE','LightSteelBlue')
+ let i = s:SetNamedColor('#FFFFE0','LightYellow')
+ let i = s:SetNamedColor('#32CD32','LimeGreen')
+ let i = s:SetNamedColor('#FAF0E6','Linen')
+ let i = s:SetNamedColor('#FF00FF','Magenta')
+ let i = s:SetNamedColor('#66CDAA','MediumAquaMarine')
+ let i = s:SetNamedColor('#0000CD','MediumBlue')
+ let i = s:SetNamedColor('#BA55D3','MediumOrchid')
+ let i = s:SetNamedColor('#9370D8','MediumPurple')
+ let i = s:SetNamedColor('#3CB371','MediumSeaGreen')
+ let i = s:SetNamedColor('#7B68EE','MediumSlateBlue')
+ let i = s:SetNamedColor('#00FA9A','MediumSpringGreen')
+ let i = s:SetNamedColor('#48D1CC','MediumTurquoise')
+ let i = s:SetNamedColor('#C71585','MediumVioletRed')
+ let i = s:SetNamedColor('#191970','MidnightBlue')
+ let i = s:SetNamedColor('#F5FFFA','MintCream')
+ let i = s:SetNamedColor('#FFE4E1','MistyRose')
+ let i = s:SetNamedColor('#FFE4B5','Moccasin')
+ let i = s:SetNamedColor('#FFDEAD','NavajoWhite')
+ let i = s:SetNamedColor('#FDF5E6','OldLace')
+ let i = s:SetNamedColor('#6B8E23','OliveDrab')
+ let i = s:SetNamedColor('#FF4500','OrangeRed')
+ let i = s:SetNamedColor('#DA70D6','Orchid')
+ let i = s:SetNamedColor('#EEE8AA','PaleGoldenRod')
+ let i = s:SetNamedColor('#98FB98','PaleGreen')
+ let i = s:SetNamedColor('#AFEEEE','PaleTurquoise')
+ let i = s:SetNamedColor('#D87093','PaleVioletRed')
+ let i = s:SetNamedColor('#FFEFD5','PapayaWhip')
+ let i = s:SetNamedColor('#FFDAB9','PeachPuff')
+ let i = s:SetNamedColor('#CD853F','Peru')
+ let i = s:SetNamedColor('#FFC0CB','Pink')
+ let i = s:SetNamedColor('#DDA0DD','Plum')
+ let i = s:SetNamedColor('#B0E0E6','PowderBlue')
+ let i = s:SetNamedColor('#BC8F8F','RosyBrown')
+ let i = s:SetNamedColor('#4169E1','RoyalBlue')
+ let i = s:SetNamedColor('#8B4513','SaddleBrown')
+ let i = s:SetNamedColor('#FA8072','Salmon')
+ let i = s:SetNamedColor('#F4A460','SandyBrown')
+ let i = s:SetNamedColor('#2E8B57','SeaGreen')
+ let i = s:SetNamedColor('#FFF5EE','SeaShell')
+ let i = s:SetNamedColor('#A0522D','Sienna')
+ let i = s:SetNamedColor('#87CEEB','SkyBlue')
+ let i = s:SetNamedColor('#6A5ACD','SlateBlue')
+ let i = s:SetNamedColor('#708090','SlateGray')
+ let i = s:SetNamedColor('#708090','SlateGrey')
+ let i = s:SetNamedColor('#FFFAFA','Snow')
+ let i = s:SetNamedColor('#00FF7F','SpringGreen')
+ let i = s:SetNamedColor('#4682B4','SteelBlue')
+ let i = s:SetNamedColor('#D2B48C','Tan')
+ let i = s:SetNamedColor('#D8BFD8','Thistle')
+ let i = s:SetNamedColor('#FF6347','Tomato')
+ let i = s:SetNamedColor('#40E0D0','Turquoise')
+ let i = s:SetNamedColor('#EE82EE','Violet')
+ let i = s:SetNamedColor('#F5DEB3','Wheat')
+ let i = s:SetNamedColor('#F5F5F5','WhiteSmoke')
+ let i = s:SetNamedColor('#9ACD32','YellowGreen')
+
+
+
+ let i = 1
+ while i <= line("$")
+ call s:PreviewCSSColorInLine(i)
+ let i = i+1
+ endwhile
+ unlet i
+
+ autocmd CursorHold * silent call s:PreviewCSSColorInLine('.')
+ autocmd CursorHoldI * silent call s:PreviewCSSColorInLine('.')
+ set ut=100
+endif " has("gui_running")
10 after/syntax/css/pseudo.vim
@@ -0,0 +1,10 @@
+" Vim script file
+" FileType: CSS (日记)
+" Author: lilydjwg
+" Maintainer: lilydjwg
+" Last Change: 2010年5月23日
+"
+" 伪类后不必有空格
+syn match cssPseudoClass ":[^{]\+" contains=cssPseudoClassId,cssUnicodeEscape
+syn match cssPseudoClass "::[^{]\+" contains=cssPseudoClassId,cssUnicodeEscape
+syn match cssPseudoClassId contained /\v-moz-selection|selection/
11 after/syntax/dosini.vim
@@ -0,0 +1,11 @@
+" Vim syntax file
+" FileType: dosini 补充
+" Author: lilydjwg <lilydjwg@gmail.com>
+" Last Change: 2010年7月13日
+
+" ---------------------------------------------------------------------
+syn match dosiniComment "^[;#].*$"
+" ---------------------------------------------------------------------
+" Vim Modeline:
+" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
+" ---------------------------------------------------------------------
11 after/syntax/html.vim
@@ -0,0 +1,11 @@
+" Vim syntax file
+" FileType: HTML
+" Author: lilydjwg <lilydjwg@gmail.com>
+" Last Change: 2010年5月23日
+
+" ---------------------------------------------------------------------
+syn include @htmlCss after/syntax/css/*.vim
+" ---------------------------------------------------------------------
+" Vim Modeline:
+" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
+" ---------------------------------------------------------------------
13 after/syntax/python.vim
@@ -0,0 +1,13 @@
+" Vim syntax file
+" FileType: python
+" Author: lilydjwg
+" Last Change: 2009年8月30日
+
+" CGI 中很多 HTML 字符串的
+if expand('%:p') =~ 'www'
+ unlet b:current_syntax
+ syntax include @Html syntax/html.vim
+ syntax region pythonHtmlString matchgroup=Normal start="r'''<\@=" end="'''" contains=@Html
+ let b:current_syntax = 'python'
+endif
+
25 after/syntax/sh.vim
@@ -0,0 +1,25 @@
+" Vim syntax file
+" FileType: shell script
+" Author: lilydjwg <lilydjwg@gmail.com>
+" Last Change: 2010年2月10日
+
+" ---------------------------------------------------------------------
+" Don't mark as Error:
+syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" end=")" contains=@shCommandSubList
+
+" 允许 sh 中出现原本在 bash 中这样的 ${0%\/*}
+syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOp
+syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList
+syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList
+syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern
+syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern
+syn match shDerefEscape contained '\%(\\\\\)*\\.'
+syn region shDerefOp contained start=":[$[:alnum:]_]"me=e-1 end=":"me=e-1 end="}"me=e-1 contains=@shCommandSubList nextgroup=shDerefPOL
+syn match shDerefPOL contained ":[^}]\+" contains=@shCommandSubList
+syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft
+syn region shDerefPPSleft contained start='.' skip=@\%(\\\)\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
+syn region shDerefPPSright contained start='.' end='\ze}' contains=@shCommandSubList
+" ---------------------------------------------------------------------
+" Vim Modeline:
+" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
+" ---------------------------------------------------------------------
11 after/syntax/tex.vim
@@ -0,0 +1,11 @@
+" Vim syntax file
+" FileType: TeX
+" Author: lilydjwg
+" Last Change: 2009年8月14日
+
+syntax case match
+
+" 在 MediaWiki 中,如果含有 \section 片断,不能让它吃掉 </code>
+if &ft == 'wiki'
+ syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)\|\ze</code>' fold contains=@texFoldGroup,@texSectionGroup,@Spell
+endif
7 after/syntax/vim.vim
@@ -0,0 +1,7 @@
+" Vim syntax file
+" Language: Vim 7.2 script
+" Last Change: 2009年8月10日
+" Maintainer: lilydjwg
+
+" python 应该可以写在函数等之中
+syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript containedin=ALL
1,036 autoload/Align.vim
@@ -0,0 +1,1036 @@
+" Align: tool to align multiple fields based on one or more separators
+" Author: Charles E. Campbell, Jr.
+" Date: Mar 03, 2009
+" Version: 35
+" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim
+" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
+" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
+" Permission is hereby granted to use and distribute this code,
+" with or without modifications, provided that this copyright
+" notice is copied with it. Like anything else that's free,
+" Align.vim is provided *as is* and comes with no warranty
+" of any kind, either expressed or implied. By using this
+" plugin, you agree that in no event will the copyright
+" holder be liable for any damages resulting from the use
+" of this software.
+"
+" Romans 1:16,17a : For I am not ashamed of the gospel of Christ, for it is {{{1
+" the power of God for salvation for everyone who believes; for the Jew first,
+" and also for the Greek. For in it is revealed God's righteousness from
+" faith to faith.
+
+" ---------------------------------------------------------------------
+" Load Once: {{{1
+if exists("g:loaded_Align") || &cp
+ finish
+endif
+let g:loaded_Align = "v35"
+if v:version < 700
+ echohl WarningMsg
+ echo "***warning*** this version of Align needs vim 7.0"
+ echohl Normal
+ finish
+endif
+let s:keepcpo= &cpo
+set cpo&vim
+"DechoTabOn
+
+" ---------------------------------------------------------------------
+" Debugging Support: {{{1
+"if !exists("g:loaded_Decho") | runtime plugin/Decho.vim | endif
+
+" ---------------------------------------------------------------------
+" Options: {{{1
+if !exists("g:Align_xstrlen")
+ if &enc == "latin1" || $LANG == "en_US.UTF-8" || !has("multi_byte")
+ let g:Align_xstrlen= 0
+ else
+ let g:Align_xstrlen= 1
+ endif
+endif
+
+" ---------------------------------------------------------------------
+" Align#AlignCtrl: enter alignment patterns here {{{1
+"
+" Styles = all alignment-break patterns are equivalent
+" C cycle through alignment-break pattern(s)
+" l left-justified alignment
+" r right-justified alignment
+" c center alignment
+" - skip separator, treat as part of field
+" : treat rest of line as field
+" + repeat previous [lrc] style
+" < left justify separators
+" > right justify separators
+" | center separators
+"
+" Builds = s:AlignPat s:AlignCtrl s:AlignPatQty
+" C s:AlignPat s:AlignCtrl s:AlignPatQty
+" p s:AlignPrePad
+" P s:AlignPostPad
+" w s:AlignLeadKeep
+" W s:AlignLeadKeep
+" I s:AlignLeadKeep
+" l s:AlignStyle
+" r s:AlignStyle
+" - s:AlignStyle
+" + s:AlignStyle
+" : s:AlignStyle
+" c s:AlignStyle
+" g s:AlignGPat
+" v s:AlignVPat
+" < s:AlignSep
+" > s:AlignSep
+" | s:AlignSep
+fun! Align#AlignCtrl(...)
+
+" call Dfunc("AlignCtrl(...) a:0=".a:0)
+
+ " save options that will be changed
+ let keep_search = @/
+ let keep_ic = &ic
+
+ " turn ignorecase off
+ set noic
+
+ " clear visual mode so that old visual-mode selections don't
+ " get applied to new invocations of Align().
+ if v:version < 602
+ if !exists("s:Align_gavemsg")
+ let s:Align_gavemsg= 1
+ echomsg "Align needs at least Vim version 6.2 to clear visual-mode selection"
+ endif
+ elseif exists("s:dovisclear")
+" call Decho("clearing visual mode a:0=".a:0." a:1<".a:1.">")
+ let clearvmode= visualmode(1)
+ endif
+
+ " set up a list akin to an argument list
+ if a:0 > 0
+ let A= s:QArgSplitter(a:1)
+ else
+ let A=[0]
+ endif
+
+ if A[0] > 0
+ let style = A[1]
+
+ " Check for bad separator patterns (zero-length matches)
+ " (but zero-length patterns for g/v is ok)
+ if style !~# '[gv]'
+ let ipat= 2
+ while ipat <= A[0]
+ if "" =~ A[ipat]
+ echoerr "AlignCtrl: separator<".A[ipat]."> matches zero-length string"
+ let &ic= keep_ic
+" call Dret("AlignCtrl")
+ return
+ endif
+ let ipat= ipat + 1
+ endwhile
+ endif
+ endif
+
+" call Decho("AlignCtrl() A[0]=".A[0])
+ if !exists("s:AlignStyle")
+ let s:AlignStyle= "l"
+ endif
+ if !exists("s:AlignPrePad")
+ let s:AlignPrePad= 0
+ endif
+ if !exists("s:AlignPostPad")
+ let s:AlignPostPad= 0
+ endif
+ if !exists("s:AlignLeadKeep")
+ let s:AlignLeadKeep= 'w'
+ endif
+
+ if A[0] == 0
+ " ----------------------
+ " List current selection
+ " ----------------------
+ if !exists("s:AlignPatQty")
+ let s:AlignPatQty= 0
+ endif
+ echo "AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep
+" call Decho("AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep)
+ if exists("s:AlignGPat") && !exists("s:AlignVPat")
+ echo "AlignGPat<".s:AlignGPat.">"
+ elseif !exists("s:AlignGPat") && exists("s:AlignVPat")
+ echo "AlignVPat<".s:AlignVPat.">"
+ elseif exists("s:AlignGPat") && exists("s:AlignVPat")
+ echo "AlignGPat<".s:AlignGPat."> AlignVPat<".s:AlignVPat.">"
+ endif
+ let ipat= 1
+ while ipat <= s:AlignPatQty
+ echo "Pat".ipat."<".s:AlignPat_{ipat}.">"
+" call Decho("Pat".ipat."<".s:AlignPat_{ipat}.">")
+ let ipat= ipat + 1
+ endwhile
+
+ else
+ " ----------------------------------
+ " Process alignment control settings
+ " ----------------------------------
+" call Decho("process the alignctrl settings")
+" call Decho("style<".style.">")
+
+ if style ==? "default"
+ " Default: preserve initial leading whitespace, left-justified,
+ " alignment on '=', one space padding on both sides
+ if exists("s:AlignCtrlStackQty")
+ " clear AlignCtrl stack
+ while s:AlignCtrlStackQty > 0
+ call Align#AlignPop()
+ endwhile
+ unlet s:AlignCtrlStackQty
+ endif
+ " Set AlignCtrl to its default value
+ call Align#AlignCtrl("Ilp1P1=<",'=')
+ call Align#AlignCtrl("g")
+ call Align#AlignCtrl("v")
+ let s:dovisclear = 1
+ let &ic = keep_ic
+ let @/ = keep_search
+" call Dret("AlignCtrl")
+ return
+ endif
+
+ if style =~# 'm'
+ " map support: Do an AlignPush now and the next call to Align()
+ " will do an AlignPop at exit
+" call Decho("style case m: do AlignPush")
+ call Align#AlignPush()
+ let s:DoAlignPop= 1
+ endif
+
+ " = : record a list of alignment patterns that are equivalent
+ if style =~# "="
+" call Decho("style case =: record list of equiv alignment patterns")
+ let s:AlignCtrl = '='
+ if A[0] >= 2
+ let s:AlignPatQty= 1
+ let s:AlignPat_1 = A[2]
+ let ipat = 3
+ while ipat <= A[0]
+ let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat]
+ let ipat = ipat + 1
+ endwhile
+ let s:AlignPat_1= '\('.s:AlignPat_1.'\)'
+" call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">")
+ endif
+
+ "c : cycle through alignment pattern(s)
+ elseif style =~# 'C'
+" call Decho("style case C: cycle through alignment pattern(s)")
+ let s:AlignCtrl = 'C'
+ if A[0] >= 2
+ let s:AlignPatQty= A[0] - 1
+ let ipat = 1
+ while ipat < A[0]
+ let s:AlignPat_{ipat}= A[ipat+1]
+" call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">")
+ let ipat= ipat + 1
+ endwhile
+ endif
+ endif
+
+ if style =~# 'p'
+ let s:AlignPrePad= substitute(style,'^.*p\(\d\+\).*$','\1','')
+" call Decho("style case p".s:AlignPrePad.": pre-separator padding")
+ if s:AlignPrePad == ""
+ echoerr "AlignCtrl: 'p' needs to be followed by a numeric argument'
+ let @/ = keep_search
+ let &ic= keep_ic
+" call Dret("AlignCtrl")
+ return
+ endif
+ endif
+
+ if style =~# 'P'
+ let s:AlignPostPad= substitute(style,'^.*P\(\d\+\).*$','\1','')
+" call Decho("style case P".s:AlignPostPad.": post-separator padding")
+ if s:AlignPostPad == ""
+ echoerr "AlignCtrl: 'P' needs to be followed by a numeric argument'
+ let @/ = keep_search
+ let &ic= keep_ic
+" call Dret("AlignCtrl")
+ return
+ endif
+ endif
+
+ if style =~# 'w'
+" call Decho("style case w: ignore leading whitespace")
+ let s:AlignLeadKeep= 'w'
+ elseif style =~# 'W'
+" call Decho("style case w: keep leading whitespace")
+ let s:AlignLeadKeep= 'W'
+ elseif style =~# 'I'
+" call Decho("style case w: retain initial leading whitespace")
+ let s:AlignLeadKeep= 'I'
+ endif
+
+ if style =~# 'g'
+ " first list item is a "g" selector pattern
+" call Decho("style case g: global selector pattern")
+ if A[0] < 2
+ if exists("s:AlignGPat")
+ unlet s:AlignGPat
+" call Decho("unlet s:AlignGPat")
+ endif
+ else
+ let s:AlignGPat= A[2]
+" call Decho("s:AlignGPat<".s:AlignGPat.">")
+ endif
+ elseif style =~# 'v'
+ " first list item is a "v" selector pattern
+" call Decho("style case v: global selector anti-pattern")
+ if A[0] < 2
+ if exists("s:AlignVPat")
+ unlet s:AlignVPat
+" call Decho("unlet s:AlignVPat")
+ endif
+ else
+ let s:AlignVPat= A[2]
+" call Decho("s:AlignVPat<".s:AlignVPat.">")
+ endif
+ endif
+
+ "[-lrc+:] : set up s:AlignStyle
+ if style =~# '[-lrc+:]'
+" call Decho("style case [-lrc+:]: field justification")
+ let s:AlignStyle= substitute(style,'[^-lrc:+]','','g')
+" call Decho("AlignStyle<".s:AlignStyle.">")
+ endif
+
+ "[<>|] : set up s:AlignSep
+ if style =~# '[<>|]'
+" call Decho("style case [-lrc+:]: separator justification")
+ let s:AlignSep= substitute(style,'[^<>|]','','g')
+" call Decho("AlignSep ".s:AlignSep)
+ endif
+ endif
+
+ " sanity
+ if !exists("s:AlignCtrl")
+ let s:AlignCtrl= '='
+ endif
+
+ " restore search and options
+ let @/ = keep_search
+ let &ic= keep_ic
+
+" call Dret("AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle)
+ return s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle
+endfun
+
+" ---------------------------------------------------------------------
+" s:MakeSpace: returns a string with spacecnt blanks {{{1
+fun! s:MakeSpace(spacecnt)
+" call Dfunc("MakeSpace(spacecnt=".a:spacecnt.")")
+ let str = ""
+ let spacecnt = a:spacecnt
+ while spacecnt > 0
+ let str = str . " "
+ let spacecnt = spacecnt - 1
+ endwhile
+" call Dret("MakeSpace <".str.">")
+ return str
+endfun
+
+" ---------------------------------------------------------------------
+" Align#Align: align selected text based on alignment pattern(s) {{{1
+fun! Align#Align(hasctrl,...) range
+" call Dfunc("Align#Align(hasctrl=".a:hasctrl.",...) a:0=".a:0)
+
+ " sanity checks
+ if string(a:hasctrl) != "0" && string(a:hasctrl) != "1"
+ echohl Error|echo 'usage: Align#Align(hasctrl<'.a:hasctrl.'> (should be 0 or 1),"separator(s)" (you have '.a:0.') )'|echohl None
+" call Dret("Align#Align")
+ return
+ endif
+ if exists("s:AlignStyle") && s:AlignStyle == ":"
+ echohl Error |echo '(Align#Align) your AlignStyle is ":", which implies "do-no-alignment"!'|echohl None
+" call Dret("Align#Align")
+ return
+ endif
+
+ " set up a list akin to an argument list
+ if a:0 > 0
+ let A= s:QArgSplitter(a:1)
+ else
+ let A=[0]
+ endif
+
+ " if :Align! was used, then the first argument is (should be!) an AlignCtrl string
+ " Note that any alignment control set this way will be temporary.
+ let hasctrl= a:hasctrl
+" call Decho("hasctrl=".hasctrl)
+ if a:hasctrl && A[0] >= 1
+" call Decho("Align! : using A[1]<".A[1]."> for AlignCtrl")
+ if A[1] =~ '[gv]'
+ let hasctrl= hasctrl + 1
+ call Align#AlignCtrl('m')
+ call Align#AlignCtrl(A[1],A[2])
+" call Decho("Align! : also using A[2]<".A[2]."> for AlignCtrl")
+ elseif A[1] !~ 'm'
+ call Align#AlignCtrl(A[1]."m")
+ else
+ call Align#AlignCtrl(A[1])
+ endif
+ endif
+
+ " Check for bad separator patterns (zero-length matches)
+ let ipat= 1 + hasctrl
+ while ipat <= A[0]
+ if "" =~ A[ipat]
+ echoerr "Align: separator<".A[ipat]."> matches zero-length string"
+" call Dret("Align#Align")
+ return
+ endif
+ let ipat= ipat + 1
+ endwhile
+
+ " record current search pattern for subsequent restoration
+ let keep_search= @/
+ let keep_ic = &ic
+ let keep_report= &report
+ set noic report=10000
+
+ if A[0] > hasctrl
+ " Align will accept a list of separator regexps
+" call Decho("A[0]=".A[0].": accepting list of separator regexp")
+
+ if s:AlignCtrl =~# "="
+ "= : consider all separators to be equivalent
+" call Decho("AlignCtrl: record list of equivalent alignment patterns")
+ let s:AlignCtrl = '='
+ let s:AlignPat_1 = A[1 + hasctrl]
+ let s:AlignPatQty= 1
+ let ipat = 2 + hasctrl
+ while ipat <= A[0]
+ let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat]
+ let ipat = ipat + 1
+ endwhile
+ let s:AlignPat_1= '\('.s:AlignPat_1.'\)'
+" call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">")
+
+ elseif s:AlignCtrl =~# 'C'
+ "c : cycle through alignment pattern(s)
+" call Decho("AlignCtrl: cycle through alignment pattern(s)")
+ let s:AlignCtrl = 'C'
+ let s:AlignPatQty= A[0] - hasctrl
+ let ipat = 1
+ while ipat <= s:AlignPatQty
+ let s:AlignPat_{ipat}= A[(ipat + hasctrl)]
+" call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">")
+ let ipat= ipat + 1
+ endwhile
+ endif
+ endif
+
+ " Initialize so that begline<endline and begcol<endcol.
+ " Ragged right: check if the column associated with '< or '>
+ " is greater than the line's string length -> ragged right.
+ " Have to be careful about visualmode() -- it returns the last visual
+ " mode used whether or not it was used currently.
+ let begcol = virtcol("'<")-1
+ let endcol = virtcol("'>")-1
+ if begcol > endcol
+ let begcol = virtcol("'>")-1
+ let endcol = virtcol("'<")-1
+ endif
+" call Decho("begcol=".begcol." endcol=".endcol)
+ let begline = a:firstline
+ let endline = a:lastline
+ if begline > endline
+ let begline = a:lastline
+ let endline = a:firstline
+ endif
+" call Decho("begline=".begline." endline=".endline)
+ let fieldcnt = 0
+ if (begline == line("'>") && endline == line("'<")) || (begline == line("'<") && endline == line("'>"))
+ let vmode= visualmode()
+" call Decho("vmode=".vmode)
+ if vmode == "\<c-v>"
+ if exists("g:Align_xstrlen") && g:Align_xstrlen
+ let ragged = ( col("'>") > s:Strlen(getline("'>")) || col("'<") > s:Strlen(getline("'<")) )
+ else
+ let ragged = ( col("'>") > strlen(getline("'>")) || col("'<") > strlen(getline("'<")) )
+ endif
+ else
+ let ragged= 1
+ endif
+ else
+ let ragged= 1
+ endif
+ if ragged
+ let begcol= 0
+ endif
+" call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">")
+
+ " Keep user options
+ let etkeep = &l:et
+ let pastekeep= &l:paste
+ setlocal et paste
+
+ " convert selected range of lines to use spaces instead of tabs
+ " but if first line's initial white spaces are to be retained
+ " then use 'em
+ if begcol <= 0 && s:AlignLeadKeep == 'I'
+ " retain first leading whitespace for all subsequent lines
+ let bgntxt= substitute(getline(begline),'^\(\s*\).\{-}$','\1','')
+" call Decho("retaining 1st leading whitespace: bgntxt<".bgntxt.">")
+ set noet
+ endif
+ exe begline.",".endline."ret"
+
+ " Execute two passes
+ " First pass: collect alignment data (max field sizes)
+ " Second pass: perform alignment
+ let pass= 1
+ while pass <= 2
+" call Decho(" ")
+" call Decho("---- Pass ".pass.": ----")
+
+ let line= begline
+ while line <= endline
+ " Process each line
+ let txt = getline(line)
+" call Decho(" ")
+" call Decho("Pass".pass.": Line ".line." <".txt.">")
+
+ " AlignGPat support: allows a selector pattern (akin to g/selector/cmd )
+ if exists("s:AlignGPat")
+" call Decho("Pass".pass.": AlignGPat<".s:AlignGPat.">")
+ if match(txt,s:AlignGPat) == -1
+" call Decho("Pass".pass.": skipping")
+ let line= line + 1
+ continue
+ endif
+ endif
+
+ " AlignVPat support: allows a selector pattern (akin to v/selector/cmd )
+ if exists("s:AlignVPat")
+" call Decho("Pass".pass.": AlignVPat<".s:AlignVPat.">")
+ if match(txt,s:AlignVPat) != -1
+" call Decho("Pass".pass.": skipping")
+ let line= line + 1
+ continue
+ endif
+ endif
+
+ " Always skip blank lines
+ if match(txt,'^\s*$') != -1
+" call Decho("Pass".pass.": skipping")
+ let line= line + 1
+ continue
+ endif
+
+ " Extract visual-block selected text (init bgntxt, endtxt)
+ if exists("g:Align_xstrlen") && g:Align_xstrlen
+ let txtlen= s:Strlen(txt)
+ else
+ let txtlen= strlen(txt)
+ endif
+ if begcol > 0
+ " Record text to left of selected area
+ let bgntxt= strpart(txt,0,begcol)
+" call Decho("Pass".pass.": record text to left: bgntxt<".bgntxt.">")
+ elseif s:AlignLeadKeep == 'W'
+ let bgntxt= substitute(txt,'^\(\s*\).\{-}$','\1','')
+" call Decho("Pass".pass.": retaining all leading ws: bgntxt<".bgntxt.">")
+ elseif s:AlignLeadKeep == 'w' || !exists("bgntxt")
+ " No beginning text
+ let bgntxt= ""
+" call Decho("Pass".pass.": no beginning text")
+ endif
+ if ragged
+ let endtxt= ""
+ else
+ " Elide any text lying outside selected columnar region
+ let endtxt= strpart(txt,endcol+1,txtlen-endcol)
+ let txt = strpart(txt,begcol,endcol-begcol+1)
+ endif
+" call Decho(" ")
+" call Decho("Pass".pass.": bgntxt<".bgntxt.">")
+" call Decho("Pass".pass.": txt<". txt .">")
+" call Decho("Pass".pass.": endtxt<".endtxt.">")
+ if !exists("s:AlignPat_{1}")
+ echohl Error|echo "no separators specified!"|echohl None
+" call Dret("Align#Align")
+ return
+ endif
+
+ " Initialize for both passes
+ let seppat = s:AlignPat_{1}
+ let ifield = 1
+ let ipat = 1
+ let bgnfield = 0
+ let endfield = 0
+ let alignstyle = s:AlignStyle
+ let doend = 1
+ let newtxt = ""
+ let alignprepad = s:AlignPrePad
+ let alignpostpad= s:AlignPostPad
+ let alignsep = s:AlignSep
+ let alignophold = " "
+ let alignop = "l"
+" call Decho("Pass".pass.": initial alignstyle<".alignstyle."> seppat<".seppat.">")
+
+ " Process each field on the line
+ while doend > 0
+
+ " C-style: cycle through pattern(s)
+ if s:AlignCtrl == 'C' && doend == 1
+ let seppat = s:AlignPat_{ipat}
+" call Decho("Pass".pass.": processing field: AlignCtrl=".s:AlignCtrl." ipat=".ipat." seppat<".seppat.">")
+ let ipat = ipat + 1
+ if ipat > s:AlignPatQty
+ let ipat = 1
+ endif
+ endif
+
+ " cyclic alignment/justification operator handling
+ let alignophold = alignop
+ let alignop = strpart(alignstyle,0,1)
+ if alignop == '+' || doend == 2
+ let alignop= alignophold
+ else
+ let alignstyle = strpart(alignstyle,1).strpart(alignstyle,0,1)
+ let alignopnxt = strpart(alignstyle,0,1)
+ if alignop == ':'
+ let seppat = '$'
+ let doend = 2
+" call Decho("Pass".pass.": alignop<:> case: setting seppat<$> doend==2")
+ endif
+ endif
+
+ " cylic separator alignment specification handling
+ let alignsepop= strpart(alignsep,0,1)
+ let alignsep = strpart(alignsep,1).alignsepop
+
+ " mark end-of-field and the subsequent end-of-separator.
+ " Extend field if alignop is '-'
+ let endfield = match(txt,seppat,bgnfield)
+ let sepfield = matchend(txt,seppat,bgnfield)
+ let skipfield= sepfield
+" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield)
+ while alignop == '-' && endfield != -1
+ let endfield = match(txt,seppat,skipfield)
+ let sepfield = matchend(txt,seppat,skipfield)
+ let skipfield = sepfield
+ let alignop = strpart(alignstyle,0,1)
+ let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1)
+" call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">")
+ endwhile
+ let seplen= sepfield - endfield
+" call Decho("Pass".pass.": seplen=[sepfield=".sepfield."] - [endfield=".endfield."]=".seplen)
+
+ if endfield != -1
+ if pass == 1
+ " ---------------------------------------------------------------------
+ " Pass 1: Update FieldSize to max
+" call Decho("Pass".pass.": before lead/trail remove: field<".strpart(txt,bgnfield,endfield-bgnfield).">")
+ let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','')
+ if s:AlignLeadKeep == 'W'
+ let field = bgntxt.field
+ let bgntxt= ""
+ endif
+ if exists("g:Align_xstrlen") && g:Align_xstrlen
+ let fieldlen = s:Strlen(field)
+ else
+ let fieldlen = strlen(field)
+ endif
+ let sFieldSize = "FieldSize_".ifield
+ if !exists(sFieldSize)
+ let FieldSize_{ifield}= fieldlen
+" call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">")
+ elseif fieldlen > FieldSize_{ifield}
+ let FieldSize_{ifield}= fieldlen
+" call Decho("Pass".pass.": oset FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">")
+ endif
+ let sSepSize= "SepSize_".ifield
+ if !exists(sSepSize)
+ let SepSize_{ifield}= seplen
+" call Decho(" set SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">")
+ elseif seplen > SepSize_{ifield}
+ let SepSize_{ifield}= seplen
+" call Decho("Pass".pass.": oset SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">")
+ endif
+
+ else
+ " ---------------------------------------------------------------------
+ " Pass 2: Perform Alignment
+ let prepad = strpart(alignprepad,0,1)
+ let postpad = strpart(alignpostpad,0,1)
+ let alignprepad = strpart(alignprepad,1).strpart(alignprepad,0,1)
+ let alignpostpad = strpart(alignpostpad,1).strpart(alignpostpad,0,1)
+ let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','')
+ if s:AlignLeadKeep == 'W'
+ let field = bgntxt.field
+ let bgntxt= ""
+ endif
+ if doend == 2
+ let prepad = 0
+ let postpad= 0
+ endif
+ if exists("g:Align_xstrlen") && g:Align_xstrlen
+ let fieldlen = s:Strlen(field)
+ else
+ let fieldlen = strlen(field)
+ endif
+ let sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad)
+ if seplen < SepSize_{ifield}
+ if alignsepop == "<"
+ " left-justify separators
+ let sep = sep.s:MakeSpace(SepSize_{ifield}-seplen)
+ elseif alignsepop == ">"
+ " right-justify separators
+ let sep = s:MakeSpace(SepSize_{ifield}-seplen).sep
+ else
+ " center-justify separators
+ let sepleft = (SepSize_{ifield} - seplen)/2
+ let sepright = SepSize_{ifield} - seplen - sepleft
+ let sep = s:MakeSpace(sepleft).sep.s:MakeSpace(sepright)
+ endif
+ endif
+ let spaces = FieldSize_{ifield} - fieldlen
+" call Decho("Pass".pass.": Field #".ifield."<".field."> spaces=".spaces." be[".bgnfield.",".endfield."] pad=".prepad.','.postpad." FS_".ifield."<".FieldSize_{ifield}."> sep<".sep."> ragged=".ragged." doend=".doend." alignop<".alignop.">")
+
+ " Perform alignment according to alignment style justification
+ if spaces > 0
+ if alignop == 'c'
+ " center the field
+ let spaceleft = spaces/2
+ let spaceright= FieldSize_{ifield} - spaceleft - fieldlen
+ let newtxt = newtxt.s:MakeSpace(spaceleft).field.s:MakeSpace(spaceright).sep
+ elseif alignop == 'r'
+ " right justify the field
+ let newtxt= newtxt.s:MakeSpace(spaces).field.sep
+ elseif ragged && doend == 2
+ " left justify rightmost field (no trailing blanks needed)
+ let newtxt= newtxt.field
+ else
+ " left justfiy the field
+ let newtxt= newtxt.field.s:MakeSpace(spaces).sep
+ endif
+ elseif ragged && doend == 2
+ " field at maximum field size and no trailing blanks needed
+ let newtxt= newtxt.field
+ else
+ " field is at maximum field size already
+ let newtxt= newtxt.field.sep
+ endif
+" call Decho("Pass".pass.": newtxt<".newtxt.">")
+ endif " pass 1/2
+
+ " bgnfield indexes to end of separator at right of current field
+ " Update field counter
+ let bgnfield= sepfield
+ let ifield = ifield + 1
+ if doend == 2
+ let doend= 0
+ endif
+ " handle end-of-text as end-of-field
+ elseif doend == 1
+ let seppat = '$'
+ let doend = 2
+ else
+ let doend = 0
+ endif " endfield != -1
+ endwhile " doend loop (as well as regularly separated fields)
+
+ if pass == 2
+ " Write altered line to buffer
+" call Decho("Pass".pass.": bgntxt<".bgntxt."> line=".line)
+" call Decho("Pass".pass.": newtxt<".newtxt.">")
+" call Decho("Pass".pass.": endtxt<".endtxt.">")
+ call setline(line,bgntxt.newtxt.endtxt)
+ endif
+
+ let line = line + 1
+ endwhile " line loop
+
+ let pass= pass + 1
+ endwhile " pass loop
+" call Decho("end of two pass loop")
+
+ " Restore user options
+ let &l:et = etkeep
+ let &l:paste = pastekeep
+
+ if exists("s:DoAlignPop")
+ " AlignCtrl Map support
+ call Align#AlignPop()
+ unlet s:DoAlignPop
+ endif
+
+ " restore current search pattern
+ let @/ = keep_search
+ let &ic = keep_ic
+ let &report = keep_report
+
+" call Dret("Align#Align")
+ return
+endfun
+
+" ---------------------------------------------------------------------
+" Align#AlignPush: this command/function pushes an alignment control string onto a stack {{{1
+fun! Align#AlignPush()
+" call Dfunc("AlignPush()")
+
+ " initialize the stack
+ if !exists("s:AlignCtrlStackQty")
+ let s:AlignCtrlStackQty= 1
+ else
+ let s:AlignCtrlStackQty= s:AlignCtrlStackQty + 1
+ endif
+
+ " construct an AlignCtrlStack entry
+ if !exists("s:AlignSep")
+ let s:AlignSep= ''
+ endif
+ let s:AlignCtrlStack_{s:AlignCtrlStackQty}= s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle.s:AlignSep
+" call Decho("AlignPush: AlignCtrlStack_".s:AlignCtrlStackQty."<".s:AlignCtrlStack_{s:AlignCtrlStackQty}.">")
+
+ " push [GV] patterns onto their own stack
+ if exists("s:AlignGPat")
+ let s:AlignGPat_{s:AlignCtrlStackQty}= s:AlignGPat
+ else
+ let s:AlignGPat_{s:AlignCtrlStackQty}= ""
+ endif
+ if exists("s:AlignVPat")
+ let s:AlignVPat_{s:AlignCtrlStackQty}= s:AlignVPat
+ else
+ let s:AlignVPat_{s:AlignCtrlStackQty}= ""
+ endif
+
+" call Dret("AlignPush")
+endfun
+
+" ---------------------------------------------------------------------
+" Align#AlignPop: this command/function pops an alignment pattern from a stack {{{1
+" and into the AlignCtrl variables.
+fun! Align#AlignPop()
+" call Dfunc("Align#AlignPop()")
+
+ " sanity checks
+ if !exists("s:AlignCtrlStackQty")
+ echoerr "AlignPush needs to be used prior to AlignPop"
+" call Dret("Align#AlignPop <> : AlignPush needs to have been called first")
+ return ""
+ endif
+ if s:AlignCtrlStackQty <= 0
+ unlet s:AlignCtrlStackQty
+ echoerr "AlignPush needs to be used prior to AlignPop"
+" call Dret("Align#AlignPop <> : AlignPop needs to have been called first")
+ return ""
+ endif
+
+ " pop top of AlignCtrlStack and pass value to AlignCtrl
+ let retval=s:AlignCtrlStack_{s:AlignCtrlStackQty}
+ unlet s:AlignCtrlStack_{s:AlignCtrlStackQty}
+ call Align#AlignCtrl(retval)
+
+ " pop G pattern stack
+ if s:AlignGPat_{s:AlignCtrlStackQty} != ""
+ call Align#AlignCtrl('g',s:AlignGPat_{s:AlignCtrlStackQty})
+ else
+ call Align#AlignCtrl('g')
+ endif
+ unlet s:AlignGPat_{s:AlignCtrlStackQty}
+
+ " pop V pattern stack
+ if s:AlignVPat_{s:AlignCtrlStackQty} != ""
+ call Align#AlignCtrl('v',s:AlignVPat_{s:AlignCtrlStackQty})
+ else
+ call Align#AlignCtrl('v')
+ endif
+
+ unlet s:AlignVPat_{s:AlignCtrlStackQty}
+ let s:AlignCtrlStackQty= s:AlignCtrlStackQty - 1
+
+" call Dret("Align#AlignPop <".retval."> : AlignCtrlStackQty=".s:AlignCtrlStackQty)
+ return retval
+endfun
+
+" ---------------------------------------------------------------------
+" Align#AlignReplaceQuotedSpaces: {{{1
+fun! Align#AlignReplaceQuotedSpaces()
+" call Dfunc("AlignReplaceQuotedSpaces()")
+
+ let l:line = getline(line("."))
+ if exists("g:Align_xstrlen") && g:Align_xstrlen
+ let l:linelen = s:Strlen(l:line)
+ else
+ let l:linelen = strlen(l:line)
+ endif
+ let l:startingPos = 0
+ let l:startQuotePos = 0
+ let l:endQuotePos = 0
+ let l:spacePos = 0
+ let l:quoteRe = '\\\@<!"'
+
+" "call Decho("in replace spaces. line=" . line('.'))
+ while (1)
+ let l:startQuotePos = match(l:line, l:quoteRe, l:startingPos)
+ if (l:startQuotePos < 0)
+" "call Decho("No more quotes to the end of line")
+ break
+ endif
+ let l:endQuotePos = match(l:line, l:quoteRe, l:startQuotePos + 1)
+ if (l:endQuotePos < 0)
+" "call Decho("Mismatched quotes")
+ break
+ endif
+ let l:spaceReplaceRe = '^.\{' . (l:startQuotePos + 1) . '}.\{-}\zs\s\ze.*.\{' . (linelen - l:endQuotePos) . '}$'
+" "call Decho('spaceReplaceRe="' . l:spaceReplaceRe . '"')
+ let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '')
+ while (l:newStr != l:line)
+" "call Decho('newstr="' . l:newStr . '"')
+ let l:line = l:newStr
+ let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '')
+ endwhile
+ let l:startingPos = l:endQuotePos + 1
+ endwhile
+ call setline(line('.'), l:line)
+
+" call Dret("AlignReplaceQuotedSpaces")
+endfun
+
+" ---------------------------------------------------------------------
+" s:QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{1
+" However, <q-args> doesn't split at all, so this function returns a list
+" of arguments which has been:
+" * split at whitespace
+" * unless inside "..."s. One may escape characters with a backslash inside double quotes.
+" along with a leading length-of-list.
+"
+" Examples: %Align "\"" will align on "s
+" %Align " " will align on spaces
+"
+" The resulting list: qarglist[0] corresponds to a:0
+" qarglist[i] corresponds to a:{i}
+fun! s:QArgSplitter(qarg)
+" call Dfunc("s:QArgSplitter(qarg<".a:qarg.">)")
+
+ if a:qarg =~ '".*"'
+ " handle "..." args, which may include whitespace
+ let qarglist = []
+ let args = a:qarg
+" call Decho("handle quoted arguments: args<".args.">")
+ while args != ""
+ let iarg = 0
+ let arglen = strlen(args)
+" call Decho("args[".iarg."]<".args[iarg]."> arglen=".arglen)
+ " find index to first not-escaped '"'
+ while args[iarg] != '"' && iarg < arglen
+ if args[iarg] == '\'
+ let args= strpart(args,1)
+ endif
+ let iarg= iarg + 1
+ endwhile
+" call Decho("args<".args."> iarg=".iarg." arglen=".arglen)
+
+ if iarg > 0
+ " handle left of quote or remaining section
+" call Decho("handle left of quote or remaining section")
+ if args[iarg] == '"'
+ let qarglist= qarglist + split(strpart(args,0,iarg-1))
+ else
+ let qarglist= qarglist + split(strpart(args,0,iarg))
+ endif
+ let args = strpart(args,iarg)
+ let arglen = strlen(args)
+
+ elseif iarg < arglen && args[0] == '"'
+ " handle "quoted" section
+" call Decho("handle quoted section")
+ let iarg= 1
+ while args[iarg] != '"' && iarg < arglen
+ if args[iarg] == '\'
+ let args= strpart(args,1)
+ endif
+ let iarg= iarg + 1
+ endwhile
+" call Decho("args<".args."> iarg=".iarg." arglen=".arglen)
+ if args[iarg] == '"'
+ call add(qarglist,strpart(args,1,iarg-1))
+ let args= strpart(args,iarg+1)
+ else
+ let qarglist = qarglist + split(args)
+ let args = ""
+ endif
+ endif
+" call Decho("qarglist".string(qarglist)." iarg=".iarg." args<".args.">")
+ endwhile
+
+ else
+ " split at all whitespace
+ let qarglist= split(a:qarg)
+ endif
+
+ let qarglistlen= len(qarglist)
+ let qarglist = insert(qarglist,qarglistlen)
+" call Dret("s:QArgSplitter ".string(qarglist))
+ return qarglist
+endfun
+
+" ---------------------------------------------------------------------
+" s:Strlen: this function returns the length of a string, even if its {{{1
+" using two-byte etc characters.
+" Currently, its only used if g:Align_xstrlen is set to a
+" nonzero value. Solution from Nicolai Weibull, vim docs
+" (:help strlen()), Tony Mechelynck, and my own invention.
+fun! s:Strlen(x)
+ " lilydjwg: vim7.3 有 strwidth 函数
+ if exists('*strwidth')
+ return strwidth(a:x)
+ endif
+
+" call Dfunc("s:Strlen(x<".a:x.">")
+ if g:Align_xstrlen == 1
+ " number of codepoints (Latin a + combining circumflex is two codepoints)
+ " (comment from TM, solution from NW)
+ let ret= strlen(substitute(a:x,'.','c','g'))
+
+ elseif g:Align_xstrlen == 2
+ " number of spacing codepoints (Latin a + combining circumflex is one spacing
+ " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.)
+ " (comment from TM, solution from TM)
+ let ret=strlen(substitute(a:x, '.\Z', 'x', 'g'))
+
+ elseif g:Align_xstrlen == 3
+ " virtual length (counting, for instance, tabs as anything between 1 and
+ " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately
+ " preceded by lam, one otherwise, etc.)
+ " (comment from TM, solution from me)
+ let modkeep= &l:mod
+ exe "norm! o\<esc>"
+ call setline(line("."),a:x)
+ let ret= virtcol("$") - 1
+ d
+ " lilydjwg: 这样才不会让光标乱跑
+ normal k
+ let &l:mod= modkeep
+
+ else
+ " at least give a decent default
+ ret= strlen(a:x)
+ endif
+" call Dret("s:Strlen ".ret)
+ return ret
+endfun
+
+" ---------------------------------------------------------------------
+" Set up default values: {{{1
+"call Decho("-- Begin AlignCtrl Initialization --")
+call Align#AlignCtrl("default")
+"call Decho("-- End AlignCtrl Initialization --")
+
+" ---------------------------------------------------------------------
+" Restore: {{{1
+let &cpo= s:keepcpo
+unlet s:keepcpo
+" vim: ts=4 fdm=marker
330 autoload/AlignMaps.vim
@@ -0,0 +1,330 @@
+" AlignMaps.vim : support functions for AlignMaps
+" Author: Charles E. Campbell, Jr.
+" Date: Mar 03, 2009
+" Version: 41
+" ---------------------------------------------------------------------
+" Load Once: {{{1
+if &cp || exists("g:loaded_AlignMaps")
+ finish
+endif
+let g:loaded_AlignMaps= "v41"
+let s:keepcpo = &cpo
+set cpo&vim
+
+" =====================================================================
+" Functions: {{{1
+
+" ---------------------------------------------------------------------
+" AlignMaps#WrapperStart: {{{2
+fun! AlignMaps#WrapperStart(vis) range
+" call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")")
+
+ if a:vis
+ norm! '<ma'>
+ endif
+
+ if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0
+" call Decho("wrapper initialization")
+ let s:alignmaps_wrapcnt = 1
+ let s:alignmaps_keepgd = &gdefault
+ let s:alignmaps_keepsearch = @/
+ let s:alignmaps_keepch = &ch
+ let s:alignmaps_keepmy = SaveMark("'y")
+ let s:alignmaps_keepmz = SaveMark("'z")
+ let s:alignmaps_posn = SaveWinPosn(0)
+ " set up fencepost blank lines
+ put =''
+ norm! mz'a
+ put! =''
+ ky
+ let s:alignmaps_zline = line("'z")
+ exe "'y,'zs/@/\177/ge"
+ else
+" call Decho("embedded wrapper")
+ let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1
+ norm! 'yjma'zk
+ endif
+
+ " change some settings to align-standard values
+ set nogd
+ set ch=2
+ AlignPush
+ norm! 'zk
+" call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#WrapperEnd: {{{2
+fun! AlignMaps#WrapperEnd() range
+" call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
+
+ " remove trailing white space introduced by whatever in the modification zone
+ 'y,'zs/ \+$//e
+
+ " restore AlignCtrl settings
+ AlignPop
+
+ let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1
+ if s:alignmaps_wrapcnt <= 0
+ " initial wrapper ending
+ exe "'y,'zs/\177/@/ge"
+
+ " if the 'z line hasn't moved, then go ahead and restore window position
+ let zstationary= s:alignmaps_zline == line("'z")
+
+ " remove fencepost blank lines.
+ " restore 'a
+ norm! 'yjmakdd'zdd
+
+ " restore original 'y, 'z, and window positioning
+ call RestoreMark(s:alignmaps_keepmy)
+ call RestoreMark(s:alignmaps_keepmz)
+ if zstationary > 0
+ call RestoreWinPosn(s:alignmaps_posn)
+" call Decho("restored window positioning")
+ endif
+
+ " restoration of options
+ let &gd= s:alignmaps_keepgd
+ let &ch= s:alignmaps_keepch
+ let @/ = s:alignmaps_keepsearch
+
+ " remove script variables
+ unlet s:alignmaps_keepch
+ unlet s:alignmaps_keepsearch
+ unlet s:alignmaps_keepmy
+ unlet s:alignmaps_keepmz
+ unlet s:alignmaps_keepgd
+ unlet s:alignmaps_posn
+ endif
+
+" call Dret("AlignMaps#WrapperEnd : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#StdAlign: some semi-standard align calls {{{2
+fun! AlignMaps#StdAlign(mode) range
+" call Dfunc("AlignMaps#StdAlign(mode=".a:mode.")")
+ if a:mode == 1
+ " align on @
+" call Decho("align on @")
+ AlignCtrl mIp1P1=l @
+ 'a,.Align
+ elseif a:mode == 2
+ " align on @, retaining all initial white space on each line
+" call Decho("align on @, retaining all initial white space on each line")
+ AlignCtrl mWp1P1=l @
+ 'a,.Align
+ elseif a:mode == 3
+ " like mode 2, but ignore /* */-style comments
+" call Decho("like mode 2, but ignore /* */-style comments")
+ AlignCtrl v ^\s*/[/*]
+ AlignCtrl mWp1P1=l @
+ 'a,.Align
+ else
+ echoerr "(AlignMaps) AlignMaps#StdAlign doesn't support mode#".a:mode
+ endif
+" call Dret("AlignMaps#StdAlign")
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#CharJoiner: joins lines which end in the given character (spaces {{{2
+" at end are ignored)
+fun! AlignMaps#CharJoiner(chr)
+" call Dfunc("AlignMaps#CharJoiner(chr=".a:chr.")")
+ let aline = line("'a")
+ let rep = line(".") - aline
+ while rep > 0
+ norm! 'a
+ while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0
+ " while = at end-of-line, delete it and join with next
+ norm! 'a$
+ j!
+ let rep = rep - 1
+ endwhile
+ " update rep(eat) count
+ let rep = rep - 1
+ if rep <= 0
+ " terminate loop if at end-of-block
+ break
+ endif
+ " prepare for next line
+ norm! jma
+ let aline = line("'a")
+ endwhile
+" call Dret("AlignMaps#CharJoiner")
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#Equals: supports \t= and \T= {{{2
+fun! AlignMaps#Equals() range
+" call Dfunc("AlignMaps#Equals()")
+ 'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e
+ 'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge
+ 'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge
+ 'a,'zs/\([!<>:]\)=/\=submatch(1)."\<Char-0x0f>"/ge
+ norm g'zk
+ AlignCtrl mIp1P1=l =
+ AlignCtrl g =
+ 'a,'z-1Align
+ 'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge
+ 'a,'z-1s/\( \+\);/;\1/ge
+ if &ft == "c" || &ft == "cpp"
+" call Decho("exception for ".&ft)
+ 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
+ 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
+ if exists("g:mapleader")
+ exe "norm 'zk"
+ call AlignMaps#StdAlign(1)
+ else
+ exe "norm 'zk"
+ call AlignMaps#StdAlign(1)
+ endif
+ 'y,'zs/^\(\s*\) @/\1/e
+ endif
+ 'a,'z-1s/\%x0f/=/ge
+ 'y,'zs/ @//eg
+" call Dret("AlignMaps#Equals")
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#Afnc: useful for splitting one-line function beginnings {{{2
+" into one line per argument format
+fun! AlignMaps#Afnc()
+" call Dfunc("AlignMaps#Afnc()")
+
+ " keep display quiet
+ let chkeep = &ch
+ let gdkeep = &gd
+ let vekeep = &ve
+ set ch=2 nogd ve=
+
+ " will use marks y,z ; save current values
+ let mykeep = SaveMark("'y")
+ let mzkeep = SaveMark("'z")
+
+ " Find beginning of function -- be careful to skip over comments
+ let cmmntid = synIDtrans(hlID("Comment"))
+ let stringid = synIDtrans(hlID("String"))
+ exe "norm! ]]"
+ while search(")","bW") != 0
+" call Decho("line=".line(".")." col=".col("."))
+ let parenid= synIDtrans(synID(line("."),col("."),1))
+ if parenid != cmmntid && parenid != stringid
+ break
+ endif
+ endwhile
+ norm! %my
+ s/(\s*\(\S\)/(\r \1/e
+ exe "norm! `y%"
+ s/)\s*\(\/[*/]\)/)\r\1/e
+ exe "norm! `y%mz"
+ 'y,'zs/\s\+$//e
+ 'y,'zs/^\s\+//e
+ 'y+1,'zs/^/ /
+
+ " insert newline after every comma only one parenthesis deep
+ sil! exe "norm! `y\<right>h"
+ let parens = 1
+ let cmmnt = 0
+ let cmmntline= -1
+ while parens >= 1
+" call Decho("parens=".parens." @a=".@a)
+ exe 'norm! ma "ay`a '
+ if @a == "("
+ let parens= parens + 1
+ elseif @a == ")"
+ let parens= parens - 1
+
+ " comment bypass: /* ... */ or //...
+ elseif cmmnt == 0 && @a == '/'
+ let cmmnt= 1
+ elseif cmmnt == 1
+ if @a == '/'
+ let cmmnt = 2 " //...
+ let cmmntline= line(".")
+ elseif @a == '*'
+ let cmmnt= 3 " /*...
+ else
+ let cmmnt= 0
+ endif
+ elseif cmmnt == 2 && line(".") != cmmntline
+ let cmmnt = 0
+ let cmmntline= -1
+ elseif cmmnt == 3 && @a == '*'
+ let cmmnt= 4
+ elseif cmmnt == 4
+ if @a == '/'
+ let cmmnt= 0 " ...*/
+ elseif @a != '*'
+ let cmmnt= 3
+ endif
+
+ elseif @a == "," && parens == 1 && cmmnt == 0
+ exe "norm! i\<CR>\<Esc>"
+ endif
+ endwhile
+ norm! `y%mz%
+ sil! 'y,'zg/^\s*$/d
+
+ " perform substitutes to mark fields for Align
+ sil! 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
+ sil! 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
+ sil! 'y+1,'zv/^\//s/\* \+/*/ge
+ sil! 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge
+ " func
+ " ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end->
+ sil! 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
+ sil! 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
+ sil! 'y+1,'z+1s%/[*/]%@&@%ge
+ sil! 'y+1,'z+1s%*/%@&%ge
+ AlignCtrl mIp0P0=l @
+ sil! 'y+1,'zAlign
+ sil! 'y,'zs%@\(/[*/]\)@%\t\1 %e
+ sil! 'y,'zs%@\*/% */%e
+ sil! 'y,'zs/@\([,)]\)/\1/
+ sil! 'y,'zs/@/ /
+ AlignCtrl mIlrp0P0= # @
+ sil! 'y+1,'zAlign
+ sil! 'y+1,'zs/#/ /
+ sil! 'y+1,'zs/@//
+ sil! 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
+
+ " Restore
+ call RestoreMark(mykeep)
+ call RestoreMark(mzkeep)
+ let &ch= chkeep
+ let &gd= gdkeep
+ let &ve= vekeep
+
+" call Dret("AlignMaps#Afnc")
+endfun
+
+" ---------------------------------------------------------------------
+" AlignMaps#FixMultiDec: converts a type arg,arg,arg; line to multiple lines {{{2
+fun! AlignMaps#FixMultiDec()
+" call Dfunc("AlignMaps#FixMultiDec()")
+
+ " save register x
+ let xkeep = @x
+ let curline = getline(".")
+" call Decho("curline<".curline.">")
+
+ " Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly)
+ let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9_ \t]*\)\s\+[(*]*\h.*$','\1','')
+" call Decho("@x<".@x.">")
+
+ " transform line
+ exe 's/,/;\r'.@x.' /ge'
+
+ "restore register x
+ let @x= xkeep
+
+" call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z"))
+endfun
+
+" ---------------------------------------------------------------------
+" Restore: {{{1
+let &cpo= s:keepcpo
+unlet s:keepcpo
+" vim: ts=4 fdm=marker
1,954 autoload/genutils.vim
@@ -0,0 +1,1954 @@
+" genutils.vim: Please see plugin/genutils.vim
+"
+" TODO:
+" - Vim7: redir can be used with a variable.
+" - fnamemodify() on Unix doesn't expand to full name if the filename doesn't
+" really exist on the filesystem.
+" - Is setting 'scrolloff' and 'sidescrolloff' to 0 required while moving the
+" cursor?
+" - http://www.vim.org/tips/tip.php?tip_id=1379
+"
+" - EscapeCommand() didn't work for David Fishburn.
+" - Save/RestoreWindowSettings doesn't work well.
+"
+" Vim7:
+" - Save/RestoreWindowSettings can use winsave/restview() functions.
+"
+
+" Make sure line-continuations won't cause any problem. This will be restored
+" at the end
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+let g:makeArgumentString = 'exec genutils#MakeArgumentString()'
+let g:makeArgumentList = 'exec genutils#MakeArgumentList()'
+
+let s:makeArgumentString = ''
+function! genutils#MakeArgumentString(...)
+ if s:makeArgumentString == ''
+ let s:makeArgumentString = genutils#ExtractFuncListing(s:SNR().
+ \ '_makeArgumentString', 0, 0)
+ endif
+ if a:0 > 0 && a:1 != ''
+ return substitute(s:makeArgumentString, '\<argumentString\>', a:1, 'g')
+ else
+ return s:makeArgumentString
+ endif
+endfunction
+
+
+let s:makeArgumentList = ''
+function! genutils#MakeArgumentList(...)
+ if s:makeArgumentList == ''
+ let s:makeArgumentList = genutils#ExtractFuncListing(s:SNR().
+ \ '_makeArgumentList', 0, 0)
+ endif
+ if a:0 > 0 && a:1 != ''
+ let mkArgLst = substitute(s:makeArgumentList, '\<argumentList\>', a:1, 'g')
+ if a:0 > 1 && a:2 != ''
+ let mkArgLst = substitute(s:makeArgumentList,
+ \ '\(\s\+let __argSeparator = \)[^'."\n".']*', "\\1'".a:2."'", '')
+ endif
+ return mkArgLst
+ else
+ return s:makeArgumentList
+ endif
+endfunction
+
+function! genutils#ExtractFuncListing(funcName, hLines, tLines)
+ let listing = genutils#GetVimCmdOutput('func '.a:funcName)
+ let listing = substitute(listing,
+ \ '^\%(\s\|'."\n".'\)*function '.a:funcName.'([^)]*)'."\n", '', '')
+ "let listing = substitute(listing, '\%(\s\|'."\n".'\)*endfunction\%(\s\|'."\n".'\)*$', '', '')
+ " Leave the last newline character.
+ let listing = substitute(listing, '\%('."\n".'\)\@<=\s*endfunction\s*$', '', '')
+ let listing = substitute(listing, '\(\%(^\|'."\n".'\)\s*\)\@<=\d\+',
+ \ '', 'g')
+ if a:hLines > 0
+ let listing = substitute(listing, '^\%([^'."\n".']*'."\n".'\)\{'.
+ \ a:hLines.'}', '', '')
+ endif
+ if a:tLines > 0
+ let listing = substitute(listing, '\%([^'."\n".']*'."\n".'\)\{'.
+ \ a:tLines.'}$', '', '')
+ endif
+ return listing
+endfunction
+
+function! genutils#CreateArgString(argList, sep, ...)
+ let sep = (a:0 == 0) ? a:sep : a:1 " This is no longer used.
+ " Matching multvals functionality means, we need to ignore the trailing
+ " separator.
+ let argList = split(substitute(a:argList, a:sep.'$', '', ''), a:sep, 1)
+ let argString = "'"
+ for nextArg in argList
+ " FIXME: I think this check is not required. If "'" is the separator, we
+ " don't expect to see them in the elements.
+ if a:sep != "'"
+ let nextArg = substitute(nextArg, "'", "' . \"'\" . '", 'g')
+ endif
+ let argString = argString . nextArg . "', '"
+ endfor
+ let argString = strpart(argString, 0, strlen(argString) - 3)
+ return argString
+endfunction
+
+" {{{
+function! s:_makeArgumentString()
+ let __argCounter = 1
+ let argumentString = ''
+ while __argCounter <= a:0
+ if type(a:{__argCounter})
+ let __nextArg = "'" .
+ \ substitute(a:{__argCounter}, "'", "' . \"'\" . '", "g") . "'"
+ else
+ let __nextArg = a:{__argCounter}
+ endif
+ let argumentString = argumentString. __nextArg .
+ \ ((__argCounter == a:0) ? '' : ', ')
+ let __argCounter = __argCounter + 1
+ endwhile
+ unlet __argCounter
+ if exists('__nextArg')
+ unlet __nextArg
+ endif
+endfunction
+
+function! s:_makeArgumentList()
+ let __argCounter = 1
+ let __argSeparator = ','
+ let argumentList = ''
+ while __argCounter <= a:0
+ let argumentList = argumentList . a:{__argCounter}
+ if __argCounter != a:0
+ let argumentList = argumentList . __argSeparator
+ endif
+ let __argCounter = __argCounter + 1
+ endwhile
+ unlet __argCounter
+ unlet __argSeparator
+endfunction
+" }}}
+
+
+function! genutils#DebugShowArgs(...)
+ let i = 0
+ let argString = ''
+ while i < a:0
+ let argString = argString . a:{i + 1} . ', '
+ let i = i + 1
+ endwhile
+ let argString = strpart(argString, 0, strlen(argString) - 2)
+ call input("Args: " . argString)
+endfunction
+
+" Window related functions {{{
+
+function! genutils#NumberOfWindows()
+ let i = 1
+ while winbufnr(i) != -1
+ let i = i+1
+ endwhile
+ return i - 1
+endfunction
+
+" Find the window number for the buffer passed.
+" The fileName argument is treated literally, unlike the bufnr() which treats
+" the argument as a regex pattern.
+function! genutils#FindWindowForBuffer(bufferName, checkUnlisted)
+ return bufwinnr(genutils#FindBufferForName(a:bufferName))
+endfunction
+
+function! genutils#FindBufferForName(fileName)
+ " The name could be having extra backslashes to protect certain chars (such
+ " as '#' and '%'), so first expand them.
+ return s:FindBufferForName(genutils#UnEscape(a:fileName, '#%'))
+endfunction
+
+function! s:FindBufferForName(fileName)
+ let fileName = genutils#Escape(a:fileName, '[?,{')
+ let _isf = &isfname
+ try
+ set isfname-=\
+ set isfname-=[
+ let i = bufnr('^' . fileName . '$')
+ finally
+ let &isfname = _isf
+ endtry
+ return i
+endfunction
+
+function! genutils#GetBufNameForAu(bufName)
+ let bufName = a:bufName
+ " Autocommands always require forward-slashes.
+ let bufName = substitute(bufName, "\\\\", '/', 'g')
+ let bufName = escape(bufName, '*?,{}[ ')
+ return bufName
+endfunction
+
+function! genutils#MoveCursorToWindow(winno)
+ if genutils#NumberOfWindows() != 1
+ execute a:winno . " wincmd w"
+ endif
+endfunction
+
+function! genutils#MoveCurLineToWinLine(n)
+ normal! zt
+ if a:n == 1
+ return
+ endif
+ let _wrap = &l:wrap
+ setl nowrap
+ let n = a:n
+ if n >= winheight(0)
+ let n = winheight(0)
+ endif
+ let n = n - 1
+ execute "normal! " . n . "\<C-Y>"
+ let &l:wrap = _wrap
+endfunction
+
+function! genutils#CloseWindow(win, force)
+ let _eventignore = &eventignore
+ try
+ set eventignore=all
+ call genutils#MarkActiveWindow()
+
+ let &eventignore = _eventignore
+ exec a:win 'wincmd w'
+ exec 'close'.(a:force ? '!' : '')
+ set eventignore=all