Jeremy Wright avatar Jeremy Wright committed 060ea84

Added better colors. Added tabluar plugin

Comments (0)

Files changed (9)

-source $VIMRUNTIME/vimrc_example.vim 
-"Copied from debian.vim
 set nocompatible
 set backspace=indent,eol,start	" more powerful backspacing
 
     set guifont=DejaVu\ Sans\ Mono\ 10
 endif
 
-colors jellybeans 
+colors jellybeans-jwright
+
 set number
 filetype plugin indent on
 syntax on
 let g:clang_complete_auto = 1
 let g:clang_use_library = 1
 
+""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Cool keymappings
+""""""""""""""""""""""""""""""""""""""""""""""""""""
+"" Tabluar
+if exists(":Tabularize")
+  let mapleader=","
+  nmap <Leader>a= :Tabularize /=<CR>
+  vmap <Leader>a= :Tabularize /=<CR>
+  nmap <Leader>a: :Tabularize /:\zs<CR>
+  vmap <Leader>a: :Tabularize /:\zs<CR>
+endif
+
 " -- Save backups in a common folder instead of in the working directory. End
 "  with a double directory separator to create path indelendent filenames
 if has("win32")

after/plugin/TabularMaps.vim

+if !exists(':Tabularize')
+  finish " Tabular.vim wasn't loaded
+endif
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+AddTabularPattern!  assignment      /[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1
+AddTabularPattern!  two_spaces      /  /l0
+
+AddTabularPipeline! multiple_spaces /  / map(a:lines, "substitute(v:val, '   *', '  ', 'g')") | tabular#TabularizeStrings(a:lines, '  ', 'l0')
+
+AddTabularPipeline! argument_list   /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')')
+                                       \ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0')
+                                       \ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")')
+                                       \ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")')
+
+function! SplitCDeclarations(lines)
+  let rv = []
+  for line in a:lines
+    " split the line into declaractions
+    let split = split(line, '\s*[,;]\s*')
+    " separate the type from the first declaration
+    let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '')
+    " add the ; back on every declaration
+    call map(split, 'v:val . ";"')
+    " add the first element to the return as-is, and remove it from the list
+    let rv += [ remove(split, 0) ]
+    " transform the other elements by adding the type on at the beginning
+    call map(split, 'type . v:val')
+    " and add them all to the return
+    let rv += split
+  endfor
+  return rv
+endfunction
+
+AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines)
+
+AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1
+
+AddTabularPattern! cpp_io /<<\|>>/l1
+
+AddTabularPattern! pascal_assign /:=/l1
+
+AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1
+
+let &cpo = s:save_cpo
+unlet s:save_cpo

autoload/getopts/cpp.cache

--I/usr/include/c++/4.7.0/
--I/usr/include/c++/4.7.0/x86_64-unknown-linux-gnu/
--I/usr/include/c++/4.7.0/backward/
--I/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include/
+-I/usr/include/c++/4.6/
+-I/usr/include/c++/4.6/x86_64-linux-gnu/
+-I/usr/include/c++/4.6/backward/
+-I/usr/lib/gcc/x86_64-linux-gnu/4.6/include/
 -I/usr/local/include/
--I/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed/
+-I/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed/
+-I/usr/include/x86_64-linux-gnu/
 -I/usr/include/

autoload/tabular.vim

+" Tabular:     Align columnar data using regex-designated column boundaries
+" Maintainer:  Matthew Wozniski (godlygeek@gmail.com)
+" Date:        Thu, 03 May 2012 20:49:32 -0400
+" Version:     1.0
+"
+" Long Description:
+" Sometimes, it's useful to line up text.  Naturally, it's nicer to have the
+" computer do this for you, since aligning things by hand quickly becomes
+" unpleasant.  While there are other plugins for aligning text, the ones I've
+" tried are either impossibly difficult to understand and use, or too simplistic
+" to handle complicated tasks.  This plugin aims to make the easy things easy
+" and the hard things possible, without providing an unnecessarily obtuse
+" interface.  It's still a work in progress, and criticisms are welcome.
+"
+" License:
+" Copyright (c) 2012, Matthew J. Wozniski
+" All rights reserved.
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions are met:
+"     * Redistributions of source code must retain the above copyright notice,
+"       this list of conditions and the following disclaimer.
+"     * 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.
+"     * The names of the contributors may not be used to endorse or promote
+"       products derived from this software without specific prior written
+"       permission.
+"
+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
+" 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 COPYRIGHT HOLDER 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.
+
+" Stupid vimscript crap                                                   {{{1
+let s:savecpo = &cpo
+set cpo&vim
+
+" Private Functions                                                       {{{1
+
+" Return the number of bytes in a string after expanding tabs to spaces.  {{{2
+" This expansion is done based on the current value of 'tabstop'
+function! s:Strlen(string)
+  let rv = 0
+  let i = 0
+
+  for char in split(a:string, '\zs')
+    if char == "\t"
+      let rv += &ts - i
+      let i = 0
+    else
+      let rv += 1
+      let i = (i + 1) % &ts
+    endif
+  endfor
+
+  return rv
+endfunction
+
+" Align a string within a field                                           {{{2
+" These functions do not trim leading and trailing spaces.
+
+" Right align 'string' in a field of size 'fieldwidth'
+function! s:Right(string, fieldwidth)
+  let spaces = a:fieldwidth - s:Strlen(a:string)
+  return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '')
+endfunction
+
+" Left align 'string' in a field of size 'fieldwidth'
+function! s:Left(string, fieldwidth)
+  let spaces = a:fieldwidth - s:Strlen(a:string)
+  return a:string . repeat(" ", spaces)
+endfunction
+
+" Center align 'string' in a field of size 'fieldwidth'
+function! s:Center(string, fieldwidth)
+  let spaces = a:fieldwidth - s:Strlen(a:string)
+  let right = spaces / 2
+  let left = right + (right * 2 != spaces)
+  return repeat(" ", left) . a:string . repeat(" ", right)
+endfunction
+
+" Remove spaces around a string                                           {{{2
+
+" Remove all trailing spaces from a string.
+function! s:StripTrailingSpaces(string)
+  return matchstr(a:string, '^.\{-}\ze\s*$')
+endfunction
+
+" Remove all leading spaces from a string.
+function! s:StripLeadingSpaces(string)
+  return matchstr(a:string, '^\s*\zs.*$')
+endfunction
+
+" Split a string into fields and delimiters                               {{{2
+" Like split(), but include the delimiters as elements
+" All odd numbered elements are delimiters
+" All even numbered elements are non-delimiters (including zero)
+function! s:SplitDelim(string, delim)
+  let rv = []
+  let beg = 0
+
+  let len = len(a:string)
+  let searchoff = 0
+
+  while 1
+    let mid = match(a:string, a:delim, beg + searchoff, 1)
+    if mid == -1 || mid == len
+      break
+    endif
+
+    let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1)
+    let length = strlen(matchstr)
+
+    if length == 0 && beg == mid
+      " Zero-length match for a zero-length delimiter - advance past it
+      let searchoff += 1
+      continue
+    endif
+
+    if beg == mid
+      let rv += [ "" ]
+    else
+      let rv += [ a:string[beg : mid-1] ]
+    endif
+
+    let rv += [ matchstr ]
+
+    let beg = mid + length
+    let searchoff = 0
+  endwhile
+
+  let rv += [ strpart(a:string, beg) ]
+
+  return rv
+endfunction
+
+" Replace lines from `start' to `start + len - 1' with the given strings. {{{2
+" If more lines are needed to show all strings, they will be added.
+" If there are too few strings to fill all lines, lines will be removed.
+function! s:SetLines(start, len, strings)
+  if a:start > line('$') + 1 || a:start < 1
+    throw "Invalid start line!"
+  endif
+
+  if len(a:strings) > a:len
+    let fensave = &fen
+    let view = winsaveview()
+    call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len))
+    call winrestview(view)
+    let &fen = fensave
+  elseif len(a:strings) < a:len
+    let fensave = &fen
+    let view = winsaveview()
+    sil exe (a:start + len(a:strings)) . ',' .  (a:start + a:len - 1) . 'd_'
+    call winrestview(view)
+    let &fen = fensave
+  endif
+
+  call setline(a:start, a:strings)
+endfunction
+
+" Runs the given commandstring argument as an expression.                 {{{2
+" The commandstring expression is expected to reference the a:lines argument.
+" If the commandstring expression returns a list the items of that list will
+" replace the items in a:lines, otherwise the expression is assumed to have
+" modified a:lines itself.
+function! s:FilterString(lines, commandstring)
+  exe 'let rv = ' . a:commandstring
+
+  if type(rv) == type(a:lines) && rv isnot a:lines
+    call filter(a:lines, 0)
+    call extend(a:lines, rv)
+  endif
+endfunction
+
+" Public API                                                              {{{1
+
+if !exists("g:tabular_default_format")
+  let g:tabular_default_format = "l1"
+endif
+
+let s:formatelempat = '\%([lrc]\d\+\)'
+
+function! tabular#ElementFormatPattern()
+  return s:formatelempat
+endfunction
+
+" Given a list of strings and a delimiter, split each string on every
+" occurrence of the delimiter pattern, format each element according to either
+" the provided format (optional) or the default format, and join them back
+" together with enough space padding to guarantee that the nth delimiter of
+" each string is aligned.
+function! tabular#TabularizeStrings(strings, delim, ...)
+  if a:0 > 1
+    echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")"
+    return 1
+  endif
+
+  let formatstr = (a:0 ? a:1 : g:tabular_default_format)
+
+  if formatstr !~? s:formatelempat . '\+'
+    echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!"
+    return 1
+  endif
+
+  let format = split(formatstr, s:formatelempat . '\zs')
+
+  let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)')
+
+  " Strip spaces
+  "   - Only from non-delimiters; spaces in delimiters must have been matched
+  "     intentionally
+  "   - Don't strip leading spaces from the first element; we like indenting.
+  for line in lines
+    if line[0] !~ '^\s*$'
+      let line[0] = s:StripTrailingSpaces(line[0])
+    endif
+    if len(line) >= 3
+      for i in range(2, len(line)-1, 2)
+        let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i]))
+      endfor
+    endif
+  endfor
+
+  " Find the max length of each field
+  let maxes = []
+  for line in lines
+    for i in range(len(line))
+      if i == len(maxes)
+        let maxes += [ s:Strlen(line[i]) ]
+      else
+        let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] )
+      endif
+    endfor
+  endfor
+
+  let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"'))
+
+  " Concatenate the fields, according to the format pattern.
+  for idx in range(len(lines))
+    let line = lines[idx]
+    for i in range(len(line))
+      let how = format[i % len(format)][0]
+      let pad = format[i % len(format)][1:-1]
+
+      if how =~? 'l'
+        let field = s:Left(line[i], maxes[i])
+      elseif how =~? 'r'
+        let field = s:Right(line[i], maxes[i])
+      elseif how =~? 'c'
+        let field = s:Center(line[i], maxes[i])
+      endif
+
+      let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad))
+    endfor
+
+    let lines[idx] = s:StripTrailingSpaces(join(line, ''))
+  endfor
+endfunction
+
+" Apply 0 or more filters, in sequence, to selected text in the buffer    {{{2
+" The lines to be filtered are determined as follows:
+"   If the function is called with a range containing multiple lines, then
+"     those lines will be used as the range.
+"   If the function is called with no range or with a range of 1 line, then
+"     if "includepat" is not specified,
+"       that 1 line will be filtered,
+"     if "includepat" is specified and that line does not match it,
+"       no lines will be filtered
+"     if "includepat" is specified and that line does match it,
+"       all contiguous lines above and below the specified line matching the
+"       pattern will be filtered.
+"
+" The remaining arguments must each be a filter to apply to the text.
+" Each filter must either be a String evaluating to a function to be called.
+function! tabular#PipeRange(includepat, ...) range
+  let top = a:firstline
+  let bot = a:lastline
+
+  if a:includepat != '' && top == bot
+    if top < 0 || top > line('$') || getline(top) !~ a:includepat
+      return
+    endif
+    while top > 1 && getline(top-1) =~ a:includepat
+      let top -= 1
+    endwhile
+    while bot < line('$') && getline(bot+1) =~ a:includepat
+      let bot += 1
+    endwhile
+  endif
+
+  let lines = map(range(top, bot), 'getline(v:val)')
+
+  for filter in a:000
+    if type(filter) != type("")
+      echoerr "PipeRange: Bad filter: " . string(filter)
+    endif
+
+    call s:FilterString(lines, filter)
+
+    unlet filter
+  endfor
+
+  call s:SetLines(top, bot - top + 1, lines)
+endfunction
+
+function! s:SplitDelimTest(string, delim, expected)
+  let result = s:SplitDelim(a:string, a:delim)
+
+  if result !=# a:expected
+    echomsg 'Test failed!'
+    echomsg '  string=' . string(a:string) . '  delim=' . string(a:delim)
+    echomsg '  Returned=' . string(result)
+    echomsg '  Expected=' . string(a:expected)
+  endif
+endfunction
+
+function! tabular#SplitDelimUnitTest()
+  let assignment = '[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*='
+  let two_spaces = '  '
+  let ternary_operator = '^.\{-}\zs?\|:'
+  let cpp_io = '<<\|>>'
+  let pascal_assign = ':='
+  let trailing_c_comments = '\/\*\|\*\/\|\/\/'
+
+  call s:SplitDelimTest('a+=b',    assignment, ['a', '+=', 'b'])
+  call s:SplitDelimTest('a-=b',    assignment, ['a', '-=', 'b'])
+  call s:SplitDelimTest('a!=b',    assignment, ['a!=b'])
+  call s:SplitDelimTest('a==b',    assignment, ['a==b'])
+  call s:SplitDelimTest('a&=b',    assignment, ['a', '&=', 'b'])
+  call s:SplitDelimTest('a|=b',    assignment, ['a', '|=', 'b'])
+  call s:SplitDelimTest('a=b=c',   assignment, ['a', '=', 'b', '=', 'c'])
+
+  call s:SplitDelimTest('a  b  c', two_spaces, ['a', '  ', 'b', '  ', 'c'])
+  call s:SplitDelimTest('a b   c', two_spaces, ['a b', '  ', ' c'])
+  call s:SplitDelimTest('ab    c', two_spaces, ['ab', '  ', '', '  ', 'c'])
+
+  call s:SplitDelimTest('a?b:c',   ternary_operator, ['a', '?', 'b', ':', 'c'])
+
+  call s:SplitDelimTest('a<<b<<c', cpp_io, ['a', '<<', 'b', '<<', 'c'])
+
+  call s:SplitDelimTest('a:=b=c',  pascal_assign, ['a', ':=', 'b=c'])
+
+  call s:SplitDelimTest('x//foo',  trailing_c_comments, ['x', '//', 'foo'])
+  call s:SplitDelimTest('x/*foo*/',trailing_c_comments, ['x', '/*', 'foo', '*/', ''])
+
+  call s:SplitDelimTest('#ab#cd#ef', '[^#]*', ['#', 'ab', '#', 'cd', '#', 'ef', ''])
+  call s:SplitDelimTest('#ab#cd#ef', '#\zs',  ['#', '', 'ab#', '', 'cd#', '', 'ef'])
+endfunction
+
+" Stupid vimscript crap, part 2                                           {{{1
+let &cpo = s:savecpo
+unlet s:savecpo
+
+" vim:set sw=2 sts=2 fdm=marker:

colors/jellybeans-jwright.vim

+" Vim color file
+"
+"  "    __       _ _       _                             "
+"  "    \ \  ___| | |_   _| |__   ___  __ _ _ __  ___    "
+"  "     \ \/ _ \ | | | | |  _ \ / _ \/ _  |  _ \/ __|   "
+"  "  /\_/ /  __/ | | |_| | |_| |  __/ |_| | | | \__ \   "
+"  "  \___/ \___|_|_|\__  |____/ \___|\____|_| |_|___/   "
+"  "                 \___/                               "
+"
+"         "A colorful, dark color scheme for Vim."
+"
+" File:         jellybeans.vim
+" Maintainer:   NanoTech <http://nanotech.nanotechcorp.net/>
+" Version:      1.3
+" Last Change:  October 25th, 2010
+" Contributors: Daniel Herbert <http://pocket-ninja.com>,
+"               Henry So, Jr. <henryso@panix.com>,
+"               David Liang <bmdavll at gmail dot com>
+"
+" Copyright (c) 2009-2010 NanoTech
+"
+" Permission is hereby granted, free of charge, to any person obtaining a copy
+" of this software and associated documentation files (the "Software"), to deal
+" in the Software without restriction, including without limitation the rights
+" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+" copies of the Software, and to permit persons to whom the Software is
+" furnished to do so, subject to the following conditions:
+"
+" The above copyright notice and this permission notice shall be included in
+" all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+" THE SOFTWARE.
+
+set background=dark
+
+hi clear
+
+if exists("syntax_on")
+  syntax reset
+endif
+
+let colors_name = "jellybeans-jwright"
+
+if has("gui_running") || &t_Co == 88 || &t_Co == 256
+  let s:low_color = 0
+else
+  let s:low_color = 1
+endif
+
+" Color approximation functions by Henry So, Jr. and David Liang {{{
+" Added to jellybeans.vim by Daniel Herbert
+
+" returns an approximate grey index for the given grey level
+fun! s:grey_number(x)
+  if &t_Co == 88
+    if a:x < 23
+      return 0
+    elseif a:x < 69
+      return 1
+    elseif a:x < 103
+      return 2
+    elseif a:x < 127
+      return 3
+    elseif a:x < 150
+      return 4
+    elseif a:x < 173
+      return 5
+    elseif a:x < 196
+      return 6
+    elseif a:x < 219
+      return 7
+    elseif a:x < 243
+      return 8
+    else
+      return 9
+    endif
+  else
+    if a:x < 14
+      return 0
+    else
+      let l:n = (a:x - 8) / 10
+      let l:m = (a:x - 8) % 10
+      if l:m < 5
+        return l:n
+      else
+        return l:n + 1
+      endif
+    endif
+  endif
+endfun
+
+" returns the actual grey level represented by the grey index
+fun! s:grey_level(n)
+  if &t_Co == 88
+    if a:n == 0
+      return 0
+    elseif a:n == 1
+      return 46
+    elseif a:n == 2
+      return 92
+    elseif a:n == 3
+      return 115
+    elseif a:n == 4
+      return 139
+    elseif a:n == 5
+      return 162
+    elseif a:n == 6
+      return 185
+    elseif a:n == 7
+      return 208
+    elseif a:n == 8
+      return 231
+    else
+      return 255
+    endif
+  else
+    if a:n == 0
+      return 0
+    else
+      return 8 + (a:n * 10)
+    endif
+  endif
+endfun
+
+" returns the palette index for the given grey index
+fun! s:grey_color(n)
+  if &t_Co == 88
+    if a:n == 0
+      return 16
+    elseif a:n == 9
+      return 79
+    else
+      return 79 + a:n
+    endif
+  else
+    if a:n == 0
+      return 16
+    elseif a:n == 25
+      return 231
+    else
+      return 231 + a:n
+    endif
+  endif
+endfun
+
+" returns an approximate color index for the given color level
+fun! s:rgb_number(x)
+  if &t_Co == 88
+    if a:x < 69
+      return 0
+    elseif a:x < 172
+      return 1
+    elseif a:x < 230
+      return 2
+    else
+      return 3
+    endif
+  else
+    if a:x < 75
+      return 0
+    else
+      let l:n = (a:x - 55) / 40
+      let l:m = (a:x - 55) % 40
+      if l:m < 20
+        return l:n
+      else
+        return l:n + 1
+      endif
+    endif
+  endif
+endfun
+
+" returns the actual color level for the given color index
+fun! s:rgb_level(n)
+  if &t_Co == 88
+    if a:n == 0
+      return 0
+    elseif a:n == 1
+      return 139
+    elseif a:n == 2
+      return 205
+    else
+      return 255
+    endif
+  else
+    if a:n == 0
+      return 0
+    else
+      return 55 + (a:n * 40)
+    endif
+  endif
+endfun
+
+" returns the palette index for the given R/G/B color indices
+fun! s:rgb_color(x, y, z)
+  if &t_Co == 88
+    return 16 + (a:x * 16) + (a:y * 4) + a:z
+  else
+    return 16 + (a:x * 36) + (a:y * 6) + a:z
+  endif
+endfun
+
+" returns the palette index to approximate the given R/G/B color levels
+fun! s:color(r, g, b)
+  " get the closest grey
+  let l:gx = s:grey_number(a:r)
+  let l:gy = s:grey_number(a:g)
+  let l:gz = s:grey_number(a:b)
+
+  " get the closest color
+  let l:x = s:rgb_number(a:r)
+  let l:y = s:rgb_number(a:g)
+  let l:z = s:rgb_number(a:b)
+
+  if l:gx == l:gy && l:gy == l:gz
+    " there are two possibilities
+    let l:dgr = s:grey_level(l:gx) - a:r
+    let l:dgg = s:grey_level(l:gy) - a:g
+    let l:dgb = s:grey_level(l:gz) - a:b
+    let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
+    let l:dr = s:rgb_level(l:gx) - a:r
+    let l:dg = s:rgb_level(l:gy) - a:g
+    let l:db = s:rgb_level(l:gz) - a:b
+    let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
+    if l:dgrey < l:drgb
+      " use the grey
+      return s:grey_color(l:gx)
+    else
+      " use the color
+      return s:rgb_color(l:x, l:y, l:z)
+    endif
+  else
+    " only one possibility
+    return s:rgb_color(l:x, l:y, l:z)
+  endif
+endfun
+
+" returns the palette index to approximate the 'rrggbb' hex string
+fun! s:rgb(rgb)
+  let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
+  let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
+  let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
+  return s:color(l:r, l:g, l:b)
+endfun
+
+" sets the highlighting for the given group
+fun! s:X(group, fg, bg, attr, lcfg, lcbg)
+  if s:low_color
+    let l:fge = empty(a:lcfg)
+    let l:bge = empty(a:lcbg)
+
+    if !l:fge && !l:bge
+      exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=".a:lcbg
+    elseif !l:fge && l:bge
+      exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=NONE"
+    elseif l:fge && !l:bge
+      exec "hi ".a:group." ctermfg=NONE ctermbg=".a:lcbg
+    endif
+  else
+    let l:fge = empty(a:fg)
+    let l:bge = empty(a:bg)
+
+    if !l:fge && !l:bge
+      exec "hi ".a:group." guifg=#".a:fg." guibg=#".a:bg." ctermfg=".s:rgb(a:fg)." ctermbg=".s:rgb(a:bg)
+    elseif !l:fge && l:bge
+      exec "hi ".a:group." guifg=#".a:fg." guibg=NONE ctermfg=".s:rgb(a:fg)
+    elseif l:fge && !l:bge
+      exec "hi ".a:group." guifg=NONE guibg=#".a:bg." ctermbg=".s:rgb(a:bg)
+    endif
+  endif
+
+  if a:attr == ""
+    exec "hi ".a:group." gui=none cterm=none"
+  else
+    if a:attr == 'italic'
+      exec "hi ".a:group." gui=".a:attr." cterm=none"
+    else
+      exec "hi ".a:group." gui=".a:attr." cterm=".a:attr
+    endif
+  endif
+endfun
+" }}}
+
+if version >= 700
+  call s:X("CursorLine","","1c1c1c","","","")
+  call s:X("CursorColumn","","1c1c1c","","","")
+  call s:X("MatchParen","ffffff","80a090","bold","","")
+
+  call s:X("TabLine","000000","b0b8c0","italic","","Black")
+  call s:X("TabLineFill","9098a0","","","","")
+  call s:X("TabLineSel","000000","f0f0f0","italic,bold","","")
+
+  " Auto-completion
+  call s:X("Pmenu","ffffff","000000","","","")
+  call s:X("PmenuSel","101010","eeeeee","","","")
+endif
+
+call s:X("Visual","","404040","","","")
+call s:X("Cursor","","b0d0f0","","","")
+
+call s:X("Normal","e8e8d3","151515","","White","")
+call s:X("LineNr","605958","151515","none","Black","")
+call s:X("Comment","C9660B","","italic","Orange","")
+call s:X("Todo","808080","","bold","","")
+
+call s:X("StatusLine","000000","dddddd","italic","Black","White")
+call s:X("StatusLineNC","ffffff","403c41","italic","White","Black")
+call s:X("VertSplit","777777","403c41","italic","Black","Black")
+
+call s:X("Folded","a0a8b0","384048","italic","black","")
+call s:X("FoldColumn","a0a8b0","384048","","","")
+call s:X("SignColumn","a0a8b0","384048","","","")
+
+call s:X("Title","70b950","","bold","","")
+
+call s:X("Constant","cf6a4c","","","Red","")
+call s:X("Special","799d6a","","","Green","")
+call s:X("Delimiter","668799","","","Grey","")
+
+call s:X("String","99ad6a","","","Green","")
+call s:X("StringDelimiter","556633","","","DarkGreen","")
+
+call s:X("Identifier","c6b6ee","","","LightCyan","")
+call s:X("Structure","8fbfdc","","","LightCyan","")
+call s:X("Function","fad07a","","","Yellow","")
+call s:X("Statement","8197bf","","","DarkBlue","")
+call s:X("PreProc","8fbfdc","","","LightBlue","")
+
+hi link Operator Normal
+
+call s:X("Type","ffb964","","","Yellow","")
+call s:X("NonText","606060","151515","","","")
+
+call s:X("SpecialKey","444444","1c1c1c","","","")
+
+call s:X("Search","f0a0c0","302028","underline","Magenta","")
+
+call s:X("Directory","dad085","","","","")
+call s:X("ErrorMsg","","902020","","","")
+hi link Error ErrorMsg
+
+" Diff
+
+hi link diffRemoved Constant
+hi link diffAdded String
+
+" VimDiff
+
+call s:X("DiffAdd","","032218","","Black","DarkGreen")
+call s:X("DiffChange","","100920","","Black","DarkMagenta")
+call s:X("DiffDelete","220000","220000","","DarkRed","DarkRed")
+call s:X("DiffText","","000940","","","DarkRed")
+
+" PHP
+
+hi link phpFunctions Function
+call s:X("StorageClass","c59f6f","","","Red","")
+hi link phpSuperglobal Identifier
+hi link phpQuoteSingle StringDelimiter
+hi link phpQuoteDouble StringDelimiter
+hi link phpBoolean Constant
+hi link phpNull Constant
+hi link phpArrayPair Operator
+
+" Ruby
+
+hi link rubySharpBang Comment
+call s:X("rubyClass","447799","","","DarkBlue","")
+call s:X("rubyIdentifier","c6b6fe","","","","")
+
+call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","")
+call s:X("rubySymbol","7697d6","","","Blue","")
+hi link rubyGlobalVariable rubyInstanceVariable
+hi link rubyModule rubyClass
+call s:X("rubyControl","7597c6","","","","")
+
+hi link rubyString String
+hi link rubyStringDelimiter StringDelimiter
+hi link rubyInterpolationDelimiter Identifier
+
+call s:X("rubyRegexpDelimiter","540063","","","Magenta","")
+call s:X("rubyRegexp","dd0093","","","DarkMagenta","")
+call s:X("rubyRegexpSpecial","a40073","","","Magenta","")
+
+call s:X("rubyPredefinedIdentifier","de5577","","","Red","")
+
+" JavaScript
+hi link javaScriptValue Constant
+hi link javaScriptRegexpString rubyRegexp
+
+" C
+
+hi link cOperator Constant
+
+" Objective-C/Cocoa
+hi link objcClass Type
+hi link cocoaClass objcClass
+hi link objcSubclass objcClass
+hi link objcSuperclass objcClass
+hi link objcDirective rubyClass
+hi link cocoaFunction Function
+hi link objcMethodName Identifier
+hi link objcMethodArg Normal
+hi link objcMessageName Identifier
+
+" Tag list
+hi link TagListFileName Directory
+
+" delete functions {{{
+delf s:X
+delf s:rgb
+delf s:color
+delf s:rgb_color
+delf s:rgb_level
+delf s:rgb_number
+delf s:grey_color
+delf s:grey_level
+delf s:grey_number
+" }}}
+*Tabular.txt*   Configurable, flexible, intuitive text aligning
+
+                                                       *tabular* *tabular.vim*
+
+       #|#|#|#|#|          #|                  #|                     ~
+           #|      #|#|#|  #|#|#|    #|    #|  #|    #|#|#|  #|  #|#| ~
+           #|    #|    #|  #|    #|  #|    #|  #|  #|    #|  #|#|     ~
+           #|    #|    #|  #|    #|  #|    #|  #|  #|    #|  #|       ~
+           #|      #|#|#|  #|#|#|      #|#|#|  #|    #|#|#|  #|       ~
+
+                                                  For Vim version 7.0 or newer
+
+                               By Matt Wozniski
+                                mjw@drexel.edu
+
+                               Reference Manual ~
+
+                                                                 *tabular-toc*
+
+1. Description                                           |tabular-intro|
+2. Walkthrough                                           |tabular-walkthrough|
+3. Scripting                                             |tabular-scripting|
+
+The functionality mentioned here is a plugin, see |add-plugin|.
+You can avoid loading this plugin by setting the "Tabular_loaded" global
+variable in your |vimrc| file: >
+    :let g:tabular_loaded = 1
+
+==============================================================================
+1. Description                                                 *tabular-intro*
+
+Sometimes, it's useful to line up text.  Naturally, it's nicer to have the
+computer do this for you, since aligning things by hand quickly becomes
+unpleasant.  While there are other plugins for aligning text, the ones I've
+tried are either impossibly difficult to understand and use, or too simplistic
+to handle complicated tasks.  This plugin aims to make the easy things easy
+and the hard things possible, without providing an unnecessarily obtuse
+interface.  It's still a work in progress, and criticisms are welcome.
+
+==============================================================================
+2. Walkthrough                                           *tabular-walkthrough*
+
+Tabular's commands are based largely on regular expressions.  The basic
+technique used by Tabular is taking some regex to match field delimiters,
+splitting the input lines at those delimiters, trimming unnecessary spaces
+from the non-delimiter parts, padding the non-delimiter parts of the lines
+with spaces to make them the same length, and joining things back together
+again.
+
+For instance, consider starting with the following lines:
+>
+    Some short phrase,some other phrase
+    A much longer phrase here,and another long phrase
+<
+Let's say we want to line these lines up at the commas.  We can tell
+Tabularize to do this by passing a pattern matching , to the Tabularize
+command:
+>
+  :Tabularize /,
+
+    Some short phrase         , some other phrase
+    A much longer phrase here , and another long phrase
+<
+I encourage you to try copying those lines to another buffer and trying to
+call :Tabularize.  You'll want to take notice of two things quickly: First,
+instead of requiring a range, Tabularize tries to figure out what you want to
+happen.  Since it knows that you want to act on lines matching a comma, it
+will look upwards and downwards for lines around the current line that match a
+comma, and consider all contiguous lines matching the pattern to be the range
+to be acted upon.  You can always override this by specifying a range, though.
+
+The second thing you should notice is that you'll almost certainly be able to
+abbreviate :Tabularize to :Tab - using this form in mappings and scripts is
+discouraged as it will make conflicts with other scripts more likely, but for
+interactive use it's a nice timesaver.  Another convenience feature is that
+running :Tabularize without providing a new pattern will cause it to reuse the
+last pattern it was called with.
+
+So, anyway, now the commas line up.  Splitting the lines on commas, Tabular
+realized that 'Some short phrase' would need to be padded with spaces to match
+the length of 'A much longer phrase here', and it did that before joining the
+lines back together.  You'll also notice that, in addition to the spaces
+inserting for padding, extra spaces were inserted between fields.  That's
+because by default, Tabular prints things left-aligned with one space between
+fields.  If you wanted to print things right-aligned with no spaces between
+fields, you would provide a different format to the Tabularize command:
+>
+  :Tabularize /,/r0
+
+            Some short phrase,      some other phrase
+    A much longer phrase here,and another long phrase
+<
+A format specifier is either l, r, or c, followed by one or more digits.  If
+the letter is l, the field will be left aligned, similarly for r and right
+aligning and c and center aligning.  The number following the letter is the
+number of spaces padding to insert before the start of the next field.
+Multiple format specifiers can be added to the same command - each field will
+be printed with the next format specifier in the list; when they all have been
+used the first will be used again, and so on.  So, the last command right
+aligned every field, then inserted 0 spaces of padding before the next field.
+What if we wanted to right align the text before the comma, and left align the
+text after the comma?  The command would look like this:
+>
+  :Tabularize /,/r1c1l0
+
+            Some short phrase , some other phrase
+    A much longer phrase here , and another long phrase
+<
+That command would be read as "Align the matching text, splitting fields on
+commas.  Print everything before the first comma right aligned, then 1 space,
+then the comma center aligned, then 1 space, then everything after the comma
+left aligned."  Notice that the alignment of the field the comma is in is
+irrelevant - since it's only 1 cell wide, it looks the same whether it's right,
+left, or center aligned.  Also notice that the 0 padding spaces specified for
+the 3rd field are unused - but they would be used if there were enough fields
+to require looping through the fields again.  For instance:
+>
+    abc,def,ghi
+    a,b
+    a,b,c
+
+  :Tabularize /,/r1c1l0
+
+    abc , def, ghi
+      a , b
+      a , b  ,  c
+<
+Notice that now, the format pattern has been reused; field 4 (the second comma)
+is right aligned, field 5 is center aligned.  No spaces were inserted between
+the 3rd field (containing "def") and the 4th field (the second comma) because
+the format specified 'l0'.
+
+But, what if you only wanted to act on the first comma on the line, rather than
+all of the commas on the line?  Let's say we want everything before the first
+comma right aligned, then the comma, then everything after the comma left
+aligned:
+>
+    abc,def,ghi
+    a,b
+    a,b,c
+
+  :Tabularize /^[^,]*\zs,/r0c0l0
+
+    abc,def,ghi
+      a,b
+      a,b,c
+<
+Here, we used a Vim regex that would only match the first comma on the line.
+It matches the beginning of the line, followed by all the non-comma characters
+up to the first comma, and then forgets about what it matched so far and
+pretends that the match starts exactly at the comma.
+
+But, now that this command does exactly what we want it to, it's become pretty
+unwieldy.  It would be unpleasant to need to type that more than once or
+twice.  The solution is to assign a name to it.
+>
+  :AddTabularPattern first_comma /^[^,]*\zs,/r0c0l0
+<
+Now, typing ":Tabularize first_comma" will do the same thing as typing the
+whole pattern out each time.  Of course this is more useful if you store the
+name in a file to be used later.
+
+NOTE: In order to make these new commands available every time vim starts,
+you'll need to put those new commands into a .vim file in a plugin directory
+somewhere in your 'runtimepath'.  In order to make sure that Tabular.vim has
+already been loaded before your file tries to use :AddTabularPattern or
+:AddTabularPipeline, the new file should be installed in an after/plugin
+directory in 'runtimepath'.  In general, it will be safe to find out where the
+TabularMaps.vim plugin was installed, and place other files extending
+Tabular.vim in the same directory as TabularMaps.vim.  For more information,
+and some suggested best practices, check out the |tabular-scripting| section.
+
+Lastly, we'll approach the case where tabular cannot achieve your desired goal
+just by splitting lines appart, trimming whitespace, padding with whitespace,
+and rejoining the lines.  As an example, consider the multiple_spaces command
+from TabularMaps.vim.  The goal is to split using two or more spaces as a
+field delimiter, and join fields back together, properly lined up, with only
+two spaces between the end of each field and the beginning of the next.
+Unfortunately, Tabular can't do this with only the commands we know so far:
+>
+  :Tabularize /  /
+<
+The above function won't work, because it will consider "a    b" as 5 fields
+delimited by two pairs of 2 spaces ( 'a', '  ', '', '  ', 'b' ) instead of as
+3 fields delimited by one set of 2 or more spaces ( 'a', '    ', 'b' ).
+>
+  :Tabularize /  \+/
+<
+The above function won't work either, because it will leave the delimiter as 4
+spaces when used against "a    b", meaning that we would fail at our goal of
+collapsing everything down to two spaces between fields.  So, we need a new
+command to get around this:
+>
+  :AddTabularPipeline multiple_spaces / \{2,}/
+    \ map(a:lines, "substitute(v:val, ' \{2,}', '  ', 'g')")
+    \   | tabular#TabularizeStrings(a:lines, '  ', 'l0')
+<
+Yeah.  I know it looks complicated.  Bear with me.  I probably will try to add
+in some shortcuts for this syntax, but this verbose will be guaranteed to
+always work.
+
+You should already recognize the name being assigned.  The next thing to
+happen is / \{2,}/ which is a pattern specifying which lines should
+automatically be included in the range when no range is given.  Without this,
+there would be no pattern to use for extending the range.  Everything after
+that is a | separated list of expressions to be evaluated.  In the context in
+which they will be evaluated, a:lines will be set to a List of Strings
+containing the text of the lines being filtered as they procede through the
+pipeline you've set up.  The \ at the start of the lines are just vim's line
+continuation marker; you needn't worry much about them.  So, the first
+expression in the pipeline transforms each line by replacing every instance of
+2 or more spaces with exactly two spaces.  The second command in the pipeline
+performs the equivalent of ":Tabularize /  /l0"; the only difference is that
+it is operating on a List of Strings rather than text in the buffer.  At the
+end of the pipeline, the Strings in the modified a:lines (or the return value
+of the last expression in the pipeline, if it returns a List) will replace the
+chosen range.
+
+==============================================================================
+3. Extending                                               *tabular-scripting*
+
+As mentioned above, the most important consideration when extending Tabular
+with new maps or commands is that your plugin must be loaded after Tabular.vim
+has finished loading, and only if Tabular.vim has loaded successfully.  The
+easiest approach to making sure it loads after Tabular.vim is simply putting
+the new file (we'll call it "tabular_extra.vim" as an example) into an
+"after/plugin/" directory in 'runtimepath', for instance:
+>
+  ~/.vim/after/plugin/tabular_extra.vim
+<
+The default set of mappings, found in "TabularMaps.vim", is installed in
+the after/plugin/ subdirectory of whatever directory Tabular was installed to.
+
+The other important consideration is making sure that your commands are only
+called if Tabular.vim was actually loaded.  The easiest way to do this is by
+checking for the existence of the :Tabularize command at the start of your
+plugin.  A short example plugin would look like this:
+>
+  " after/plugin/my_tabular_commands.vim
+  " Provides extra :Tabularize commands
+
+  if !exists(':Tabularize')
+    finish " Give up here; the Tabular plugin musn't have been loaded
+  endif
+
+  " Make line wrapping possible by resetting the 'cpo' option, first saving it
+  let s:save_cpo = &cpo
+  set cpo&vim
+
+  AddTabularPattern! asterisk /*/l1
+
+  AddTabularPipeline! remove_leading_spaces /^ /
+                  \ map(a:lines, "substitute(v:val, '^ *', '', '')")
+
+  " Restore the saved value of 'cpo'
+  let &cpo = s:save_cpo
+  unlet s:save_cpo
+<
+==============================================================================
+vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:

plugin/Tabular.vim

+" Tabular:     Align columnar data using regex-designated column boundaries
+" Maintainer:  Matthew Wozniski (godlygeek@gmail.com)
+" Date:        Thu, 03 May 2012 20:49:32 -0400
+" Version:     1.0
+"
+" Long Description:
+" Sometimes, it's useful to line up text.  Naturally, it's nicer to have the
+" computer do this for you, since aligning things by hand quickly becomes
+" unpleasant.  While there are other plugins for aligning text, the ones I've
+" tried are either impossibly difficult to understand and use, or too simplistic
+" to handle complicated tasks.  This plugin aims to make the easy things easy
+" and the hard things possible, without providing an unnecessarily obtuse
+" interface.  It's still a work in progress, and criticisms are welcome.
+"
+" License:
+" Copyright (c) 2012, Matthew J. Wozniski
+" All rights reserved.
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions are met:
+"     * Redistributions of source code must retain the above copyright notice,
+"       this list of conditions and the following disclaimer.
+"     * 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.
+"     * The names of the contributors may not be used to endorse or promote
+"       products derived from this software without specific prior written
+"       permission.
+"
+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
+" 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 COPYRIGHT HOLDER 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.
+
+" Abort if running in vi-compatible mode or the user doesn't want us.
+if &cp || exists('g:tabular_loaded')
+  if &cp && &verbose
+    echo "Not loading Tabular in compatible mode."
+  endif
+  finish
+endif
+
+let g:tabular_loaded = 1
+
+" Stupid vimscript crap                                                   {{{1
+let s:savecpo = &cpo
+set cpo&vim
+
+" Private Things                                                          {{{1
+
+" Dictionary of command name to command
+let s:TabularCommands = {}
+
+" Generate tab completion list for :Tabularize                            {{{2
+" Return a list of commands that match the command line typed so far.
+" NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem
+"       to handle that terribly well... maybe I should give up on that.
+function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos)
+  let names = keys(s:TabularCommands)
+  if exists("b:TabularCommands")
+    let names += keys(b:TabularCommands)
+  endif
+
+  let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '')
+
+  return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')')
+endfunction
+
+" Choose the proper command map from the given command line               {{{2
+" Returns [ command map, command line with leading <buffer> removed ]
+function! s:ChooseCommandMap(commandline)
+  let map = s:TabularCommands
+  let cmd = a:commandline
+
+  if cmd =~# '^<buffer>\s\+'
+    if !exists('b:TabularCommands')
+      let b:TabularCommands = {}
+    endif
+    let map = b:TabularCommands
+    let cmd = substitute(cmd, '^<buffer>\s\+', '', '')
+  endif
+
+  return [ map, cmd ]
+endfunction
+
+" Parse '/pattern/format' into separate pattern and format parts.         {{{2
+" If parsing fails, return [ '', '' ]
+function! s:ParsePattern(string)
+  if a:string[0] != '/'
+    return ['','']
+  endif
+
+  let pat = '\\\@<!\%(\\\\\)\{-}\zs/' . tabular#ElementFormatPattern() . '*$'
+  let format = matchstr(a:string[1:-1], pat)
+  if !empty(format)
+    let format = format[1 : -1]
+    let pattern = a:string[1 : -len(format) - 2]
+  else
+    let pattern = a:string[1 : -1]
+  endif
+
+  return [pattern, format]
+endfunction
+
+" Split apart a list of | separated expressions.                          {{{2
+function! s:SplitCommands(string)
+  if a:string =~ '^\s*$'
+    return []
+  endif
+
+  let end = match(a:string, "[\"'|]")
+
+  " Loop until we find a delimiting | or end-of-string
+  while end != -1 && (a:string[end] != '|' || a:string[end+1] == '|')
+    if a:string[end] == "'"
+      let end = match(a:string, "'", end+1) + 1
+      if end == 0
+        throw "No matching end single quote"
+      endif
+    elseif a:string[end] == '"'
+      " Find a " preceded by an even number of \ (or 0)
+      let pattern = '\%(\\\@<!\%(\\\\\)*\)\@<="'
+      let end = matchend(a:string, pattern, end+1) + 1
+      if end == 0
+        throw "No matching end double quote"
+      endif
+    else " Found ||
+      let end += 2
+    endif
+
+    let end = match(a:string, "[\"'|]", end)
+  endwhile
+
+  if end == 0 || a:string[0 : end - (end > 0)] =~ '^\s*$'
+    throw "Empty element"
+  endif
+
+  if end == -1
+    let rv = [ a:string ]
+  else
+    let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1])
+  endif
+
+  return rv
+endfunction
+
+" Public Things                                                           {{{1
+
+" Command associating a command name with a simple pattern command        {{{2
+" AddTabularPattern[!] [<buffer>] name /pattern[/format]
+"
+" If <buffer> is provided, the command will only be available in the current
+" buffer, and will be used instead of any global command with the same name.
+"
+" If a command with the same name and scope already exists, it is an error,
+" unless the ! is provided, in which case the existing command will be
+" replaced.
+"
+" pattern is a regex describing the delimiter to be used.
+"
+" format describes the format pattern to be used.  The default will be used if
+" none is provided.
+com! -nargs=+ -bang AddTabularPattern
+   \ call AddTabularPattern(<q-args>, <bang>0)
+
+function! AddTabularPattern(command, force)
+  try
+    let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
+
+    let name = matchstr(rest, '.\{-}\ze\s*/')
+    let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
+
+    let [ pattern, format ] = s:ParsePattern(pattern)
+
+    if empty(name) || empty(pattern)
+      throw "Invalid arguments!"
+    endif
+
+    if !a:force && has_key(commandmap, name)
+      throw string(name) . " is already defined, use ! to overwrite."
+    endif
+
+    let command = "tabular#TabularizeStrings(a:lines, " . string(pattern)
+
+    if !empty(format)
+      let command .=  ", " . string(format)
+    endif
+
+    let command .= ")"
+
+    let commandmap[name] = ":call tabular#PipeRange("
+          \ . string(pattern) . ","
+          \ . string(command) . ")"
+  catch
+    echohl ErrorMsg
+    echomsg "AddTabularPattern: " . v:exception
+    echohl None
+  endtry
+endfunction
+
+" Command associating a command name with a pipeline of functions         {{{2
+" AddTabularPipeline[!] [<buffer>] name /pattern/ func [ | func2 [ | func3 ] ]
+"
+" If <buffer> is provided, the command will only be available in the current
+" buffer, and will be used instead of any global command with the same name.
+"
+" If a command with the same name and scope already exists, it is an error,
+" unless the ! is provided, in which case the existing command will be
+" replaced.
+"
+" pattern is a regex that will be used to determine which lines will be
+" filtered.  If the cursor line doesn't match the pattern, using the command
+" will be a no-op, otherwise the cursor and all contiguous lines matching the
+" pattern will be filtered.
+"
+" Each 'func' argument represents a function to be called.  This function
+" will have access to a:lines, a List containing one String per line being
+" filtered.
+com! -nargs=+ -bang AddTabularPipeline
+   \ call AddTabularPipeline(<q-args>, <bang>0)
+
+function! AddTabularPipeline(command, force)
+  try
+    let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
+
+    let name = matchstr(rest, '.\{-}\ze\s*/')
+    let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
+
+    let commands = matchstr(pattern, '^/.\{-}\\\@<!\%(\\\\\)\{-}/\zs.*')
+    let pattern = matchstr(pattern, '/\zs.\{-}\\\@<!\%(\\\\\)\{-}\ze/')
+
+    if empty(name) || empty(pattern)
+      throw "Invalid arguments!"
+    endif
+
+    if !a:force && has_key(commandmap, name)
+      throw string(name) . " is already defined, use ! to overwrite."
+    endif
+
+    let commandlist = s:SplitCommands(commands)
+
+    if empty(commandlist)
+      throw "Must provide a list of functions!"
+    endif
+
+    let cmd = ":call tabular#PipeRange(" . string(pattern)
+
+    for command in commandlist
+      let cmd .= "," . string(command)
+    endfor
+
+    let cmd .= ")"
+
+    let commandmap[name] = cmd
+  catch
+    echohl ErrorMsg
+    echomsg "AddTabularPipeline: " . v:exception
+    echohl None
+  endtry
+endfunction
+
+" Tabularize /pattern[/format]                                            {{{2
+" Tabularize name
+"
+" Align text, either using the given pattern, or the command associated with
+" the given name.
+com! -nargs=* -range -complete=customlist,<SID>CompleteTabularizeCommand
+   \ Tabularize <line1>,<line2>call Tabularize(<q-args>)
+
+function! Tabularize(command) range
+  if empty(a:command)
+    if !exists("s:last_tabularize_command")
+      echohl ErrorMsg
+      echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!"
+      echohl None
+      return
+    endif
+  else
+    let s:last_tabularize_command = a:command
+  endif
+
+  let command = s:last_tabularize_command
+
+  let range = a:firstline . ',' . a:lastline
+
+  try
+    let [ pattern, format ] = s:ParsePattern(command)
+
+    if !empty(pattern)
+      let cmd  = "tabular#TabularizeStrings(a:lines, " . string(pattern)
+
+      if !empty(format)
+        let cmd .= "," . string(format)
+      endif
+
+      let cmd .= ")"
+
+      exe range . 'call tabular#PipeRange(pattern, cmd)'
+    else
+      if exists('b:TabularCommands') && has_key(b:TabularCommands, command)
+        let command = b:TabularCommands[command]
+      elseif has_key(s:TabularCommands, command)
+        let command = s:TabularCommands[command]
+      else
+        throw "Unrecognized command " . string(command)
+      endif
+
+      exe range . command
+    endif
+  catch
+    echohl ErrorMsg
+    echomsg "Tabularize: " . v:exception
+    echohl None
+    return
+  endtry
+endfunction
+
+" Stupid vimscript crap, part 2                                           {{{1
+let &cpo = s:savecpo
+unlet s:savecpo
+
+" vim:set sw=2 sts=2 fdm=marker:
Add a comment to this file

plugin/clang/__init__.pyc

Binary file modified.

Add a comment to this file

plugin/clang/cindex.pyc

Binary file modified.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.