This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! ToggleBoolean() | |
| return "ciw\<c-r>=@\" =~# 'true' ? 'false' : 'true'\<cr>\<esc>" | |
| endfunction | |
| nnoremap <expr> <c-x> match(expand('<cword>'), '[-+]\?\d\+') == -1 ? ToggleBoolean() : ":normal! \<c-x>\<cr>" | |
| finish | |
| 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let s:neongenesis = [ | |
| \ ['q', ['d', '+']], | |
| \ ['d', ['s', '+']], | |
| \ ['s', ['d', '-']], | |
| \ ['d', ['q', '-']] | |
| \] | |
| function! NeonIn(neon, n) | |
| let s = a:neon[1][0] | |
| let s .= a:n*2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " VimL Example of Walking an AST | |
| " Barry Arthur, 2012 07 31 | |
| " simple AST walker with a visitor, applied to each node in the tree | |
| func! Walk(ast, visitor) | |
| return type(a:ast) == type([]) ? call(a:visitor[a:ast[0]], [a:ast[1]], a:visitor) : a:ast | |
| endfunc | |
| " one way to define a VimLPOO object | |
| let eval_visitor = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " VimL Example of Walking a multi-child AST | |
| " Barry Arthur, 2012 08 01 | |
| " The same simple AST walker | |
| func! Walk(ast, visitor) | |
| return type(a:ast) == type([]) ? call(a:visitor[a:ast[0]], [a:ast[1]], a:visitor) : a:ast | |
| endfunc | |
| " rainbows and unicorns | |
| function! RnU() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! HTMLCurrentDivId() | |
| let m = searchpos('<\s*div.\{-}id\s*=\s*"\([^"]*\)"', 'bnWp') | |
| if m[2] == 2 | |
| return matchlist(getline(m[0]), 'id\s*=\s*"\([^"]*\)"')[1] | |
| else | |
| return '' | |
| endif | |
| endfunction | |
| set statusline=%f%m%r%h%w\ [%n:%{&ff}/%Y]%=[0x\%04.4B][%03v][%p%%\ line\ %l\ of\ %L,\ \%{HTMLCurrentDivId()}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! HTMLCurrentDivId() | |
| let m = searchpos('<\s*div.\{-}id\s*=\s*"\([^"]*\)"', 'bnWp') | |
| if m[2] == 2 | |
| return matchlist(getline(m[0]), 'id\s*=\s*"\([^"]*\)"')[1] | |
| else | |
| return '' | |
| endif | |
| endfunction | |
| set statusline=%f%m%r%h%w\ [%n:%{&ff}/%Y]%=[0x\%04.4B][%03v][%p%%\ line\ %l\ of\ %L,\ \%{HTMLCurrentDivId()}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! Chroma(msg) | |
| let msg = substitute(a:msg, '\*\([^\*]\+\)\*', '"|echohl Error|echon "\1"|echohl None|echon "', 'g') | |
| exe 'echon "' . msg . '"' | |
| endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " proof of concept - Chroma: Vim colour printer using *markup* | |
| " Barry Arthur, 2012 08 02 | |
| let s:ChromaTags = ['!' , '\\*' , '+' , '/' , '_'] | |
| let s:ChromaTagNames = ['Bang' , 'Star' , 'Plus' , 'Slash' , 'UScore'] | |
| let s:ChromaHighlights = ['Error' , 'WarningMsg' , 'Type' , 'Keyword' , 'Label'] | |
| let s:ChromaTagPattern = '%\([^%]\+\)%' | |
| let s:ChromaEchoPattern = '"|echohl % |echon "\1"|echohl None|echon "' | |
| let s:Chroma = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! Flatten(list) | |
| let val = [] | |
| for elem in a:list | |
| if type(elem) == type([]) | |
| call extend(val, Flatten(elem)) | |
| else | |
| call extend(val, [elem]) | |
| endif | |
| unlet elem | |
| endfor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " MaximizeWithoutResizingQuickfix | |
| " Barry Arthur, 2012 08 14 | |
| " A solution not using vimple | |
| function! MaximizeWithoutResizingQuickfix() | |
| let qfwnr = get(get(filter(map(range(1,winnr('$')), '[v:val, getwinvar(v:val, "&buftype")]'), 'v:val[1] =~ "quickfix"'), 0, []), 0, -1) | |
| let qfh = winheight(qfwnr) | |
| wincmd _ | |
| if qfwnr != -1 | |
| exe qfwnr . "wincmd w" |