├── .gitignore ├── README.md ├── autoload └── pathogen.vim ├── bundle ├── ack.vim │ ├── doc │ │ ├── ack.txt │ │ └── tags │ └── plugin │ │ └── ack.vim ├── ctrlp.vim │ ├── .gitignore │ ├── autoload │ │ ├── ctrlp.vim │ │ └── ctrlp │ │ │ ├── bookmarkdir.vim │ │ │ ├── buffertag.vim │ │ │ ├── changes.vim │ │ │ ├── dir.vim │ │ │ ├── line.vim │ │ │ ├── mixed.vim │ │ │ ├── mrufiles.vim │ │ │ ├── quickfix.vim │ │ │ ├── rtscript.vim │ │ │ ├── tag.vim │ │ │ ├── undo.vim │ │ │ └── utils.vim │ ├── doc │ │ └── ctrlp.txt │ ├── plugin │ │ └── ctrlp.vim │ └── readme.md ├── delimitMate │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── autoload │ │ ├── delimitMate.vim │ │ └── delimitMateTests.vim │ ├── doc │ │ └── delimitMate.txt │ ├── plugin │ │ └── delimitMate.vim │ └── test │ │ ├── README │ │ ├── _setup.vim │ │ ├── autoclose_matchpairs.txt │ │ ├── autoclose_matchpairs.vim │ │ ├── autoclose_quotes.txt │ │ ├── autoclose_quotes.vim │ │ ├── expand_cr.txt │ │ ├── expand_cr.vim │ │ ├── expand_space.txt │ │ └── expand_space.vim ├── gnupg │ └── plugin │ │ └── gnupg.vim ├── matchit │ ├── doc │ │ └── matchit.txt │ └── plugin │ │ └── matchit.vim ├── snipmate │ ├── README │ ├── after │ │ └── plugin │ │ │ └── snipMate.vim │ ├── autoload │ │ └── snipMate.vim │ ├── doc │ │ ├── snipMate.txt │ │ └── tags │ ├── ftplugin │ │ └── html_snip_helper.vim │ ├── plugin │ │ └── snipMate.vim │ ├── snippets │ │ ├── _.snippets │ │ ├── autoit.snippets │ │ ├── c.snippets │ │ ├── cpp.snippets │ │ ├── css.snippets │ │ ├── eruby.snippets │ │ ├── html.snippets │ │ ├── java.snippets │ │ ├── javascript.snippets │ │ ├── mako.snippets │ │ ├── objc.snippets │ │ ├── perl.snippets │ │ ├── php.snippets │ │ ├── python.snippets │ │ ├── ruby.snippets │ │ ├── scss.snippets │ │ ├── sh.snippets │ │ ├── snippet.snippets │ │ ├── tcl.snippets │ │ ├── tex.snippets │ │ ├── vim.snippets │ │ └── zsh.snippets │ └── syntax │ │ └── snippet.vim ├── surround.vim │ ├── doc │ │ ├── surround.txt │ │ └── tags │ └── plugin │ │ └── surround.vim ├── tComment │ ├── README │ ├── autoload │ │ └── tcomment.vim │ ├── doc │ │ └── tcomment.txt │ └── plugin │ │ └── tcomment.vim ├── vim-auto-save │ ├── README │ ├── README.md │ ├── doc │ │ └── LICENSE.txt │ └── plugin │ │ └── AutoSave.vim └── vim-rails │ ├── .gitignore │ ├── CONTRIBUTING.markdown │ ├── README.markdown │ ├── autoload │ └── rails.vim │ ├── doc │ └── rails.txt │ └── plugin │ └── rails.vim └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | *.netrwhist 3 | *.zip 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Who will love this? 2 | If you do web dev a lot...yes 3 | 4 | ### Install 5 | 1. clone the repo 6 | 7 | git clone git://github.com/happypeter/peter-vim.git 8 | 9 | 1. rename it 10 | 11 | mv peter-vim ~/.vim 12 | 13 | 1. set up `~/.vimrc`, have a fake `.vimrc` in your `$HOME` 14 | 15 | ln -s ~/.vim/vimrc ~/.vimrc 16 | 17 | 1. you also need to install `Ctags`, `ack-grep` 18 | 19 | sudo apt-get install exuberant-ctags ack-grep # for ubuntu 20 | 21 | 1. vim 注意 22 | 23 | vim 中有 gpg.vim 插件,但是插件能使用的前题是系统上已经安装了 gpg ,也就是先要 24 | 25 | ``` 26 | brew install gpg 27 | ``` 28 | 29 | 然后再 30 | 31 | ``` 32 | vim xxx.gpg 33 | ``` 34 | 35 | 1. Video about how I manage my plugins 36 | 37 | - [vim plugin manage](https://www.bilibili.com/video/BV1JE411G7M3) 38 | -------------------------------------------------------------------------------- /autoload/pathogen.vim: -------------------------------------------------------------------------------- 1 | " pathogen.vim - path option manipulation 2 | " Maintainer: Tim Pope 3 | " Version: 2.0 4 | 5 | " Install in ~/.vim/autoload (or ~\vimfiles\autoload). 6 | " 7 | " For management of individually installed plugins in ~/.vim/bundle (or 8 | " ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc 9 | " prior to `filetype plugin indent on` is the only other setup necessary. 10 | " 11 | " The API is documented inline below. For maximum ease of reading, 12 | " :set foldmethod=marker 13 | 14 | if exists("g:loaded_pathogen") || &cp 15 | finish 16 | endif 17 | let g:loaded_pathogen = 1 18 | 19 | " Point of entry for basic default usage. Give a directory name to invoke 20 | " pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path 21 | " to invoke pathogen#runtime_prepend_subdirectories(). Afterwards, 22 | " pathogen#cycle_filetype() is invoked. 23 | function! pathogen#infect(...) abort " {{{1 24 | let source_path = a:0 ? a:1 : 'bundle' 25 | if source_path =~# '[\\/]' 26 | call pathogen#runtime_prepend_subdirectories(source_path) 27 | else 28 | call pathogen#runtime_append_all_bundles(source_path) 29 | endif 30 | call pathogen#cycle_filetype() 31 | endfunction " }}}1 32 | 33 | " Split a path into a list. 34 | function! pathogen#split(path) abort " {{{1 35 | if type(a:path) == type([]) | return a:path | endif 36 | let split = split(a:path,'\\\@"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags')) 170 | helptags `=dir.'/doc'` 171 | endif 172 | endfor 173 | endfunction " }}}1 174 | 175 | command! -bar Helptags :call pathogen#helptags() 176 | 177 | " Like findfile(), but hardcoded to use the runtimepath. 178 | function! pathogen#runtime_findfile(file,count) "{{{1 179 | let rtp = pathogen#join(1,pathogen#split(&rtp)) 180 | return fnamemodify(findfile(a:file,rtp,a:count),':p') 181 | endfunction " }}}1 182 | 183 | " Backport of fnameescape(). 184 | function! pathogen#fnameescape(string) " {{{1 185 | if exists('*fnameescape') 186 | return fnameescape(a:string) 187 | elseif a:string ==# '-' 188 | return '\-' 189 | else 190 | return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','') 191 | endif 192 | endfunction " }}}1 193 | 194 | function! s:find(count,cmd,file,lcd) " {{{1 195 | let rtp = pathogen#join(1,pathogen#split(&runtimepath)) 196 | let file = pathogen#runtime_findfile(a:file,a:count) 197 | if file ==# '' 198 | return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" 199 | elseif a:lcd 200 | let path = file[0:-strlen(a:file)-2] 201 | execute 'lcd `=path`' 202 | return a:cmd.' '.pathogen#fnameescape(a:file) 203 | else 204 | return a:cmd.' '.pathogen#fnameescape(file) 205 | endif 206 | endfunction " }}}1 207 | 208 | function! s:Findcomplete(A,L,P) " {{{1 209 | let sep = pathogen#separator() 210 | let cheats = { 211 | \'a': 'autoload', 212 | \'d': 'doc', 213 | \'f': 'ftplugin', 214 | \'i': 'indent', 215 | \'p': 'plugin', 216 | \'s': 'syntax'} 217 | if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) 218 | let request = cheats[a:A[0]].a:A[1:-1] 219 | else 220 | let request = a:A 221 | endif 222 | let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*' 223 | let found = {} 224 | for path in pathogen#split(&runtimepath) 225 | let path = expand(path, ':p') 226 | let matches = split(glob(path.sep.pattern),"\n") 227 | call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') 228 | call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') 229 | for match in matches 230 | let found[match] = 1 231 | endfor 232 | endfor 233 | return sort(keys(found)) 234 | endfunction " }}}1 235 | 236 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0) 237 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0) 238 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1) 239 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1) 240 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1) 241 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1) 242 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1) 243 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1) 244 | 245 | " vim:set ft=vim ts=8 sw=2 sts=2: 246 | -------------------------------------------------------------------------------- /bundle/ack.vim/doc/ack.txt: -------------------------------------------------------------------------------- 1 | *ack.txt* Plugin that integrates ack with Vim 2 | 3 | ============================================================================== 4 | Author: Antoine Imbert *ack-author* 5 | License: Same terms as Vim itself (see |license|) 6 | 7 | ============================================================================== 8 | INTRODUCTION *ack* 9 | 10 | This plugin is a front for the Perl module App::Ack. Ack can be used as a 11 | replacement for grep. This plugin will allow you to run ack from vim, and 12 | shows the results in a split window. 13 | 14 | :Ack[!] [options] {pattern} [{directory}] *:Ack* 15 | 16 | Search recursively in {directory} (which defaults to the current 17 | directory) for the {pattern}. Behaves just like the |:grep| command, but 18 | will open the |Quickfix| window for you. If [!] is not given the first 19 | error is jumped to. 20 | 21 | :AckAdd [options] {pattern} [{directory}] *:AckAdd* 22 | 23 | Just like |:Ack|, but instead of making a new list, the matches are 24 | appended to the current |quickfix| list. 25 | 26 | :AckFromSearch [{directory}] *:AckFromSearch* 27 | 28 | Just like |:Ack| but the pattern is from previous search. 29 | 30 | :LAck [options] {pattern} [{directory}] *:LAck* 31 | 32 | Just like |:Ack| but instead of the |quickfix| list, matches are placed in 33 | the current |location-list|. 34 | 35 | :LAckAdd [options] {pattern} [{directory}] *:LAckAdd* 36 | 37 | Just like |:AckAdd| but instead of the |quickfix| list, matches are added 38 | to the current |location-list| 39 | 40 | :AckFile [options] {pattern} [{directory}] *:AckFile* 41 | 42 | Search recursively in {directory} (which defaults to the current 43 | directory) for filenames matching the {pattern}. Behaves just like the 44 | |:grep| command, but will open the |Quickfix| window for you. 45 | 46 | Files containing the search term will be listed in the split window, along 47 | with the line number of the occurrence, once for each occurrence. on 48 | a line in this window will open the file, and place the cursor on the matching 49 | line. 50 | 51 | See http://betterthangrep.com/ for more information. 52 | 53 | ============================================================================== 54 | MAPPINGS *ack-mappings* 55 | 56 | The following keyboard shortcuts are available in the quickfix window: 57 | 58 | o open file (same as enter). 59 | 60 | go preview file (open but maintain focus on ack.vim results). 61 | 62 | t open in a new tab. 63 | 64 | T open in new tab silently. 65 | 66 | v open in vertical split. 67 | 68 | gv open in vertical split silently. 69 | 70 | q close the quickfix window. 71 | -------------------------------------------------------------------------------- /bundle/ack.vim/doc/tags: -------------------------------------------------------------------------------- 1 | :Ack ack.txt /*:Ack* 2 | :AckAdd ack.txt /*:AckAdd* 3 | :AckFile ack.txt /*:AckFile* 4 | :AckFromSearch ack.txt /*:AckFromSearch* 5 | :LAck ack.txt /*:LAck* 6 | :LAckAdd ack.txt /*:LAckAdd* 7 | ack ack.txt /*ack* 8 | ack-author ack.txt /*ack-author* 9 | ack-mappings ack.txt /*ack-mappings* 10 | ack.txt ack.txt /*ack.txt* 11 | -------------------------------------------------------------------------------- /bundle/ack.vim/plugin/ack.vim: -------------------------------------------------------------------------------- 1 | " NOTE: You must, of course, install the ack script 2 | " in your path. 3 | " On Debian / Ubuntu: 4 | " sudo apt-get install ack-grep 5 | " On your vimrc: 6 | " let g:ackprg="ack-grep -H --nocolor --nogroup --column" 7 | " 8 | " With MacPorts: 9 | " sudo port install p5-app-ack 10 | 11 | " Location of the ack utility 12 | if !exists("g:ackprg") 13 | let g:ackprg="ack -H --nocolor --nogroup --column" 14 | endif 15 | 16 | function! s:Ack(cmd, args) 17 | redraw 18 | echo "Searching ..." 19 | 20 | " If no pattern is provided, search for the word under the cursor 21 | if empty(a:args) 22 | let l:grepargs = expand("") 23 | else 24 | let l:grepargs = a:args 25 | end 26 | 27 | " Format, used to manage column jump 28 | if a:cmd =~# '-g$' 29 | let g:ackformat="%f" 30 | else 31 | let g:ackformat="%f:%l:%c:%m" 32 | end 33 | 34 | let grepprg_bak=&grepprg 35 | let grepformat_bak=&grepformat 36 | try 37 | let &grepprg=g:ackprg 38 | let &grepformat=g:ackformat 39 | silent execute a:cmd . " " . l:grepargs 40 | finally 41 | let &grepprg=grepprg_bak 42 | let &grepformat=grepformat_bak 43 | endtry 44 | 45 | if a:cmd =~# '^l' 46 | botright lopen 47 | else 48 | botright copen 49 | endif 50 | 51 | exec "nnoremap q :ccl" 52 | exec "nnoremap t T" 53 | exec "nnoremap T TgT" 54 | exec "nnoremap o " 55 | exec "nnoremap go " 56 | exec "nnoremap v v" 57 | exec "nnoremap gv v" 58 | 59 | " If highlighting is on, highlight the search keyword. 60 | if exists("g:ackhighlight") 61 | let @/=a:args 62 | set hlsearch 63 | end 64 | 65 | redraw! 66 | endfunction 67 | 68 | function! s:AckFromSearch(cmd, args) 69 | let search = getreg('/') 70 | " translate vim regular expression to perl regular expression. 71 | let search = substitute(search,'\(\\<\|\\>\)','\\b','g') 72 | call s:Ack(a:cmd, '"' . search .'" '. a:args) 73 | endfunction 74 | 75 | command! -bang -nargs=* -complete=file Ack call s:Ack('grep',) 76 | command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd', ) 77 | command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep', ) 78 | command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep', ) 79 | command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd', ) 80 | command! -bang -nargs=* -complete=file AckFile call s:Ack('grep -g', ) 81 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/.gitignore: -------------------------------------------------------------------------------- 1 | *.markdown 2 | *.zip 3 | note.txt 4 | tags 5 | .hg* 6 | tmp/* 7 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/bookmarkdir.vim 3 | " Description: Bookmarked directories extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir 9 | fini 10 | en 11 | let g:loaded_ctrlp_bookmarkdir = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#bookmarkdir#init()', 15 | \ 'accept': 'ctrlp#bookmarkdir#accept', 16 | \ 'lname': 'bookmarked dirs', 17 | \ 'sname': 'bkd', 18 | \ 'type': 'tabs', 19 | \ 'opmul': 1, 20 | \ 'nolim': 1, 21 | \ 'wipe': 'ctrlp#bookmarkdir#remove', 22 | \ }) 23 | 24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 25 | " Utilities {{{1 26 | fu! s:getinput(str, ...) 27 | echoh Identifier 28 | cal inputsave() 29 | let input = call('input', a:0 ? [a:str] + a:000 : [a:str]) 30 | cal inputrestore() 31 | echoh None 32 | retu input 33 | endf 34 | 35 | fu! s:cachefile() 36 | if !exists('s:cadir') || !exists('s:cafile') 37 | let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd' 38 | let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt' 39 | en 40 | retu s:cafile 41 | endf 42 | 43 | fu! s:writecache(lines) 44 | cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile) 45 | endf 46 | 47 | fu! s:getbookmarks() 48 | retu ctrlp#utils#readfile(s:cachefile()) 49 | endf 50 | 51 | fu! s:savebookmark(name, cwd) 52 | let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd] 53 | let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0') 54 | cal s:writecache(insert(entries, a:name.' '.a:cwd)) 55 | endf 56 | 57 | fu! s:setentries() 58 | let time = getftime(s:cachefile()) 59 | if !( exists('s:bookmarks') && time == s:bookmarks[0] ) 60 | let s:bookmarks = [time, s:getbookmarks()] 61 | en 62 | endf 63 | 64 | fu! s:parts(str) 65 | let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$') 66 | retu mlist != [] ? mlist[1:2] : ['', ''] 67 | endf 68 | 69 | fu! s:process(entries, type) 70 | retu map(a:entries, 's:modify(v:val, a:type)') 71 | endf 72 | 73 | fu! s:modify(entry, type) 74 | let [name, dir] = s:parts(a:entry) 75 | let dir = fnamemodify(dir, a:type) 76 | retu name.' '.( dir == '' ? '.' : dir ) 77 | endf 78 | 79 | fu! s:msg(name, cwd) 80 | redr 81 | echoh Identifier | echon 'Bookmarked ' | echoh Constant 82 | echon a:name.' ' | echoh Directory | echon a:cwd 83 | echoh None 84 | endf 85 | 86 | fu! s:syntax() 87 | if !ctrlp#nosy() 88 | cal ctrlp#hicheck('CtrlPBookmark', 'Identifier') 89 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') 90 | sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre 91 | sy match CtrlPTabExtra '\zs\t.*\ze$' 92 | en 93 | endf 94 | " Public {{{1 95 | fu! ctrlp#bookmarkdir#init() 96 | cal s:setentries() 97 | cal s:syntax() 98 | retu s:process(copy(s:bookmarks[1]), ':.') 99 | endf 100 | 101 | fu! ctrlp#bookmarkdir#accept(mode, str) 102 | let parts = s:parts(s:modify(a:str, ':p')) 103 | cal call('s:savebookmark', parts) 104 | if a:mode =~ 't\|v\|h' 105 | cal ctrlp#exit() 106 | en 107 | cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!') 108 | if a:mode == 'e' 109 | cal ctrlp#switchtype(0) 110 | cal ctrlp#recordhist() 111 | cal ctrlp#prtclear() 112 | en 113 | endf 114 | 115 | fu! ctrlp#bookmarkdir#add(dir) 116 | let str = 'Directory to bookmark: ' 117 | let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir') 118 | if cwd == '' | retu | en 119 | let cwd = fnamemodify(cwd, ':p') 120 | let name = s:getinput('Bookmark as: ', cwd) 121 | if name == '' | retu | en 122 | let name = tr(name, ' ', ' ') 123 | cal s:savebookmark(name, cwd) 124 | cal s:msg(name, cwd) 125 | endf 126 | 127 | fu! ctrlp#bookmarkdir#remove(entries) 128 | cal s:process(a:entries, ':p') 129 | cal s:writecache(a:entries == [] ? [] : 130 | \ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0')) 131 | cal s:setentries() 132 | retu s:process(copy(s:bookmarks[1]), ':.') 133 | endf 134 | 135 | fu! ctrlp#bookmarkdir#id() 136 | retu s:id 137 | endf 138 | "}}} 139 | 140 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 141 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/buffertag.vim 3 | " Description: Buffer Tag extension 4 | " Maintainer: Kien Nguyen 5 | " Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus 6 | " a few lines from taglist.vim by Yegappan Lakshmanan and from 7 | " buffertag.vim by Takeshi Nishida. 8 | " ============================================================================= 9 | 10 | " Init {{{1 11 | if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag 12 | fini 13 | en 14 | let g:loaded_ctrlp_buftag = 1 15 | 16 | cal add(g:ctrlp_ext_vars, { 17 | \ 'init': 'ctrlp#buffertag#init(s:crfile)', 18 | \ 'accept': 'ctrlp#buffertag#accept', 19 | \ 'lname': 'buffer tags', 20 | \ 'sname': 'bft', 21 | \ 'exit': 'ctrlp#buffertag#exit()', 22 | \ 'type': 'tabs', 23 | \ 'opts': 'ctrlp#buffertag#opts()', 24 | \ }) 25 | 26 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 27 | 28 | let [s:pref, s:opts] = ['g:ctrlp_buftag_', { 29 | \ 'systemenc': ['s:enc', &enc], 30 | \ 'ctags_bin': ['s:bin', ''], 31 | \ 'types': ['s:usr_types', {}], 32 | \ }] 33 | 34 | let s:bins = [ 35 | \ 'ctags-exuberant', 36 | \ 'exuberant-ctags', 37 | \ 'exctags', 38 | \ '/usr/local/bin/ctags', 39 | \ '/opt/local/bin/ctags', 40 | \ 'ctags', 41 | \ 'ctags.exe', 42 | \ 'tags', 43 | \ ] 44 | 45 | let s:types = { 46 | \ 'asm' : '%sasm%sasm%sdlmt', 47 | \ 'aspperl': '%sasp%sasp%sfsv', 48 | \ 'aspvbs' : '%sasp%sasp%sfsv', 49 | \ 'awk' : '%sawk%sawk%sf', 50 | \ 'beta' : '%sbeta%sbeta%sfsv', 51 | \ 'c' : '%sc%sc%sdgsutvf', 52 | \ 'cpp' : '%sc++%sc++%snvdtcgsuf', 53 | \ 'cs' : '%sc#%sc#%sdtncEgsipm', 54 | \ 'cobol' : '%scobol%scobol%sdfgpPs', 55 | \ 'eiffel' : '%seiffel%seiffel%scf', 56 | \ 'erlang' : '%serlang%serlang%sdrmf', 57 | \ 'expect' : '%stcl%stcl%scfp', 58 | \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs', 59 | \ 'html' : '%shtml%shtml%saf', 60 | \ 'java' : '%sjava%sjava%spcifm', 61 | \ 'javascript': '%sjavascript%sjavascript%sf', 62 | \ 'lisp' : '%slisp%slisp%sf', 63 | \ 'lua' : '%slua%slua%sf', 64 | \ 'make' : '%smake%smake%sm', 65 | \ 'pascal' : '%spascal%spascal%sfp', 66 | \ 'perl' : '%sperl%sperl%sclps', 67 | \ 'php' : '%sphp%sphp%scdvf', 68 | \ 'python' : '%spython%spython%scmf', 69 | \ 'rexx' : '%srexx%srexx%ss', 70 | \ 'ruby' : '%sruby%sruby%scfFm', 71 | \ 'scheme' : '%sscheme%sscheme%ssf', 72 | \ 'sh' : '%ssh%ssh%sf', 73 | \ 'csh' : '%ssh%ssh%sf', 74 | \ 'zsh' : '%ssh%ssh%sf', 75 | \ 'slang' : '%sslang%sslang%snf', 76 | \ 'sml' : '%ssml%ssml%secsrtvf', 77 | \ 'sql' : '%ssql%ssql%scFPrstTvfp', 78 | \ 'tcl' : '%stcl%stcl%scfmp', 79 | \ 'vera' : '%svera%svera%scdefgmpPtTvx', 80 | \ 'verilog': '%sverilog%sverilog%smcPertwpvf', 81 | \ 'vim' : '%svim%svim%savf', 82 | \ 'yacc' : '%syacc%syacc%sl', 83 | \ } 84 | 85 | cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")') 86 | 87 | if executable('jsctags') 88 | cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } }) 89 | en 90 | 91 | fu! ctrlp#buffertag#opts() 92 | for [ke, va] in items(s:opts) 93 | let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1] 94 | endfo 95 | " Ctags bin 96 | if empty(s:bin) 97 | for bin in s:bins | if executable(bin) 98 | let s:bin = bin 99 | brea 100 | en | endfo 101 | el 102 | let s:bin = expand(s:bin, 1) 103 | en 104 | " Types 105 | cal extend(s:types, s:usr_types) 106 | endf 107 | " Utilities {{{1 108 | fu! s:validfile(fname, ftype) 109 | if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname) 110 | \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en 111 | retu 0 112 | endf 113 | 114 | fu! s:exectags(cmd) 115 | if exists('+ssl') 116 | let [ssl, &ssl] = [&ssl, 0] 117 | en 118 | if &sh =~ 'cmd\.exe' 119 | let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c'] 120 | en 121 | let output = system(a:cmd) 122 | if &sh =~ 'cmd\.exe' 123 | let [&sxq, &shcf] = [sxq, shcf] 124 | en 125 | if exists('+ssl') 126 | let &ssl = ssl 127 | en 128 | retu output 129 | endf 130 | 131 | fu! s:exectagsonfile(fname, ftype) 132 | let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype] 133 | if type(s:types[ft]) == 1 134 | let ags .= s:types[ft] 135 | let bin = s:bin 136 | elsei type(s:types[ft]) == 4 137 | let ags = s:types[ft]['args'] 138 | let bin = expand(s:types[ft]['bin'], 1) 139 | en 140 | if empty(bin) | retu '' | en 141 | let cmd = s:esctagscmd(bin, ags, a:fname) 142 | if empty(cmd) | retu '' | en 143 | let output = s:exectags(cmd) 144 | if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en 145 | retu output 146 | endf 147 | 148 | fu! s:esctagscmd(bin, args, ...) 149 | if exists('+ssl') 150 | let [ssl, &ssl] = [&ssl, 0] 151 | en 152 | let fname = a:0 ? shellescape(a:1) : '' 153 | let cmd = shellescape(a:bin).' '.a:args.' '.fname 154 | if &sh =~ 'cmd\.exe' 155 | let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g') 156 | en 157 | if exists('+ssl') 158 | let &ssl = ssl 159 | en 160 | if has('iconv') 161 | let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc 162 | let cmd = iconv(cmd, &enc, last) 163 | en 164 | retu cmd 165 | endf 166 | 167 | fu! s:process(fname, ftype) 168 | if !s:validfile(a:fname, a:ftype) | retu [] | endif 169 | let ftime = getftime(a:fname) 170 | if has_key(g:ctrlp_buftags, a:fname) 171 | \ && g:ctrlp_buftags[a:fname]['time'] >= ftime 172 | let lines = g:ctrlp_buftags[a:fname]['lines'] 173 | el 174 | let data = s:exectagsonfile(a:fname, a:ftype) 175 | let [raw, lines] = [split(data, '\n\+'), []] 176 | for line in raw 177 | if line !~# '^!_TAG_' && len(split(line, ';"')) == 2 178 | let parsed_line = s:parseline(line) 179 | if parsed_line != '' 180 | cal add(lines, parsed_line) 181 | en 182 | en 183 | endfo 184 | let cache = { a:fname : { 'time': ftime, 'lines': lines } } 185 | cal extend(g:ctrlp_buftags, cache) 186 | en 187 | retu lines 188 | endf 189 | 190 | fu! s:parseline(line) 191 | let vals = matchlist(a:line, 192 | \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)') 193 | if vals == [] | retu '' | en 194 | let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')] 195 | retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] 196 | endf 197 | 198 | fu! s:syntax() 199 | if !ctrlp#nosy() 200 | cal ctrlp#hicheck('CtrlPTagKind', 'Title') 201 | cal ctrlp#hicheck('CtrlPBufName', 'Directory') 202 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') 203 | sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|' 204 | sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|' 205 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind 206 | en 207 | endf 208 | 209 | fu! s:chknearby(pat) 210 | if match(getline('.'), a:pat) < 0 211 | let [int, forw, maxl] = [1, 1, line('$')] 212 | wh !search(a:pat, 'W'.( forw ? '' : 'b' )) 213 | if !forw 214 | if int > maxl | brea | en 215 | let int += int 216 | en 217 | let forw = !forw 218 | endw 219 | en 220 | endf 221 | " Public {{{1 222 | fu! ctrlp#buffertag#init(fname) 223 | let bufs = exists('s:btmode') && s:btmode 224 | \ ? filter(ctrlp#buffers(), 'filereadable(v:val)') 225 | \ : [exists('s:bufname') ? s:bufname : a:fname] 226 | let lines = [] 227 | for each in bufs 228 | let bname = fnamemodify(each, ':p') 229 | let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '') 230 | cal extend(lines, s:process(bname, tftype)) 231 | endfo 232 | cal s:syntax() 233 | retu lines 234 | endf 235 | 236 | fu! ctrlp#buffertag#accept(mode, str) 237 | let vals = matchlist(a:str, 238 | \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$') 239 | let bufnr = str2nr(get(vals, 1)) 240 | if bufnr 241 | cal ctrlp#acceptfile(a:mode, bufnr) 242 | exe 'norm!' str2nr(get(vals, 2, line('.'))).'G' 243 | cal s:chknearby('\V\C'.get(vals, 3, '')) 244 | sil! norm! zvzz 245 | en 246 | endf 247 | 248 | fu! ctrlp#buffertag#cmd(mode, ...) 249 | let s:btmode = a:mode 250 | if a:0 && !empty(a:1) 251 | let s:bufname = fnamemodify(a:1, ':p') 252 | en 253 | retu s:id 254 | endf 255 | 256 | fu! ctrlp#buffertag#exit() 257 | unl! s:btmode s:bufname 258 | endf 259 | "}}} 260 | 261 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 262 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/changes.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/changes.vim 3 | " Description: Change list extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes 9 | fini 10 | en 11 | let g:loaded_ctrlp_changes = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)', 15 | \ 'accept': 'ctrlp#changes#accept', 16 | \ 'lname': 'changes', 17 | \ 'sname': 'chs', 18 | \ 'exit': 'ctrlp#changes#exit()', 19 | \ 'type': 'tabe', 20 | \ 'sort': 0, 21 | \ 'nolim': 1, 22 | \ }) 23 | 24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 25 | " Utilities {{{1 26 | fu! s:changelist(bufnr) 27 | sil! exe 'noa hid b' a:bufnr 28 | redi => result 29 | sil! changes 30 | redi END 31 | retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")') 32 | endf 33 | 34 | fu! s:process(clines, ...) 35 | let [clines, evas] = [[], []] 36 | for each in a:clines 37 | let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$') 38 | if !empty(parts) 39 | if parts[3] == '' | let parts[3] = ' ' | en 40 | cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|') 41 | en 42 | endfo 43 | retu reverse(filter(clines, 'count(clines, v:val) == 1')) 44 | endf 45 | 46 | fu! s:syntax() 47 | if !ctrlp#nosy() 48 | cal ctrlp#hicheck('CtrlPBufName', 'Directory') 49 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') 50 | sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$' 51 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName 52 | en 53 | endf 54 | " Public {{{1 55 | fu! ctrlp#changes#init(original_bufnr, bufnr) 56 | let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr 57 | let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr] 58 | cal filter(bufs, 'v:val > 0') 59 | let [swb, &swb] = [&swb, ''] 60 | let lines = [] 61 | for each in bufs 62 | let bname = bufname(each) 63 | let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':t') 64 | cal extend(lines, s:process(s:changelist(each), each, fnamet)) 65 | endfo 66 | sil! exe 'noa hid b' a:original_bufnr 67 | let &swb = swb 68 | cal ctrlp#syntax() 69 | cal s:syntax() 70 | retu lines 71 | endf 72 | 73 | fu! ctrlp#changes#accept(mode, str) 74 | let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$') 75 | let bufnr = str2nr(get(info, 1)) 76 | if bufnr 77 | cal ctrlp#acceptfile(a:mode, bufnr) 78 | cal cursor(get(info, 2), get(info, 3)) 79 | sil! norm! zvzz 80 | en 81 | endf 82 | 83 | fu! ctrlp#changes#cmd(mode, ...) 84 | let s:clmode = a:mode 85 | if a:0 && !empty(a:1) 86 | let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$') 87 | en 88 | retu s:id 89 | endf 90 | 91 | fu! ctrlp#changes#exit() 92 | unl! s:clmode s:bufnr 93 | endf 94 | "}}} 95 | 96 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 97 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/dir.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/dir.vim 3 | " Description: Directory extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir 9 | fini 10 | en 11 | let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0] 12 | 13 | let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching'] 14 | 15 | cal add(g:ctrlp_ext_vars, { 16 | \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')', 17 | \ 'accept': 'ctrlp#dir#accept', 18 | \ 'lname': 'dirs', 19 | \ 'sname': 'dir', 20 | \ 'type': 'path', 21 | \ 'specinput': 1, 22 | \ }) 23 | 24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 25 | 26 | let s:dircounts = {} 27 | " Utilities {{{1 28 | fu! s:globdirs(dirs, depth) 29 | let entries = split(globpath(a:dirs, s:glob), "\n") 30 | let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1] 31 | cal extend(g:ctrlp_alldirs, dirs) 32 | let nr = len(g:ctrlp_alldirs) 33 | if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth 34 | sil! cal ctrlp#progress(nr) 35 | cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")') 36 | cal s:globdirs(join(dirs, ','), depth) 37 | en 38 | endf 39 | 40 | fu! s:max(len, max) 41 | retu a:max && a:len > a:max 42 | endf 43 | 44 | fu! s:nocache() 45 | retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching ) 46 | endf 47 | " Public {{{1 48 | fu! ctrlp#dir#init(...) 49 | let s:cwd = getcwd() 50 | for each in range(len(s:ars)) 51 | let {s:ars[each]} = a:{each + 1} 52 | endfo 53 | let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir' 54 | let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir') 55 | if g:ctrlp_newdir || s:nocache() || !filereadable(cafile) 56 | let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []] 57 | if !ctrlp#igncwd(s:cwd) 58 | cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0) 59 | en 60 | cal ctrlp#rmbasedir(g:ctrlp_alldirs) 61 | if len(g:ctrlp_alldirs) <= s:compare_lim 62 | cal sort(g:ctrlp_alldirs, 'ctrlp#complen') 63 | en 64 | cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile) 65 | let g:ctrlp_newdir = 0 66 | el 67 | if !( exists('s:initcwd') && s:initcwd == s:cwd ) 68 | let s:initcwd = s:cwd 69 | let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile) 70 | en 71 | en 72 | cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) }) 73 | retu g:ctrlp_alldirs 74 | endf 75 | 76 | fu! ctrlp#dir#accept(mode, str) 77 | let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str 78 | if a:mode =~ 't\|v\|h' 79 | cal ctrlp#exit() 80 | en 81 | cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!') 82 | if a:mode == 'e' 83 | sil! cal ctrlp#statusline() 84 | cal ctrlp#setlines(s:id) 85 | cal ctrlp#recordhist() 86 | cal ctrlp#prtclear() 87 | en 88 | endf 89 | 90 | fu! ctrlp#dir#id() 91 | retu s:id 92 | endf 93 | "}}} 94 | 95 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 96 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/line.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/line.vim 3 | " Description: Line extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line 9 | fini 10 | en 11 | let g:loaded_ctrlp_line = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#line#init()', 15 | \ 'accept': 'ctrlp#line#accept', 16 | \ 'lname': 'lines', 17 | \ 'sname': 'lns', 18 | \ 'type': 'tabe', 19 | \ }) 20 | 21 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 22 | " Utilities {{{1 23 | fu! s:syntax() 24 | if !ctrlp#nosy() 25 | cal ctrlp#hicheck('CtrlPBufName', 'Directory') 26 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') 27 | sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$' 28 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName 29 | en 30 | endf 31 | " Public {{{1 32 | fu! ctrlp#line#init() 33 | let [bufs, lines] = [ctrlp#buffers('id'), []] 34 | for bufnr in bufs 35 | let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)] 36 | if lfb == [] && bufn != '' 37 | let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p')) 38 | en 39 | cal map(lfb, 'tr(v:val, '' '', '' '')') 40 | let [linenr, len_lfb] = [1, len(lfb)] 41 | let buft = bufn == '' ? '[No Name]' : fnamemodify(bufn, ':t') 42 | wh linenr <= len_lfb 43 | let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|' 44 | let linenr += 1 45 | endw 46 | cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')) 47 | endfo 48 | cal s:syntax() 49 | retu lines 50 | endf 51 | 52 | fu! ctrlp#line#accept(mode, str) 53 | let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$') 54 | let bufnr = str2nr(get(info, 1)) 55 | if bufnr 56 | cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2)) 57 | en 58 | endf 59 | 60 | fu! ctrlp#line#id() 61 | retu s:id 62 | endf 63 | "}}} 64 | 65 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 66 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/mixed.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/mixed.vim 3 | " Description: Mixing Files + MRU + Buffers 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed 9 | fini 10 | en 11 | let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0] 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#mixed#init(s:compare_lim)', 15 | \ 'accept': 'ctrlp#acceptfile', 16 | \ 'lname': 'fil + mru + buf', 17 | \ 'sname': 'mix', 18 | \ 'type': 'path', 19 | \ 'opmul': 1, 20 | \ 'specinput': 1, 21 | \ }) 22 | 23 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 24 | " Utilities {{{1 25 | fu! s:newcache(cwd) 26 | if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en 27 | retu g:ctrlp_allmixes['cwd'] != a:cwd 28 | \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile()) 29 | \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile()) 30 | \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs()) 31 | endf 32 | 33 | fu! s:getnewmix(cwd, clim) 34 | if g:ctrlp_newmix 35 | cal ctrlp#mrufiles#refresh('raw') 36 | let g:ctrlp_newcache = 1 37 | en 38 | let g:ctrlp_lines = copy(ctrlp#files()) 39 | cal ctrlp#progress('Mixing...') 40 | let mrufs = copy(ctrlp#mrufiles#list('raw')) 41 | if exists('+ssl') && &ssl 42 | cal map(mrufs, 'tr(v:val, "\\", "/")') 43 | en 44 | let allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")') 45 | let [bufs, ubufs] = [[], []] 46 | for each in allbufs 47 | cal add(filereadable(each) ? bufs : ubufs, each) 48 | endfo 49 | let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0') 50 | if len(mrufs) > len(g:ctrlp_lines) 51 | cal filter(mrufs, 'stridx(v:val, a:cwd)') 52 | el 53 | let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)') 54 | let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs) 55 | for each in cwd_mrufs 56 | let id = index(g:ctrlp_lines, each) 57 | if id >= 0 | cal remove(g:ctrlp_lines, id) | en 58 | endfo 59 | en 60 | let mrufs += ubufs 61 | cal map(mrufs, 'fnamemodify(v:val, ":.")') 62 | let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines) 63 | \ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines 64 | if len(g:ctrlp_lines) <= a:clim 65 | cal sort(g:ctrlp_lines, 'ctrlp#complen') 66 | en 67 | let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()), 68 | \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd, 69 | \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines } 70 | endf 71 | " Public {{{1 72 | fu! ctrlp#mixed#init(clim) 73 | let cwd = getcwd() 74 | if s:newcache(cwd) 75 | cal s:getnewmix(cwd, a:clim) 76 | el 77 | let g:ctrlp_lines = g:ctrlp_allmixes['data'] 78 | en 79 | let g:ctrlp_newmix = 0 80 | retu g:ctrlp_lines 81 | endf 82 | 83 | fu! ctrlp#mixed#id() 84 | retu s:id 85 | endf 86 | "}}} 87 | 88 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 89 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/mrufiles.vim 3 | " Description: Most Recently Used Files extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Static variables {{{1 8 | let [s:mrbs, s:mrufs] = [[], []] 9 | 10 | fu! ctrlp#mrufiles#opts() 11 | let [pref, opts] = ['g:ctrlp_mruf_', { 12 | \ 'max': ['s:max', 250], 13 | \ 'include': ['s:in', ''], 14 | \ 'exclude': ['s:ex', ''], 15 | \ 'case_sensitive': ['s:cseno', 1], 16 | \ 'relative': ['s:re', 0], 17 | \ 'save_on_update': ['s:soup', 1], 18 | \ }] 19 | for [ke, va] in items(opts) 20 | let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]] 21 | endfo 22 | endf 23 | cal ctrlp#mrufiles#opts() 24 | " Utilities {{{1 25 | fu! s:excl(fn) 26 | retu !empty({s:ex}) && a:fn =~# {s:ex} 27 | endf 28 | 29 | fu! s:mergelists() 30 | let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile()) 31 | cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0') 32 | let mrufs = s:mrufs + diskmrufs 33 | retu s:chop(mrufs) 34 | endf 35 | 36 | fu! s:chop(mrufs) 37 | if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en 38 | retu a:mrufs 39 | endf 40 | 41 | fu! s:reformat(mrufs, ...) 42 | let cwd = getcwd() 43 | let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : '' 44 | if {s:re} 45 | let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd 46 | cal filter(a:mrufs, '!stridx(v:val, cwd)') 47 | en 48 | if a:0 && a:1 == 'raw' | retu a:mrufs | en 49 | let idx = strlen(cwd) 50 | if exists('+ssl') && &ssl 51 | let cwd = tr(cwd, '\', '/') 52 | cal map(a:mrufs, 'tr(v:val, "\\", "/")') 53 | en 54 | retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val') 55 | endf 56 | 57 | fu! s:record(bufnr) 58 | if s:locked | retu | en 59 | let bufnr = a:bufnr + 0 60 | let bufname = bufname(bufnr) 61 | if bufnr > 0 && !empty(bufname) 62 | cal filter(s:mrbs, 'v:val != bufnr') 63 | cal insert(s:mrbs, bufnr) 64 | cal s:addtomrufs(bufname) 65 | en 66 | endf 67 | 68 | fu! s:addtomrufs(fname) 69 | let fn = fnamemodify(a:fname, ':p') 70 | let fn = exists('+ssl') ? tr(fn, '/', '\') : fn 71 | if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) 72 | \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu 73 | en 74 | let idx = index(s:mrufs, fn, 0, !{s:cseno}) 75 | if idx 76 | cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn') 77 | cal insert(s:mrufs, fn) 78 | if {s:soup} && idx < 0 79 | cal s:savetofile(s:mergelists()) 80 | en 81 | en 82 | endf 83 | 84 | fu! s:savetofile(mrufs) 85 | cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile) 86 | endf 87 | " Public {{{1 88 | fu! ctrlp#mrufiles#refresh(...) 89 | let mrufs = s:mergelists() 90 | cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)') 91 | if exists('+ssl') 92 | cal map(mrufs, 'tr(v:val, "/", "\\")') 93 | cal map(s:mrufs, 'tr(v:val, "/", "\\")') 94 | let cond = 'count(mrufs, v:val, !{s:cseno}) == 1' 95 | cal filter(mrufs, cond) 96 | cal filter(s:mrufs, cond) 97 | en 98 | cal s:savetofile(mrufs) 99 | retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs) 100 | endf 101 | 102 | fu! ctrlp#mrufiles#remove(files) 103 | let mrufs = [] 104 | if a:files != [] 105 | let mrufs = s:mergelists() 106 | let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0' 107 | cal filter(mrufs, cond) 108 | cal filter(s:mrufs, cond) 109 | en 110 | cal s:savetofile(mrufs) 111 | retu s:reformat(mrufs) 112 | endf 113 | 114 | fu! ctrlp#mrufiles#add(fn) 115 | if !empty(a:fn) 116 | cal s:addtomrufs(a:fn) 117 | en 118 | endf 119 | 120 | fu! ctrlp#mrufiles#list(...) 121 | retu a:0 ? a:1 == 'raw' ? s:reformat(s:mergelists(), a:1) : 0 122 | \ : s:reformat(s:mergelists()) 123 | endf 124 | 125 | fu! ctrlp#mrufiles#bufs() 126 | retu s:mrbs 127 | endf 128 | 129 | fu! ctrlp#mrufiles#cachefile() 130 | if !exists('s:cadir') || !exists('s:cafile') 131 | let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru' 132 | let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt' 133 | en 134 | retu s:cafile 135 | endf 136 | 137 | fu! ctrlp#mrufiles#init() 138 | if !has('autocmd') | retu | en 139 | let s:locked = 0 140 | aug CtrlPMRUF 141 | au! 142 | au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('', 1)) 143 | au QuickFixCmdPre *vimgrep* let s:locked = 1 144 | au QuickFixCmdPost *vimgrep* let s:locked = 0 145 | au VimLeavePre * cal s:savetofile(s:mergelists()) 146 | aug END 147 | endf 148 | "}}} 149 | 150 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 151 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/quickfix.vim 3 | " Description: Quickfix extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix 9 | fini 10 | en 11 | let g:loaded_ctrlp_quickfix = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#quickfix#init()', 15 | \ 'accept': 'ctrlp#quickfix#accept', 16 | \ 'lname': 'quickfix', 17 | \ 'sname': 'qfx', 18 | \ 'type': 'line', 19 | \ 'sort': 0, 20 | \ 'nolim': 1, 21 | \ }) 22 | 23 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 24 | 25 | fu! s:lineout(dict) 26 | retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'], 27 | \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S')) 28 | endf 29 | " Utilities {{{1 30 | fu! s:syntax() 31 | if !ctrlp#nosy() 32 | cal ctrlp#hicheck('CtrlPqfLineCol', 'Search') 33 | sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|' 34 | en 35 | endf 36 | " Public {{{1 37 | fu! ctrlp#quickfix#init() 38 | cal s:syntax() 39 | retu map(getqflist(), 's:lineout(v:val)') 40 | endf 41 | 42 | fu! ctrlp#quickfix#accept(mode, str) 43 | let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|') 44 | if vals == [] || vals[1] == '' | retu | en 45 | cal ctrlp#acceptfile(a:mode, vals[1]) 46 | let cur_pos = getpos('.')[1:2] 47 | if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)') 48 | mark ' 49 | en 50 | cal cursor(vals[2], vals[3]) 51 | sil! norm! zvzz 52 | endf 53 | 54 | fu! ctrlp#quickfix#id() 55 | retu s:id 56 | endf 57 | "}}} 58 | 59 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 60 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/rtscript.vim 3 | " Description: Runtime scripts extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript 9 | fini 10 | en 11 | let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#rtscript#init(s:caching)', 15 | \ 'accept': 'ctrlp#acceptfile', 16 | \ 'lname': 'runtime scripts', 17 | \ 'sname': 'rts', 18 | \ 'type': 'path', 19 | \ 'opmul': 1, 20 | \ }) 21 | 22 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 23 | 24 | let s:filecounts = {} 25 | " Utilities {{{1 26 | fu! s:nocache() 27 | retu g:ctrlp_newrts || 28 | \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching ) 29 | endf 30 | " Public {{{1 31 | fu! ctrlp#rtscript#init(caching) 32 | let [s:caching, s:cwd] = [a:caching, getcwd()] 33 | if s:nocache() || 34 | \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp ) 35 | sil! cal ctrlp#progress('Indexing...') 36 | let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n") 37 | cal filter(entries, 'count(entries, v:val) == 1') 38 | let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1] 39 | el 40 | let [entries, results] = g:ctrlp_rtscache[2:3] 41 | en 42 | if s:nocache() || 43 | \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] ) 44 | if !exists('echoed') 45 | sil! cal ctrlp#progress('Processing...') 46 | en 47 | let results = map(copy(entries), 'fnamemodify(v:val, '':.'')') 48 | en 49 | let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0] 50 | cal extend(s:filecounts, { s:cwd : len(results) }) 51 | retu results 52 | endf 53 | 54 | fu! ctrlp#rtscript#id() 55 | retu s:id 56 | endf 57 | "}}} 58 | 59 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 60 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/tag.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/tag.vim 3 | " Description: Tag file extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag 9 | fini 10 | en 11 | let g:loaded_ctrlp_tag = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#tag#init()', 15 | \ 'accept': 'ctrlp#tag#accept', 16 | \ 'lname': 'tags', 17 | \ 'sname': 'tag', 18 | \ 'enter': 'ctrlp#tag#enter()', 19 | \ 'type': 'tabs', 20 | \ }) 21 | 22 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 23 | " Utilities {{{1 24 | fu! s:findcount(str) 25 | let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$') 26 | let tgs = taglist('^'.tg.'$') 27 | if len(tgs) < 2 28 | retu [1, 1] 29 | en 30 | let bname = fnamemodify(bufname('%'), ':p') 31 | let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1) 32 | let [fnd, ct, pos, idx] = [0, 0, 0, 0] 33 | wh idx < len(tgs) 34 | if bname == fnamemodify(tgs[idx]["filename"], ':p') 35 | cal insert(tgs, remove(tgs, idx)) 36 | brea 37 | en 38 | let idx += 1 39 | endw 40 | for each in tgs 41 | let ct += 1 42 | let fulname = fnamemodify(each["filename"], ':p') 43 | if stridx(fulname, fname) >= 0 44 | \ && strlen(fname) + stridx(fulname, fname) == strlen(fulname) 45 | let fnd += 1 46 | let pos = ct 47 | en 48 | if fnd > 1 | brea | en 49 | endfo 50 | retu [fnd, pos] 51 | endf 52 | 53 | fu! s:filter(tags) 54 | let nr = 0 55 | wh 0 < 1 56 | if a:tags == [] | brea | en 57 | if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_' 58 | let nr += 1 59 | con 60 | en 61 | if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr 62 | cal remove(a:tags, nr) 63 | el 64 | brea 65 | en 66 | endw 67 | retu a:tags 68 | endf 69 | 70 | fu! s:syntax() 71 | if !ctrlp#nosy() 72 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') 73 | sy match CtrlPTabExtra '\zs\t.*\ze$' 74 | en 75 | endf 76 | " Public {{{1 77 | fu! ctrlp#tag#init() 78 | if empty(s:tagfiles) | retu [] | en 79 | let g:ctrlp_alltags = [] 80 | let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1')) 81 | for each in tagfiles 82 | let alltags = s:filter(ctrlp#utils#readfile(each)) 83 | cal extend(g:ctrlp_alltags, alltags) 84 | endfo 85 | cal s:syntax() 86 | retu g:ctrlp_alltags 87 | endf 88 | 89 | fu! ctrlp#tag#accept(mode, str) 90 | cal ctrlp#exit() 91 | let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t') 92 | let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)] 93 | let cmds = { 94 | \ 't': ['tab sp', 'tab stj'], 95 | \ 'h': ['sp', 'stj'], 96 | \ 'v': ['vs', 'vert stj'], 97 | \ 'e': ['', 'tj'], 98 | \ } 99 | let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1] 100 | let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw) 101 | \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd 102 | let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd 103 | if fnd[0] == 1 104 | if cmd != '' 105 | exe cmd 106 | en 107 | let save_cst = &cst 108 | set cst& 109 | cal feedkeys(":".fnd[1]."ta ".tg."\r", 'nt') 110 | let &cst = save_cst 111 | el 112 | cal feedkeys(":".cmd." ".tg."\r", 'nt') 113 | en 114 | cal ctrlp#setlcdir() 115 | endf 116 | 117 | fu! ctrlp#tag#id() 118 | retu s:id 119 | endf 120 | 121 | fu! ctrlp#tag#enter() 122 | let tfs = tagfiles() 123 | let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'), 124 | \ 'filereadable(v:val)') : [] 125 | endf 126 | "}}} 127 | 128 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 129 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/undo.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/undo.vim 3 | " Description: Undo extension 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Init {{{1 8 | if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo ) 9 | fini 10 | en 11 | let g:loaded_ctrlp_undo = 1 12 | 13 | cal add(g:ctrlp_ext_vars, { 14 | \ 'init': 'ctrlp#undo#init()', 15 | \ 'accept': 'ctrlp#undo#accept', 16 | \ 'lname': 'undo', 17 | \ 'sname': 'udo', 18 | \ 'enter': 'ctrlp#undo#enter()', 19 | \ 'exit': 'ctrlp#undo#exit()', 20 | \ 'type': 'line', 21 | \ 'sort': 0, 22 | \ 'nolim': 1, 23 | \ }) 24 | 25 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) 26 | 27 | let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks', 28 | \ 'months', 'years'], '" ".v:val." ago"') 29 | " Utilities {{{1 30 | fu! s:getundo() 31 | if exists('*undotree') 32 | \ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) ) 33 | retu [1, undotree()] 34 | el 35 | redi => result 36 | sil! undol 37 | redi END 38 | retu [0, split(result, "\n")[1:]] 39 | en 40 | endf 41 | 42 | fu! s:flatten(tree, cur) 43 | let flatdict = {} 44 | for each in a:tree 45 | let saved = has_key(each, 'save') ? 'saved' : '' 46 | let current = each['seq'] == a:cur ? 'current' : '' 47 | cal extend(flatdict, { each['seq'] : [each['time'], saved, current] }) 48 | if has_key(each, 'alt') 49 | cal extend(flatdict, s:flatten(each['alt'], a:cur)) 50 | en 51 | endfo 52 | retu flatdict 53 | endf 54 | 55 | fu! s:elapsed(nr) 56 | let [text, time] = [s:text, localtime() - a:nr] 57 | let mins = time / 60 58 | let hrs = time / 3600 59 | let days = time / 86400 60 | let wks = time / 604800 61 | let mons = time / 2592000 62 | let yrs = time / 31536000 63 | if yrs > 1 64 | retu yrs.text[7] 65 | elsei mons > 1 66 | retu mons.text[6] 67 | elsei wks > 1 68 | retu wks.text[5] 69 | elsei days > 1 70 | retu days.text[4] 71 | elsei hrs > 1 72 | retu hrs.text[3] 73 | elsei mins > 1 74 | retu mins.text[2] 75 | elsei time == 1 76 | retu time.text[0] 77 | elsei time < 120 78 | retu time.text[1] 79 | en 80 | endf 81 | 82 | fu! s:syntax() 83 | if ctrlp#nosy() | retu | en 84 | for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String', 85 | \ 'Sv': 'Comment', 'Po': 'Title'}) 86 | cal ctrlp#hicheck('CtrlPUndo'.ke, va) 87 | endfo 88 | sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+' 89 | sy match CtrlPUndoBr '\[\|\]' 90 | sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr 91 | sy match CtrlPUndoSv 'saved' 92 | sy match CtrlPUndoPo 'current' 93 | endf 94 | 95 | fu! s:dict2list(dict) 96 | for ke in keys(a:dict) 97 | let a:dict[ke][0] = s:elapsed(a:dict[ke][0]) 98 | endfo 99 | retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')') 100 | endf 101 | 102 | fu! s:compval(...) 103 | retu a:2[0] - a:1[0] 104 | endf 105 | 106 | fu! s:format(...) 107 | let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : '' 108 | let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : '' 109 | retu a:1[1][0].' ['.a:1[0].']'.saved.current 110 | endf 111 | 112 | fu! s:formatul(...) 113 | let parts = matchlist(a:1, 114 | \ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$') 115 | retu parts == [] ? '----' 116 | \ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' ) 117 | endf 118 | " Public {{{1 119 | fu! ctrlp#undo#init() 120 | let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1] 121 | if empty(entries) | retu [] | en 122 | if !exists('s:lines') 123 | if s:undos[0] 124 | let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur'])) 125 | let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)') 126 | el 127 | let s:lines = map(reverse(entries), 's:formatul(v:val)') 128 | en 129 | en 130 | cal s:syntax() 131 | retu s:lines 132 | endf 133 | 134 | fu! ctrlp#undo#accept(mode, str) 135 | let undon = matchstr(a:str, '\[\zs\d\+\ze\]') 136 | if empty(undon) | retu | en 137 | cal ctrlp#exit() 138 | exe 'u' undon 139 | endf 140 | 141 | fu! ctrlp#undo#id() 142 | retu s:id 143 | endf 144 | 145 | fu! ctrlp#undo#enter() 146 | let s:undos = s:getundo() 147 | endf 148 | 149 | fu! ctrlp#undo#exit() 150 | unl! s:lines 151 | endf 152 | "}}} 153 | 154 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 155 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/autoload/ctrlp/utils.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: autoload/ctrlp/utils.vim 3 | " Description: Utilities 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | 7 | " Static variables {{{1 8 | fu! ctrlp#utils#lash() 9 | retu &ssl || !exists('+ssl') ? '/' : '\' 10 | endf 11 | 12 | fu! s:lash(...) 13 | retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : '' 14 | endf 15 | 16 | fu! ctrlp#utils#opts() 17 | let s:lash = ctrlp#utils#lash() 18 | let usrhome = $HOME . s:lash( $HOME ) 19 | let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache' 20 | let cadir = isdirectory(usrhome.'.ctrlp_cache') 21 | \ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp' 22 | if exists('g:ctrlp_cache_dir') 23 | let cadir = expand(g:ctrlp_cache_dir, 1) 24 | if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache') 25 | let cadir = cadir.s:lash(cadir).'.ctrlp_cache' 26 | en 27 | en 28 | let s:cache_dir = cadir 29 | endf 30 | cal ctrlp#utils#opts() 31 | 32 | let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') ) 33 | " Files and Directories {{{1 34 | fu! ctrlp#utils#cachedir() 35 | retu s:cache_dir 36 | endf 37 | 38 | fu! ctrlp#utils#cachefile(...) 39 | let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()] 40 | let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt' 41 | retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file 42 | endf 43 | 44 | fu! ctrlp#utils#readfile(file) 45 | if filereadable(a:file) 46 | let data = readfile(a:file) 47 | if empty(data) || type(data) != 3 48 | unl data 49 | let data = [] 50 | en 51 | retu data 52 | en 53 | retu [] 54 | endf 55 | 56 | fu! ctrlp#utils#mkdir(dir) 57 | if exists('*mkdir') && !isdirectory(a:dir) 58 | sil! cal mkdir(a:dir, 'p') 59 | en 60 | retu a:dir 61 | endf 62 | 63 | fu! ctrlp#utils#writecache(lines, ...) 64 | if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir)) 65 | sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile()) 66 | en 67 | endf 68 | 69 | fu! ctrlp#utils#glob(...) 70 | let path = ctrlp#utils#fnesc(a:1, 'g') 71 | retu s:wig_cond ? glob(path, a:2) : glob(path) 72 | endf 73 | 74 | fu! ctrlp#utils#globpath(...) 75 | retu call('globpath', s:wig_cond ? a:000 : a:000[:1]) 76 | endf 77 | 78 | fu! ctrlp#utils#fnesc(path, type, ...) 79 | if exists('*fnameescape') 80 | if exists('+ssl') 81 | if a:type == 'c' 82 | let path = escape(a:path, '%#') 83 | elsei a:type == 'f' 84 | let path = fnameescape(a:path) 85 | elsei a:type == 'g' 86 | let path = escape(a:path, '?*') 87 | en 88 | let path = substitute(path, '[', '[[]', 'g') 89 | el 90 | let path = fnameescape(a:path) 91 | en 92 | el 93 | if exists('+ssl') 94 | if a:type == 'c' 95 | let path = escape(a:path, '%#') 96 | elsei a:type == 'f' 97 | let path = escape(a:path, " \t\n%#*?|<\"") 98 | elsei a:type == 'g' 99 | let path = escape(a:path, '?*') 100 | en 101 | let path = substitute(path, '[', '[[]', 'g') 102 | el 103 | let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<") 104 | en 105 | en 106 | retu a:0 ? escape(path, a:1) : path 107 | endf 108 | "}}} 109 | 110 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 111 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/plugin/ctrlp.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: plugin/ctrlp.vim 3 | " Description: Fuzzy file, buffer, mru, tag, etc finder. 4 | " Author: Kien Nguyen 5 | " ============================================================================= 6 | " GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip 7 | 8 | if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp 9 | fini 10 | en 11 | let g:loaded_ctrlp = 1 12 | 13 | let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs, 14 | \ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins] 15 | \ = [[], [], [], [], {}, {}, [], 2] 16 | 17 | if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en 18 | if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en 19 | 20 | com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': }) 21 | com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': }) 22 | 23 | com! -bar CtrlPBuffer cal ctrlp#init(1) 24 | com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': }) 25 | 26 | com! -bar CtrlPClearCache cal ctrlp#clr() 27 | com! -bar CtrlPClearAllCaches cal ctrlp#clra() 28 | 29 | com! -bar ClearCtrlPCache cal ctrlp#clr() 30 | com! -bar ClearAllCtrlPCaches cal ctrlp#clra() 31 | 32 | com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' }) 33 | com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' }) 34 | com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) 35 | 36 | if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') 37 | exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' 38 | en 39 | 40 | cal ctrlp#mrufiles#init() 41 | 42 | com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id()) 43 | com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id()) 44 | 45 | com! -n=? -com=dir CtrlPDir 46 | \ cal ctrlp#init(ctrlp#dir#id(), { 'dir': }) 47 | 48 | com! -n=? -com=buffer CtrlPBufTag 49 | \ cal ctrlp#init(ctrlp#buffertag#cmd(0, )) 50 | 51 | com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) 52 | com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) 53 | com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) 54 | com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id()) 55 | 56 | com! -n=? -com=buffer CtrlPChange 57 | \ cal ctrlp#init(ctrlp#changes#cmd(0, )) 58 | 59 | com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) 60 | com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) 61 | com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) 62 | 63 | com! -n=? -com=dir CtrlPBookmarkDirAdd 64 | \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) 65 | 66 | " vim:ts=2:sw=2:sts=2 67 | -------------------------------------------------------------------------------- /bundle/ctrlp.vim/readme.md: -------------------------------------------------------------------------------- 1 | # ctrlp.vim 2 | Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim. 3 | 4 | * Written in pure Vimscript for MacVim, gVim and Vim 7.0+. 5 | * Full support for Vim's regexp as search patterns. 6 | * Built-in Most Recently Used (MRU) files monitoring. 7 | * Built-in project's root finder. 8 | * Open multiple files at once. 9 | * Create new files and directories. 10 | * [Extensible][2]. 11 | 12 | ![ctrlp][1] 13 | 14 | ## Basic Usage 15 | * Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode. 16 | * Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode. 17 | * Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time. 18 | 19 | Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands. 20 | 21 | ##### Once CtrlP is open: 22 | * Press `` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options. 23 | * Press `` and `` to cycle between modes. 24 | * Press `` to switch to filename only search instead of full path. 25 | * Press `` to switch to regexp mode. 26 | * Use ``, `` or the arrow keys to navigate the result list. 27 | * Use `` or ``, `` to open the selected entry in a new tab or in a new split. 28 | * Use ``, `` to select the next/previous string in the prompt's history. 29 | * Use `` to create a new file and its parent directories. 30 | * Use `` to mark/unmark multiple files and `` to open them. 31 | 32 | Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help. 33 | 34 | * Submit two or more dots `..` to go up the directory tree by one or multiple levels. 35 | * End the input string with a colon `:` followed by a command to execute it on the opening file(s): 36 | Use `:25` to jump to line 25. 37 | Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files. 38 | 39 | ## Basic Options 40 | * Change the default mapping and the default command to invoke CtrlP: 41 | 42 | ```vim 43 | let g:ctrlp_map = '' 44 | let g:ctrlp_cmd = 'CtrlP' 45 | ``` 46 | 47 | * When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable: 48 | 49 | ```vim 50 | let g:ctrlp_working_path_mode = 'ra' 51 | ``` 52 | 53 | `'c'` - the directory of the current file. 54 | `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` 55 | `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. 56 | `0` or `''` (empty string) - disable this feature. 57 | 58 | Define additional root markers with the `g:ctrlp_root_markers` option. 59 | 60 | * Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: 61 | 62 | ```vim 63 | set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux 64 | set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows 65 | 66 | let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' 67 | let g:ctrlp_custom_ignore = { 68 | \ 'dir': '\v[\/]\.(git|hg|svn)$', 69 | \ 'file': '\v\.(exe|so|dll)$', 70 | \ 'link': 'some_bad_symbolic_links', 71 | \ } 72 | ``` 73 | 74 | * Use a custom file listing command: 75 | 76 | ```vim 77 | let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux 78 | let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows 79 | ``` 80 | 81 | Check `:help ctrlp-options` for other options. 82 | 83 | ## Installation 84 | Use your favorite method or check the homepage for a [quick installation guide][3]. 85 | 86 | [1]: http://i.imgur.com/yIynr.png 87 | [2]: https://github.com/kien/ctrlp.vim/tree/extensions 88 | [3]: http://kien.github.com/ctrlp.vim#installation 89 | -------------------------------------------------------------------------------- /bundle/delimitMate/.gitignore: -------------------------------------------------------------------------------- 1 | *.sw? 2 | *.un? 3 | *.vba 4 | *.zip 5 | *.gz 6 | vimball.txt 7 | *.orig 8 | tags 9 | -------------------------------------------------------------------------------- /bundle/delimitMate/Makefile: -------------------------------------------------------------------------------- 1 | PLUGIN=$(shell basename "$$PWD") 2 | SCRIPT=$(wildcard plugin/*.vim) 3 | #AUTOL=$(wildcard autoload/*.vim) 4 | AUTOL=autoload/$(PLUGIN).vim 5 | DOC=$(wildcard doc/*.txt) 6 | TESTS=$(wildcard autoload/*Tests.vim) 7 | VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC)) 8 | VIMFOLDER=~/.vim/ 9 | VIM=/usr/bin/vim 10 | 11 | .PHONY: $(PLUGIN).vba README 12 | 13 | all: vimball README zip gzip 14 | 15 | vimball: $(PLUGIN).vba 16 | 17 | clean: 18 | @echo clean 19 | rm -f *.vba */*.orig *.~* .VimballRecord *.zip *.gz 20 | 21 | dist-clean: clean 22 | 23 | undo: 24 | for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done 25 | 26 | README: 27 | @echo README 28 | cp -f $(DOC) README 29 | 30 | $(PLUGIN).vba: 31 | @echo $(PLUGIN).vba 32 | rm -f $(PLUGIN)-$(VERSION).vba 33 | $(VIM) -N -c 'ru! vimballPlugin.vim' -c ':call append("0", [ "$(SCRIPT)", "$(AUTOL)", "$(DOC)"])' -c '$$d' -c ":%MkVimball $(PLUGIN)-$(VERSION) ." -c':q!' 34 | ln -f $(PLUGIN)-$(VERSION).vba $(PLUGIN).vba 35 | 36 | zip: 37 | @echo zip 38 | rm -f *.zip 39 | zip -r $(PLUGIN).zip doc plugin autoload 40 | zip $(PLUGIN).zip -d \*.sw\? || echo 1 41 | zip $(PLUGIN).zip -d \*.un\? || echo 1 42 | zip $(PLUGIN).zip -d \*.orig || echo 1 43 | zip $(PLUGIN).zip -d \*tags || echo 1 44 | zip $(PLUGIN).zip -d $(TESTS) 45 | ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip 46 | 47 | gzip: vimball 48 | @echo vimball 49 | gzip -f $(PLUGIN).vba 50 | 51 | release: version all 52 | 53 | version: 54 | @echo version: $(VERSION) 55 | perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL) 56 | perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT) 57 | perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC) 58 | perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL) 59 | perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC) 60 | @echo Version: $(VERSION) 61 | 62 | echo: 63 | -------------------------------------------------------------------------------- /bundle/delimitMate/README: -------------------------------------------------------------------------------- 1 | This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter in comments and other configurable regions), and expansions (off by default), and some more. 2 | 3 | Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using :autocmd. With a couple of exceptions and limitations, these features don't break undo, redo or history. 4 | -------------------------------------------------------------------------------- /bundle/delimitMate/autoload/delimitMateTests.vim: -------------------------------------------------------------------------------- 1 | function! delimitMateTests#Main() 2 | if !exists("g:delimitMate_testing") 3 | echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value." 4 | return 5 | elseif g:delimitMate_testing == "fork" 6 | !gvim -N -u NONE -U NONE -c "set runtimepath+=~/.vim/bundle/pathogen" -c "call pathogen\#runtime_append_all_bundles('bundle','symlinks')" -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "ru autoload/delimitMate.vim" -c "ru autoload/delimitMateTests.vim" -c "ru plugin/delimitMate.vim" -c "call delimitMateTests\#Main()" 7 | return "" 8 | endif 9 | nmap :qall! 10 | let nomore = &more 11 | set nomore 12 | let b:test_results = {} 13 | let b:errors = 0 14 | let b:corrects = 0 15 | let b:ignores = 0 16 | 17 | function! SetOptions(list) " {{{ 18 | let b:delimitMate_autoclose = 1 19 | let b:delimitMate_matchpairs = &matchpairs 20 | let b:delimitMate_quotes = "\" ' `" 21 | let b:delimitMate_excluded_regions = "Comment" 22 | let b:delimitMate_expand_space = 0 23 | let b:delimitMate_expand_cr = 0 24 | let b:delimitMate_smart_quotes = 1 25 | let b:delimitMate_apostrophes = "" 26 | let b:delimitMate_tab2exit = 1 27 | " Set current test options: 28 | for str in a:list 29 | "echom '1:'.str 30 | let op = strpart(str, 0, stridx(str,':')) 31 | "echom op 32 | let val = strpart(str, stridx(str, ':' ) + 1) 33 | "echom val 34 | exec "let b:delimitMate_" . op . " = " . val 35 | endfor 36 | DelimitMateReload 37 | endfunction " }}} 38 | 39 | function! Type(name, input, output, options, ...) " {{{ 40 | if a:0 > 0 41 | let ignore = a:1 42 | else 43 | let ignore = 0 44 | endif 45 | if a:input != "\." 46 | " Set default options: 47 | call SetOptions(a:options) 48 | let CapR = "" 49 | normal ggVG"_d 50 | exec "normal i" . a:input . "|\" 51 | else 52 | let CapR = "_R" 53 | normal gg. 54 | endif 55 | 56 | exec "normal \" 57 | call setpos('.', [0, 1, 1, 0]) 58 | let result = len(a:output) != line('$') 59 | for line in a:output 60 | if getline('.') != line || result == 1 61 | let result = 1 62 | break 63 | endif 64 | call setpos('.', [0, line('.') + 1, 1, 0]) 65 | endfor 66 | let text = getline('.') 67 | let i = 2 68 | while i <= line('$') 69 | let text = text . "" . getline(i) 70 | let i += 1 71 | endwhile 72 | if ignore == 1 73 | let label = "Ignored" 74 | let result = "?=" 75 | let b:ignores += 1 76 | elseif result == 0 77 | let label = "Passed" 78 | let result = "==" 79 | let b:corrects += 1 80 | else 81 | let label = "Failed" 82 | let result = "!=" 83 | let b:errors += 1 84 | endif 85 | exec "let b:test_results['" . 86 | \ substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . CapR . "'] = '" . 87 | \ label . ": ' . a:input . ' => ' . text . ' " . 88 | \ result . " ' . join(a:output, '')" 89 | endfunction " }}} 90 | 91 | function! RepeatLast(name, output, ...) " {{{ 92 | if a:0 > 0 93 | let arg1 = a:1 94 | else 95 | let arg1 = '' 96 | endif 97 | call Type(a:name, "\.", a:output, [], arg1) 98 | endfunction " }}} 99 | 100 | " Test's test {{{ 101 | call Type("Test 1", "123", ["123|"], []) 102 | call RepeatLast("Test 1", ["123|123|"]) 103 | 104 | " Auto-closing parens 105 | call Type("Autoclose parens", "(", ["(|)"], []) 106 | call RepeatLast("Autoclose_parens", ["(|)(|)"]) 107 | 108 | " Auto-closing quotes 109 | call Type("Autoclose quotes", '"', ['"|"'], []) 110 | call RepeatLast("Autoclose_quotes", ['"|""|"']) 111 | 112 | " Deleting parens 113 | call Type("Delete empty parens", "(\", ["|"], []) 114 | call RepeatLast("Delete empty parens", ["||"]) 115 | 116 | " Deleting quotes 117 | call Type("Delete emtpy quotes", "\"\", ['|'], []) 118 | call RepeatLast("Delete empty quotes", ["||"]) 119 | 120 | " Manual closing parens 121 | call Type("Manual closing parens", "()", ["(|)"], ["autoclose:0"]) 122 | call RepeatLast("Manual closing parens", ["(|)(|)"]) 123 | 124 | " Manual closing quotes 125 | call Type("Manual closing quotes", "\"\"", ['"|"'], ["autoclose:0"]) 126 | call RepeatLast("Manual closing quotes", ['"|""|"']) 127 | 128 | " Jump over paren 129 | call Type("Jump over paren", "()", ['()|'], []) 130 | call RepeatLast("Jump over paren", ['()|()|']) 131 | 132 | " Jump over quote 133 | call Type("Jump over quote", "\"\"", ['""|'], []) 134 | call RepeatLast("Jump over quote", ['""|""|']) 135 | 136 | " Apostrophe 137 | call Type("Apostrophe", "test'", ["test'|"], []) 138 | call RepeatLast("Apostrophe", ["test'|test'|"]) 139 | 140 | " Close quote 141 | call Type("Close quote", "'\\a'", ["'|'"], []) 142 | 143 | " Closing paren 144 | call Type("Closing paren", "abcd)", ["abcd)|"], []) 145 | 146 | " 147 | call Type("S Tab", "(\", ["()|"], []) 148 | call RepeatLast("S Tab", ["()|()|"]) 149 | 150 | " Space expansion 151 | call Type("Space expansion", "(\\", ['(|)'], ['expand_space:1']) 152 | call RepeatLast("BS with space expansion", ['(|)(|)']) 153 | 154 | " BS with space expansion 155 | call Type("BS with space expansion", "(\", ['( | )'], ['expand_space:1']) 156 | call RepeatLast("Space expansion", ['( | )( | )']) 157 | 158 | " Car return expansion 159 | call Type("CR expansion", "(\", ['(', '|', ')'], ['expand_cr:1']) 160 | call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'], 1) 161 | 162 | " BS with car return expansion 163 | call Type("BS with CR expansion", "(\\", ['(|)'], ['expand_cr:1']) 164 | call RepeatLast("BS with CR expansion", ['(|)(|)'], 1) 165 | 166 | " Smart quotes 167 | call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], []) 168 | call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|']) 169 | 170 | " Smart quotes 171 | call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], []) 172 | call RepeatLast("Smart quote escaped", ['esc\"|esc\"|']) 173 | 174 | " Smart quotes 175 | call Type("Smart quote apostrophe", "I'm", ["I'm|"], ['smart_quotes:0']) 176 | call RepeatLast("Smart quote escaped", ["I'm|I'm|"]) 177 | 178 | " Backspace inside space expansion 179 | call Type("Backspace inside space expansion", "(\\", ['(|)'], ['expand_space:1']) 180 | call RepeatLast("Backspace inside space expansion", ['(|)(|)']) 181 | 182 | " inserts text 183 | call Type(" inserts text", "(he\\th\\", ['(he) th|'], []) 184 | 185 | " Backspace inside CR expansion 186 | call Type("Backspace inside CR expansion", "(\\", ['(|)'], ['expand_cr:1']) 187 | call RepeatLast("Backspace inside CR expansion", ['(|)(|)'], 1) 188 | 189 | " FileType event 190 | let g:delimitMate_excluded_ft = "vim" 191 | set ft=vim 192 | call Type("FileType Autoclose parens", "(", ["(|"], []) 193 | unlet g:delimitMate_excluded_ft 194 | set ft= 195 | 196 | " Duplicated delimiter after CR 197 | call Type("Duplicated delimiter after CR", "(\", ['(', '|)'], []) 198 | 199 | " Deactivate on comments: The first call to a closing delimiter 200 | " will not work here as expected, but it does in real life tests. 201 | set ft=vim 202 | call Type("Deactivate on comments", "\"()``[]''\"\"", ["\"()``[]''\"\"|"], ["autoclose:0"], 1) 203 | set ft= 204 | 205 | " Deactivate parens on comments: The first call to a closing delimiter 206 | " will not work here as expected, but it does in real life tests. 207 | set ft=vim 208 | call Type("Deactivate parens on comments", "\"()[]", ["\"()[]|"], ["autoclose:0"], 1) 209 | set ft= 210 | 211 | " Deactivate quotes on comments: See previous note. 212 | set ft=vim 213 | call Type("Deactivate parens on comments", "\"(`", ["\"(``|"], [], 1) 214 | set ft= 215 | 216 | " Manual close at start of line 217 | call Type("Manual close at start of line", "m)\\)", [')|m)'], ["autoclose:0"]) 218 | 219 | " Use | in quotes 220 | call Type("Use in quotes", "\bars", ['|bars|'], ["quotes:'|'"]) 221 | 222 | " Use | in matchpairs 223 | call Type("Use in matchpairs", "\bars", ['|bars|$$'], ["matchpairs:'|:$'"]) 224 | 225 | "}}} 226 | 227 | " Show results: {{{ 228 | normal ggVG"_d 229 | call append(0, split(string(b:test_results)[1:-2], ', ')) 230 | call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.") 231 | normal "_ddgg 232 | let @/ = ".\\+Failed:.*!=" 233 | 2,$sort /^.\+':/ 234 | normal gg 235 | exec search('Ignored:','nW').",$sort! /^.\\+':/" 236 | set nohlsearch 237 | syn match lineIgnored ".*Ignored.*" 238 | syn match labelPassed "'\@<=.\+\(': 'Passed\)\@=" 239 | syn match labelFailed "'\@<=.\+\(': 'Failed\)\@=" 240 | syn match resultPassed "\('Passed: \)\@<=.\+\('$\)\@=" 241 | syn match resultFailed "\('Failed: \)\@<=.\+\('$\)\@=" contains=resultInequal 242 | syn match resultIgnored "\('Ignored: \)\@<=.\+\('$\)\@=" 243 | syn match resultInequal "!=" 244 | syn match resultSummary "^\*.\+" contains=resultSummaryNumber 245 | syn match resultSummaryNumber "[1-9][0-9]* failed*" contained 246 | 247 | hi def link lineIgnored Ignore 248 | hi def link labelPassed Comment 249 | hi def link labelFailed Special 250 | hi def link resultPassed Ignore 251 | hi def link resultFailed Boolean 252 | hi def link resultInequal Error 253 | hi def link resultSummary SpecialComment 254 | hi def link resultSummaryNumber Error 255 | " }}} 256 | 257 | let &more = nomore 258 | endfunction 259 | " vim:foldmethod=marker:foldcolumn=4 260 | 261 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/README: -------------------------------------------------------------------------------- 1 | The plugins runVimTests (http://www.vim.org/scripts/script.php?script_id=2565) 2 | and VimTAP (http://www.vim.org/scripts/script.php?script_id=2213) are needed to 3 | run these tests. 4 | 5 | Besides the _setup.vim configuration file present in this repo you need to 6 | create a global one and place it in the same dir where the runVimTests 7 | executable is located. Assuming the executable is at '~/bin/runVimTests' this 8 | global configuration file should be '~/bin/runVimTestsSetup.vim' and should 9 | have something like the following lines inside of it: 10 | 11 | " Prepend tests repos to &rtp 12 | let &runtimepath = '/path/to/runVimTests_dir,' . &rtp 13 | let &runtimepath = '/path/to/vimTAP_dir,' . &rtp 14 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/_setup.vim: -------------------------------------------------------------------------------- 1 | let &rtp = expand(':p:h:h') . ',' . &rtp . ',' . expand(':p:h:h') . '/after' 2 | ru plugin/delimitMate.vim 3 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/autoclose_matchpairs.txt: -------------------------------------------------------------------------------- 1 | let g:delimitMate_autoclose = 1 2 | "(x" "(x)" 3 | "(\x" "x" 4 | "()x" "()x" 5 | "((\gx" "(())x" 6 | "(x\u" "" 7 | "@(x" "@(x)" 8 | "@#\(x" "@(x)#" 9 | "(\x" "()x" 10 | let g:delimitMate_autoclose = 0 11 | "(x" "(x" 12 | "()x" "(x)" 13 | "())x" "()x" 14 | "()\x" "x" 15 | "@()x" "@(x)" 16 | "@#\()x" "@(x)#" 17 | let g:delimitMate_expand_space = 1 18 | let g:delimitMate_autoclose = 1 19 | "(\x" "( x )" 20 | "(\\x" "(x)" 21 | let g:delimitMate_autoclose = 0 22 | "()\\x" "(x)" 23 | let g:delimitMate_autoclose = 1 24 | # Handle backspace gracefully. 25 | set backspace= 26 | "(\a\x" "(x)" 27 | 28 | # Add semicolon next to the closing paren. Issue #77. 29 | new 30 | let b:delimitMate_eol_marker = ';' 31 | "abc(x" "abc(x);" 32 | %d 33 | # BS should behave accordingly. 34 | "abc(\" "abc" 35 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/autoclose_matchpairs.vim: -------------------------------------------------------------------------------- 1 | let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!' 2 | let lines = readfile(expand(':t:r').'.txt') 3 | call vimtest#StartTap() 4 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) 5 | let itemsnumber = len(split(g:delimitMate_matchpairs, ',')) 6 | call vimtap#Plan(testsnumber * itemsnumber) 7 | let tcount = 1 8 | let reload = 1 9 | for item in lines 10 | if item =~ '^#\|^\s*$' 11 | " A comment or empty line. 12 | continue 13 | endif 14 | if item !~ '^"' 15 | " A command. 16 | exec item 17 | call vimtap#Diag(item) 18 | let reload = 1 19 | continue 20 | endif 21 | if reload 22 | DelimitMateReload 23 | call vimtap#Diag('DelimitMateReload') 24 | let reload = 0 25 | endif 26 | let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"') 27 | for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")') 28 | let input2 = substitute(input, '(', s:l, 'g') 29 | let input2 = substitute(input2, ')', s:r, 'g') 30 | let output2 = substitute(output, '(', s:l, 'g') 31 | let output2 = substitute(output2, ')', s:r, 'g') 32 | %d 33 | exec 'normal i'.eval(input2)."\" 34 | let line = getline('.') 35 | let passed = line == eval(output2) 36 | call vimtap#Ok(passed, input2 . ' => ' . string(line) . 37 | \ (passed ? ' =' : ' !') . '= ' . string(eval(output2))) 38 | let tcount += 1 39 | endfor 40 | endfor 41 | call vimtest#Quit() 42 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/autoclose_quotes.txt: -------------------------------------------------------------------------------- 1 | let g:delimitMate_autoclose = 1 2 | "'x" "'x'" 3 | "'x\u" "" 4 | "''x" "''x" 5 | "'\x" "x" 6 | "'\gx" "''x" 7 | "'\"x" "'\"x\"'" 8 | "@'x" "@'x'" 9 | "@#\'x" "@'x'#" 10 | "'\x" "''x" 11 | "abc'" "abc'" 12 | "abc\\'x" "abc\\'x" 13 | "u'Привет'" "u'Привет'" 14 | "u'string'" "u'string'" 15 | let g:delimitMate_autoclose = 0 16 | "'x" "'x" 17 | "''x" "'x'" 18 | "'''x" "''x" 19 | "''\x" "x" 20 | "@''x" "@'x'" 21 | "@#\''x" "@'x'#" 22 | let g:delimitMate_expand_space = 1 23 | let g:delimitMate_autoclose = 1 24 | "'\x" "' x '" 25 | "'\\x" "'x'" 26 | "abc\\''\x" "abc\\' x'" 27 | let g:delimitMate_autoclose = 0 28 | "''\\x" "'x'" 29 | let g:delimitMate_autoclose = 1 30 | # Handle backspace gracefully. 31 | set backspace= 32 | "'\a\x" "'x'" 33 | set cpo=ces$ 34 | "'x" "'x'" 35 | # Make sure smart quote works beyond first column. 36 | " 'x" " 'x'" 37 | # Make sure we jump over a quote on the right. #89. 38 | "('test'x" "('test'x)" 39 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/autoclose_quotes.vim: -------------------------------------------------------------------------------- 1 | let g:delimitMate_quotes = '" '' ` ” « |' 2 | let lines = readfile(expand(':t:r').'.txt') 3 | call vimtest#StartTap() 4 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) 5 | let itemsnumber = len(split(g:delimitMate_quotes, ' ')) 6 | call vimtap#Plan(testsnumber * itemsnumber) 7 | let reload = 1 8 | let tcount = 1 9 | for item in lines 10 | if item =~ '^#\|^\s*$' 11 | " A comment or empty line. 12 | continue 13 | endif 14 | if item !~ '^"' 15 | " A command. 16 | exec item 17 | call vimtap#Diag(item) 18 | let reload = 1 19 | continue 20 | endif 21 | if reload 22 | DelimitMateReload 23 | call vimtap#Diag('DelimitMateReload') 24 | let reload = 0 25 | endif 26 | let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"') 27 | let quotes = split(g:delimitMate_quotes, '\s') 28 | for quote in quotes 29 | let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g') 30 | let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g') 31 | %d 32 | exec 'normal i'.eval(input_q)."\" 33 | let line = getline('.') 34 | let passed = line == eval(output_q) 35 | if quote == '”' || tcount == 31 36 | call vimtap#Todo(1) 37 | endif 38 | if 1 "!vimtap#Skip(1, tcount != 21, 'Test 21') 39 | call vimtap#Ok(passed, eval(substitute(input_q, '\\<', '<','g')) . ' => ' . line . 40 | \ (passed ? ' =' : ' !') . '= ' . eval(output_q)) 41 | endif 42 | let tcount += 1 43 | endfor 44 | endfor 45 | call vimtest#Quit() 46 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/expand_cr.txt: -------------------------------------------------------------------------------- 1 | # 2 | %d 3 | filetype indent on 4 | set bs=2 et sts=4 sw=4 ft=javascript 5 | call setline(1, '$(document).ready(function() {})') 6 | DelimitMateReload 7 | exec "normal 31|i\x\" 8 | ================================================================================ 9 | $(document).ready(function() { 10 | x 11 | }) 12 | -------------------------------------------------------------------------------- 13 | # Issue #95 14 | new 15 | exec "normal i(\test)x" 16 | ================================================================================ 17 | ( 18 | test 19 | )x 20 | -------------------------------------------------------------------------------- 21 | # Remove CR expansion on BS 22 | %d 23 | exec "normal i(\\x" 24 | ================================================================================ 25 | (x) 26 | -------------------------------------------------------------------------------- 27 | # Consider indentation with BS inside an empty CR expansion. 28 | %d 29 | exec "normal i( \\\x" 30 | ================================================================================ 31 | (x) 32 | -------------------------------------------------------------------------------- 33 | # Conflict with indentation settings (cindent). Issue #95 34 | se cindent 35 | call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}']) 36 | call cursor(3, 8) 37 | normal a}x 38 | ================================================================================ 39 | sub foo { 40 | while (1) { 41 | 42 | }x 43 | } 44 | -------------------------------------------------------------------------------- 45 | %d 46 | call setline(1, "\"{bracketed}") 47 | normal A"x 48 | ================================================================================ 49 | "{bracketed""x 50 | -------------------------------------------------------------------------------- 51 | # Syntax folding enabled by autocmd breaks expansion. But ti can't be tested 52 | # with :normal 53 | new 54 | autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual 55 | autocmd InsertLeave * let &foldmethod = w:fdm 56 | set foldmethod=marker 57 | set foldmarker={,} 58 | set foldlevel=0 59 | set backspace=2 60 | exec "normal iabc {\x" 61 | ================================================================================ 62 | abc { 63 | x 64 | } 65 | -------------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/expand_cr.vim: -------------------------------------------------------------------------------- 1 | let g:delimitMate_expand_cr = 1 2 | "DelimitMateReload 3 | let lines = readfile(expand(':t:r').'.txt') 4 | call vimtest#StartTap() 5 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$''')) 6 | call vimtap#Plan(testsnumber) 7 | let tcount = 1 8 | let expect = 0 9 | let evaluate = 0 10 | for item in lines 11 | if item =~ '^=\{80}$' 12 | let expect = 1 13 | let expected = [] 14 | continue 15 | endif 16 | 17 | if item =~ '^#\|^\s*$' && expect == 0 18 | " A comment or empty line. 19 | continue 20 | endif 21 | if ! expect 22 | " A command. 23 | exec item 24 | call vimtap#Diag(item) 25 | continue 26 | endif 27 | if item =~ '^-\{80}$' 28 | let expect = 0 29 | endif 30 | if expect 31 | call add(expected, item) 32 | continue 33 | endif 34 | let lines = getline(1, line('$')) 35 | let passed = lines == expected 36 | echom string(lines) 37 | echom string(expected) 38 | call vimtap#Ok(passed, string(expected) . 39 | \ (passed ? ' =' : ' !') . '= ' . string(lines)) 40 | let tcount += 1 41 | endfor 42 | call vimtest#Quit() 43 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/expand_space.txt: -------------------------------------------------------------------------------- 1 | # Issue #95 2 | new 3 | exec "normal i( test)x" 4 | ================================================================================ 5 | ( test )x 6 | -------------------------------------------------------------------------------- 7 | -------------------------------------------------------------------------------- /bundle/delimitMate/test/expand_space.vim: -------------------------------------------------------------------------------- 1 | let g:delimitMate_expand_space = 1 2 | "DelimitMateReload 3 | let lines = readfile(expand(':t:r').'.txt') 4 | call vimtest#StartTap() 5 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$''')) 6 | call vimtap#Plan(testsnumber) 7 | let tcount = 1 8 | let expect = 0 9 | let evaluate = 0 10 | for item in lines 11 | if item =~ '^=\{80}$' 12 | let expect = 1 13 | let expected = [] 14 | continue 15 | endif 16 | 17 | if item =~ '^#\|^\s*$' && expect == 0 18 | " A comment or empty line. 19 | continue 20 | endif 21 | if ! expect 22 | " A command. 23 | exec item 24 | call vimtap#Diag(item) 25 | continue 26 | endif 27 | if item =~ '^-\{80}$' 28 | let expect = 0 29 | endif 30 | if expect 31 | call add(expected, item) 32 | continue 33 | endif 34 | let lines = getline(1, line('$')) 35 | let passed = lines == expected 36 | echom string(lines) 37 | echom string(expected) 38 | call vimtap#Ok(passed, string(expected) . 39 | \ (passed ? ' =' : ' !') . '= ' . string(lines)) 40 | let tcount += 1 41 | endfor 42 | call vimtest#Quit() 43 | -------------------------------------------------------------------------------- /bundle/snipmate/README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=2540 2 | 3 | snipMate.vim aims to be an unobtrusive, concise vim script that implements some of TextMate's snippets features in Vim. A snippet is a piece of often-typed text that you can insert into your document using a trigger word followed by a . 4 | 5 | For instance, in a C file using the default installation of snipMate.vim, if you type "for" in insert mode, it will expand a typical for loop in C: 6 | 7 | for (i = 0; i < count; i++) { 8 | 9 | } 10 | 11 | To go to the next item in the loop, simply over to it; if there is repeated code, such as the "i" variable in this example, you can simply start typing once it's highlighted and all the matches specified in the snippet will be updated. 12 | 13 | Requires Vim 7 or higher. 14 | For a quick introduction, see this screencast: http://vimeo.com/3535418 15 | For more help see the documentation that comes with snipMate in ~/.vim/doc/snipMate.txt. 16 | 17 | snipMate.vim has the following features among others: 18 | - The syntax of snippets is very similar to TextMate's, allowing easy conversion. 19 | - The position of the snippet is kept transparently (i.e., it does not use marks/placeholders inserted into the buffer), allowing you to escape out of an incomplete snippet, something particularly useful in Vim. 20 | - Variables in snippets are updated as-you-type. 21 | - Snippets can have multiple matches. 22 | - Snippets can be out of order. For instance, in a do...while loop, the condition can be added before the code. 23 | 24 | Bug reports, feature requests, etc. are welcome and can be emailed to me or submitted on the issue tracker: http://code.google.com/p/snipmate/issues/list 25 | 26 | If you would like to watch the development of this plugin, you can also follow it on github: http://github.com/msanders/snipmate.vim 27 | 28 | Enjoy! 29 | -------------------------------------------------------------------------------- /bundle/snipmate/after/plugin/snipMate.vim: -------------------------------------------------------------------------------- 1 | " These are the mappings for snipMate.vim. Putting it here ensures that it 2 | " will be mapped after other plugins such as supertab.vim. 3 | if !exists('loaded_snips') || exists('s:did_snips_mappings') 4 | finish 5 | endif 6 | let s:did_snips_mappings = 1 7 | 8 | ino =TriggerSnippet() 9 | snor i=TriggerSnippet() 10 | ino =BackwardsSnippet() 11 | snor i=BackwardsSnippet() 12 | ino =ShowAvailableSnips() 13 | 14 | " The default mappings for these are annoying & sometimes break snipMate. 15 | " You can change them back if you want, I've put them here for convenience. 16 | snor b 17 | snor a 18 | snor bi 19 | snor ' b' 20 | snor ` b` 21 | snor % b% 22 | snor U bU 23 | snor ^ b^ 24 | snor \ b\ 25 | snor b 26 | 27 | " By default load snippets in snippets_dir 28 | if empty(snippets_dir) 29 | finish 30 | endif 31 | 32 | call GetSnippets(snippets_dir, '_') " Get global snippets 33 | 34 | au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif 35 | " vim:noet:sw=4:ts=4:ft=vim 36 | -------------------------------------------------------------------------------- /bundle/snipmate/autoload/snipMate.vim: -------------------------------------------------------------------------------- 1 | fun! Filename(...) 2 | let filename = expand('%:t:r') 3 | if filename == '' | return a:0 == 2 ? a:2 : '' | endif 4 | return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') 5 | endf 6 | 7 | fun s:RemoveSnippet() 8 | unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen 9 | \ s:lastBuf s:oldWord 10 | if exists('s:update') 11 | unl s:startCol s:origWordLen s:update 12 | if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif 13 | endif 14 | aug! snipMateAutocmds 15 | endf 16 | 17 | fun snipMate#expandSnip(snip, col) 18 | let lnum = line('.') | let col = a:col 19 | 20 | let snippet = s:ProcessSnippet(a:snip) 21 | " Avoid error if eval evaluates to nothing 22 | if snippet == '' | return '' | endif 23 | 24 | " Expand snippet onto current position with the tab stops removed 25 | let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1) 26 | 27 | let line = getline(lnum) 28 | let afterCursor = strpart(line, col - 1) 29 | " Keep text after the cursor 30 | if afterCursor != "\t" && afterCursor != ' ' 31 | let line = strpart(line, 0, col - 1) 32 | let snipLines[-1] .= afterCursor 33 | else 34 | let afterCursor = '' 35 | " For some reason the cursor needs to move one right after this 36 | if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' 37 | let col += 1 38 | endif 39 | endif 40 | 41 | call setline(lnum, line.snipLines[0]) 42 | 43 | " Autoindent snippet according to previous indentation 44 | let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1 45 | call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val")) 46 | 47 | " Open any folds snippet expands into 48 | if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif 49 | 50 | let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent) 51 | 52 | if s:snipLen 53 | aug snipMateAutocmds 54 | au CursorMovedI * call s:UpdateChangedSnip(0) 55 | au InsertEnter * call s:UpdateChangedSnip(1) 56 | aug END 57 | let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer 58 | let s:curPos = 0 59 | let s:endCol = g:snipPos[s:curPos][1] 60 | let s:endLine = g:snipPos[s:curPos][0] 61 | 62 | call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1]) 63 | let s:prevLen = [line('$'), col('$')] 64 | if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif 65 | else 66 | unl g:snipPos s:snipLen 67 | " Place cursor at end of snippet if no tab stop is given 68 | let newlines = len(snipLines) - 1 69 | call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor) 70 | \ + (newlines ? 0: col - 1)) 71 | endif 72 | return '' 73 | endf 74 | 75 | " Prepare snippet to be processed by s:BuildTabStops 76 | fun s:ProcessSnippet(snip) 77 | let snippet = a:snip 78 | " Evaluate eval (`...`) expressions. 79 | " Using a loop here instead of a regex fixes a bug with nested "\=". 80 | if stridx(snippet, '`') != -1 81 | while match(snippet, '`.\{-}`') != -1 82 | let snippet = substitute(snippet, '`.\{-}`', 83 | \ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')), 84 | \ "\n\\%$", '', ''), '') 85 | endw 86 | let snippet = substitute(snippet, "\r", "\n", 'g') 87 | endif 88 | 89 | " Place all text after a colon in a tab stop after the tab stop 90 | " (e.g. "${#:foo}" becomes "${:foo}foo"). 91 | " This helps tell the position of the tab stops later. 92 | let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g') 93 | 94 | " Update the a:snip so that all the $# become the text after 95 | " the colon in their associated ${#}. 96 | " (e.g. "${1:foo}" turns all "$1"'s into "foo") 97 | let i = 1 98 | while stridx(snippet, '${'.i) != -1 99 | let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}') 100 | if s != '' 101 | let snippet = substitute(snippet, '$'.i, s.'&', 'g') 102 | endif 103 | let i += 1 104 | endw 105 | 106 | if &et " Expand tabs to spaces if 'expandtab' is set. 107 | return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g') 108 | endif 109 | return snippet 110 | endf 111 | 112 | " Counts occurences of haystack in needle 113 | fun s:Count(haystack, needle) 114 | let counter = 0 115 | let index = stridx(a:haystack, a:needle) 116 | while index != -1 117 | let index = stridx(a:haystack, a:needle, index+1) 118 | let counter += 1 119 | endw 120 | return counter 121 | endf 122 | 123 | " Builds a list of a list of each tab stop in the snippet containing: 124 | " 1.) The tab stop's line number. 125 | " 2.) The tab stop's column number 126 | " (by getting the length of the string between the last "\n" and the 127 | " tab stop). 128 | " 3.) The length of the text after the colon for the current tab stop 129 | " (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned. 130 | " 4.) If the "${#:}" construct is given, another list containing all 131 | " the matches of "$#", to be replaced with the placeholder. This list is 132 | " composed the same way as the parent; the first item is the line number, 133 | " and the second is the column. 134 | fun s:BuildTabStops(snip, lnum, col, indent) 135 | let snipPos = [] 136 | let i = 1 137 | let withoutVars = substitute(a:snip, '$\d\+', '', 'g') 138 | while stridx(a:snip, '${'.i) != -1 139 | let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D') 140 | let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g') 141 | 142 | let j = i - 1 143 | call add(snipPos, [0, 0, -1]) 144 | let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n") 145 | let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D')) 146 | if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif 147 | 148 | " Get all $# matches in another list, if ${#:name} is given 149 | if stridx(withoutVars, '${'.i.':') != -1 150 | let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}')) 151 | let dots = repeat('.', snipPos[j][2]) 152 | call add(snipPos[j], []) 153 | let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g') 154 | while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1 155 | let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)') 156 | call add(snipPos[j][3], [0, 0]) 157 | let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n") 158 | let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum 159 | \ ? len(matchstr(beforeMark, '.*\n\zs.*')) 160 | \ : a:col + len(beforeMark)) 161 | let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '') 162 | endw 163 | endif 164 | let i += 1 165 | endw 166 | return [snipPos, i - 1] 167 | endf 168 | 169 | fun snipMate#jumpTabStop(backwards) 170 | let leftPlaceholder = exists('s:origWordLen') 171 | \ && s:origWordLen != g:snipPos[s:curPos][2] 172 | if leftPlaceholder && exists('s:oldEndCol') 173 | let startPlaceholder = s:oldEndCol + 1 174 | endif 175 | 176 | if exists('s:update') 177 | call s:UpdatePlaceholderTabStops() 178 | else 179 | call s:UpdateTabStops() 180 | endif 181 | 182 | " Don't reselect placeholder if it has been modified 183 | if leftPlaceholder && g:snipPos[s:curPos][2] != -1 184 | if exists('startPlaceholder') 185 | let g:snipPos[s:curPos][1] = startPlaceholder 186 | else 187 | let g:snipPos[s:curPos][1] = col('.') 188 | let g:snipPos[s:curPos][2] = 0 189 | endif 190 | endif 191 | 192 | let s:curPos += a:backwards ? -1 : 1 193 | " Loop over the snippet when going backwards from the beginning 194 | if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif 195 | 196 | if s:curPos == s:snipLen 197 | let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2] 198 | call s:RemoveSnippet() 199 | return sMode ? "\" : TriggerSnippet() 200 | endif 201 | 202 | call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1]) 203 | 204 | let s:endLine = g:snipPos[s:curPos][0] 205 | let s:endCol = g:snipPos[s:curPos][1] 206 | let s:prevLen = [line('$'), col('$')] 207 | 208 | return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord() 209 | endf 210 | 211 | fun s:UpdatePlaceholderTabStops() 212 | let changeLen = s:origWordLen - g:snipPos[s:curPos][2] 213 | unl s:startCol s:origWordLen s:update 214 | if !exists('s:oldVars') | return | endif 215 | " Update tab stops in snippet if text has been added via "$#" 216 | " (e.g., in "${1:foo}bar$1${2}"). 217 | if changeLen != 0 218 | let curLine = line('.') 219 | 220 | for pos in g:snipPos 221 | if pos == g:snipPos[s:curPos] | continue | endif 222 | let changed = pos[0] == curLine && pos[1] > s:oldEndCol 223 | let changedVars = 0 224 | let endPlaceholder = pos[2] - 1 + pos[1] 225 | " Subtract changeLen from each tab stop that was after any of 226 | " the current tab stop's placeholders. 227 | for [lnum, col] in s:oldVars 228 | if lnum > pos[0] | break | endif 229 | if pos[0] == lnum 230 | if pos[1] > col || (pos[2] == -1 && pos[1] == col) 231 | let changed += 1 232 | elseif col < endPlaceholder 233 | let changedVars += 1 234 | endif 235 | endif 236 | endfor 237 | let pos[1] -= changeLen * changed 238 | let pos[2] -= changeLen * changedVars " Parse variables within placeholders 239 | " e.g., "${1:foo} ${2:$1bar}" 240 | 241 | if pos[2] == -1 | continue | endif 242 | " Do the same to any placeholders in the other tab stops. 243 | for nPos in pos[3] 244 | let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol 245 | for [lnum, col] in s:oldVars 246 | if lnum > nPos[0] | break | endif 247 | if nPos[0] == lnum && nPos[1] > col 248 | let changed += 1 249 | endif 250 | endfor 251 | let nPos[1] -= changeLen * changed 252 | endfor 253 | endfor 254 | endif 255 | unl s:endCol s:oldVars s:oldEndCol 256 | endf 257 | 258 | fun s:UpdateTabStops() 259 | let changeLine = s:endLine - g:snipPos[s:curPos][0] 260 | let changeCol = s:endCol - g:snipPos[s:curPos][1] 261 | if exists('s:origWordLen') 262 | let changeCol -= s:origWordLen 263 | unl s:origWordLen 264 | endif 265 | let lnum = g:snipPos[s:curPos][0] 266 | let col = g:snipPos[s:curPos][1] 267 | " Update the line number of all proceeding tab stops if has 268 | " been inserted. 269 | if changeLine != 0 270 | let changeLine -= 1 271 | for pos in g:snipPos 272 | if pos[0] >= lnum 273 | if pos[0] == lnum | let pos[1] += changeCol | endif 274 | let pos[0] += changeLine 275 | endif 276 | if pos[2] == -1 | continue | endif 277 | for nPos in pos[3] 278 | if nPos[0] >= lnum 279 | if nPos[0] == lnum | let nPos[1] += changeCol | endif 280 | let nPos[0] += changeLine 281 | endif 282 | endfor 283 | endfor 284 | elseif changeCol != 0 285 | " Update the column of all proceeding tab stops if text has 286 | " been inserted/deleted in the current line. 287 | for pos in g:snipPos 288 | if pos[1] >= col && pos[0] == lnum 289 | let pos[1] += changeCol 290 | endif 291 | if pos[2] == -1 | continue | endif 292 | for nPos in pos[3] 293 | if nPos[0] > lnum | break | endif 294 | if nPos[0] == lnum && nPos[1] >= col 295 | let nPos[1] += changeCol 296 | endif 297 | endfor 298 | endfor 299 | endif 300 | endf 301 | 302 | fun s:SelectWord() 303 | let s:origWordLen = g:snipPos[s:curPos][2] 304 | let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1, 305 | \ s:origWordLen) 306 | let s:prevLen[1] -= s:origWordLen 307 | if !empty(g:snipPos[s:curPos][3]) 308 | let s:update = 1 309 | let s:endCol = -1 310 | let s:startCol = g:snipPos[s:curPos][1] - 1 311 | endif 312 | if !s:origWordLen | return '' | endif 313 | let l = col('.') != 1 ? 'l' : '' 314 | if &sel == 'exclusive' 315 | return "\".l.'v'.s:origWordLen."l\" 316 | endif 317 | return s:origWordLen == 1 ? "\".l.'gh' 318 | \ : "\".l.'v'.(s:origWordLen - 1)."l\" 319 | endf 320 | 321 | " This updates the snippet as you type when text needs to be inserted 322 | " into multiple places (e.g. in "${1:default text}foo$1bar$1", 323 | " "default text" would be highlighted, and if the user types something, 324 | " UpdateChangedSnip() would be called so that the text after "foo" & "bar" 325 | " are updated accordingly) 326 | " 327 | " It also automatically quits the snippet if the cursor is moved out of it 328 | " while in insert mode. 329 | fun s:UpdateChangedSnip(entering) 330 | if exists('g:snipPos') && bufnr(0) != s:lastBuf 331 | call s:RemoveSnippet() 332 | elseif exists('s:update') " If modifying a placeholder 333 | if !exists('s:oldVars') && s:curPos + 1 < s:snipLen 334 | " Save the old snippet & word length before it's updated 335 | " s:startCol must be saved too, in case text is added 336 | " before the snippet (e.g. in "foo$1${2}bar${1:foo}"). 337 | let s:oldEndCol = s:startCol 338 | let s:oldVars = deepcopy(g:snipPos[s:curPos][3]) 339 | endif 340 | let col = col('.') - 1 341 | 342 | if s:endCol != -1 343 | let changeLen = col('$') - s:prevLen[1] 344 | let s:endCol += changeLen 345 | else " When being updated the first time, after leaving select mode 346 | if a:entering | return | endif 347 | let s:endCol = col - 1 348 | endif 349 | 350 | " If the cursor moves outside the snippet, quit it 351 | if line('.') != g:snipPos[s:curPos][0] || col < s:startCol || 352 | \ col - 1 > s:endCol 353 | unl! s:startCol s:origWordLen s:oldVars s:update 354 | return s:RemoveSnippet() 355 | endif 356 | 357 | call s:UpdateVars() 358 | let s:prevLen[1] = col('$') 359 | elseif exists('g:snipPos') 360 | if !a:entering && g:snipPos[s:curPos][2] != -1 361 | let g:snipPos[s:curPos][2] = -2 362 | endif 363 | 364 | let col = col('.') 365 | let lnum = line('.') 366 | let changeLine = line('$') - s:prevLen[0] 367 | 368 | if lnum == s:endLine 369 | let s:endCol += col('$') - s:prevLen[1] 370 | let s:prevLen = [line('$'), col('$')] 371 | endif 372 | if changeLine != 0 373 | let s:endLine += changeLine 374 | let s:endCol = col 375 | endif 376 | 377 | " Delete snippet if cursor moves out of it in insert mode 378 | if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1])) 379 | \ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0] 380 | call s:RemoveSnippet() 381 | endif 382 | endif 383 | endf 384 | 385 | " This updates the variables in a snippet when a placeholder has been edited. 386 | " (e.g., each "$1" in "${1:foo} $1bar $1bar") 387 | fun s:UpdateVars() 388 | let newWordLen = s:endCol - s:startCol + 1 389 | let newWord = strpart(getline('.'), s:startCol, newWordLen) 390 | if newWord == s:oldWord || empty(g:snipPos[s:curPos][3]) 391 | return 392 | endif 393 | 394 | let changeLen = g:snipPos[s:curPos][2] - newWordLen 395 | let curLine = line('.') 396 | let startCol = col('.') 397 | let oldStartSnip = s:startCol 398 | let updateTabStops = changeLen != 0 399 | let i = 0 400 | 401 | for [lnum, col] in g:snipPos[s:curPos][3] 402 | if updateTabStops 403 | let start = s:startCol 404 | if lnum == curLine && col <= start 405 | let s:startCol -= changeLen 406 | let s:endCol -= changeLen 407 | endif 408 | for nPos in g:snipPos[s:curPos][3][(i):] 409 | " This list is in ascending order, so quit if we've gone too far. 410 | if nPos[0] > lnum | break | endif 411 | if nPos[0] == lnum && nPos[1] > col 412 | let nPos[1] -= changeLen 413 | endif 414 | endfor 415 | if lnum == curLine && col > start 416 | let col -= changeLen 417 | let g:snipPos[s:curPos][3][i][1] = col 418 | endif 419 | let i += 1 420 | endif 421 | 422 | " "Very nomagic" is used here to allow special characters. 423 | call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'. 424 | \ escape(s:oldWord, '\'), escape(newWord, '\&'), '')) 425 | endfor 426 | if oldStartSnip != s:startCol 427 | call cursor(0, startCol + s:startCol - oldStartSnip) 428 | endif 429 | 430 | let s:oldWord = newWord 431 | let g:snipPos[s:curPos][2] = newWordLen 432 | endf 433 | " vim:noet:sw=4:ts=4:ft=vim 434 | -------------------------------------------------------------------------------- /bundle/snipmate/doc/snipMate.txt: -------------------------------------------------------------------------------- 1 | *snipMate.txt* Plugin for using TextMate-style snippets in Vim. 2 | 3 | snipMate *snippet* *snippets* *snipMate* 4 | Last Change: July 13, 2009 5 | 6 | |snipMate-description| Description 7 | |snipMate-syntax| Snippet syntax 8 | |snipMate-usage| Usage 9 | |snipMate-settings| Settings 10 | |snipMate-features| Features 11 | |snipMate-disadvantages| Disadvantages to TextMate 12 | |snipMate-contact| Contact 13 | 14 | For Vim version 7.0 or later. 15 | This plugin only works if 'compatible' is not set. 16 | {Vi does not have any of these features.} 17 | 18 | ============================================================================== 19 | DESCRIPTION *snipMate-description* 20 | 21 | snipMate.vim implements some of TextMate's snippets features in Vim. A 22 | snippet is a piece of often-typed text that you can insert into your 23 | document using a trigger word followed by a . 24 | 25 | For instance, in a C file using the default installation of snipMate.vim, if 26 | you type "for" in insert mode, it will expand a typical for loop in C: > 27 | 28 | for (i = 0; i < count; i++) { 29 | 30 | } 31 | 32 | 33 | To go to the next item in the loop, simply over to it; if there is 34 | repeated code, such as the "i" variable in this example, you can simply 35 | start typing once it's highlighted and all the matches specified in the 36 | snippet will be updated. To go in reverse, use . 37 | 38 | ============================================================================== 39 | SYNTAX *snippet-syntax* 40 | 41 | Snippets can be defined in two ways. They can be in their own file, named 42 | after their trigger in 'snippets//.snippet', or they can be 43 | defined together in a 'snippets/.snippets' file. Note that dotted 44 | 'filetype' syntax is supported -- e.g., you can use > 45 | 46 | :set ft=html.eruby 47 | 48 | to activate snippets for both HTML and eRuby for the current file. 49 | 50 | The syntax for snippets in *.snippets files is the following: > 51 | 52 | snippet trigger 53 | expanded text 54 | more expanded text 55 | 56 | Note that the first hard tab after the snippet trigger is required, and not 57 | expanded in the actual snippet. The syntax for *.snippet files is the same, 58 | only without the trigger declaration and starting indentation. 59 | 60 | Also note that snippets must be defined using hard tabs. They can be expanded 61 | to spaces later if desired (see |snipMate-indenting|). 62 | 63 | "#" is used as a line-comment character in *.snippets files; however, they can 64 | only be used outside of a snippet declaration. E.g.: > 65 | 66 | # this is a correct comment 67 | snippet trigger 68 | expanded text 69 | snippet another_trigger 70 | # this isn't a comment! 71 | expanded text 72 | < 73 | This should hopefully be obvious with the included syntax highlighting. 74 | 75 | *snipMate-${#}* 76 | Tab stops ~ 77 | 78 | By default, the cursor is placed at the end of a snippet. To specify where the 79 | cursor is to be placed next, use "${#}", where the # is the number of the tab 80 | stop. E.g., to place the cursor first on the id of a
tag, and then allow 81 | the user to press to go to the middle of it: 82 | > 83 | snippet div 84 |
85 | ${2} 86 |
87 | < 88 | *snipMate-placeholders* *snipMate-${#:}* *snipMate-$#* 89 | Placeholders ~ 90 | 91 | Placeholder text can be supplied using "${#:text}", where # is the number of 92 | the tab stop. This text then can be copied throughout the snippet using "$#", 93 | given # is the same number as used before. So, to make a C for loop: > 94 | 95 | snippet for 96 | for (${2:i}; $2 < ${1:count}; $1++) { 97 | ${4} 98 | } 99 | 100 | This will cause "count" to first be selected and change if the user starts 101 | typing. When is pressed, the "i" in ${2}'s position will be selected; 102 | all $2 variables will default to "i" and automatically be updated if the user 103 | starts typing. 104 | NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate. 105 | 106 | Variables within variables are also possible. For instance: > 107 | 108 | snippet opt 109 | 110 | 111 | Will, as usual, cause "option" to first be selected and update all the $1 112 | variables if the user starts typing. Since one of these variables is inside of 113 | ${2}, this text will then be used as a placeholder for the next tab stop, 114 | allowing the user to change it if he wishes. 115 | 116 | To copy a value throughout a snippet without supplying default text, simply 117 | use the "${#:}" construct without the text; e.g.: > 118 | 119 | snippet foo 120 | ${1:}bar$1 121 | < *snipMate-commands* 122 | Interpolated Vim Script ~ 123 | 124 | Snippets can also contain Vim script commands that are executed (via |eval()|) 125 | when the snippet is inserted. Commands are given inside backticks (`...`); for 126 | TextMates's functionality, use the |system()| function. E.g.: > 127 | 128 | snippet date 129 | `system("date +%Y-%m-%d")` 130 | 131 | will insert the current date, assuming you are on a Unix system. Note that you 132 | can also (and should) use |strftime()| for this example. 133 | 134 | Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()* 135 | 136 | Since the current filename is used often in snippets, a default function 137 | has been defined for it in snipMate.vim, appropriately called Filename(). 138 | 139 | With no arguments, the default filename without an extension is returned; 140 | the first argument specifies what to place before or after the filename, 141 | and the second argument supplies the default text to be used if the file 142 | has not been named. "$1" in the first argument is replaced with the filename; 143 | if you only want the filename to be returned, the first argument can be left 144 | blank. Examples: > 145 | 146 | snippet filename 147 | `Filename()` 148 | snippet filename_with_default 149 | `Filename('', 'name')` 150 | snippet filename_foo 151 | `filename('$1_foo')` 152 | 153 | The first example returns the filename if it the file has been named, and an 154 | empty string if it hasn't. The second returns the filename if it's been named, 155 | and "name" if it hasn't. The third returns the filename followed by "_foo" if 156 | it has been named, and an empty string if it hasn't. 157 | 158 | *multi_snip* 159 | To specify that a snippet can have multiple matches in a *.snippets file, use 160 | this syntax: > 161 | 162 | snippet trigger A description of snippet #1 163 | expand this text 164 | snippet trigger A description of snippet #2 165 | expand THIS text! 166 | 167 | In this example, when "trigger" is typed, a numbered menu containing all 168 | of the descriptions of the "trigger" will be shown; when the user presses the 169 | corresponding number, that snippet will then be expanded. 170 | 171 | To create a snippet with multiple matches using *.snippet files, 172 | simply place all the snippets in a subdirectory with the trigger name: 173 | 'snippets///.snippet'. 174 | 175 | ============================================================================== 176 | USAGE *snipMate-usage* 177 | 178 | *'snippets'* *g:snippets_dir* 179 | Snippets are by default looked for any 'snippets' directory in your 180 | 'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or 181 | '$HOME\vimfiles\snippets\' on Windows. To change that location or add another 182 | one, change the g:snippets_dir variable in your |.vimrc| to your preferred 183 | directory, or use the |ExtractSnips()|function. This will be used by the 184 | |globpath()| function, and so accepts the same syntax as it (e.g., 185 | comma-separated paths). 186 | 187 | ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets* 188 | 189 | ExtractSnipsFile() extracts the specified *.snippets file for the given 190 | filetype. A .snippets file contains multiple snippet declarations for the 191 | filetype. It is further explained above, in |snippet-syntax|. 192 | 193 | ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet* 194 | 195 | ExtractSnips() extracts *.snippet files from the specified directory and 196 | defines them as snippets for the given filetype. The directory tree should 197 | look like this: 'snippets//.snippet'. If the snippet has 198 | multiple matches, it should look like this: 199 | 'snippets///.snippet' (see |multi_snip|). 200 | 201 | *ResetSnippets()* 202 | The ResetSnippets() function removes all snippets from memory. This is useful 203 | to put at the top of a snippet setup file for if you would like to |:source| 204 | it multiple times. 205 | 206 | *list-snippets* *i_CTRL-R_* 207 | If you would like to see what snippets are available, simply type 208 | in the current buffer to show a list via |popupmenu-completion|. 209 | 210 | ============================================================================== 211 | SETTINGS *snipMate-settings* *g:snips_author* 212 | 213 | The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set 214 | to your name; it can then be used in snippets to automatically add it. E.g.: > 215 | 216 | let g:snips_author = 'Hubert Farnsworth' 217 | snippet name 218 | `g:snips_author` 219 | < 220 | *snipMate-expandtab* *snipMate-indenting* 221 | If you would like your snippets to be expanded using spaces instead of tabs, 222 | just enable 'expandtab' and set 'softtabstop' to your preferred amount of 223 | spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead. 224 | 225 | *snipMate-remap* 226 | snipMate does not come with a setting to customize the trigger key, but you 227 | can remap it easily in the two lines it's defined in the 'after' directory 228 | under 'plugin/snipMate.vim'. For instance, to change the trigger key 229 | to CTRL-J, just change this: > 230 | 231 | ino =TriggerSnippet() 232 | snor i=TriggerSnippet() 233 | 234 | to this: > 235 | ino =TriggerSnippet() 236 | snor i=TriggerSnippet() 237 | 238 | ============================================================================== 239 | FEATURES *snipMate-features* 240 | 241 | snipMate.vim has the following features among others: 242 | - The syntax of snippets is very similar to TextMate's, allowing 243 | easy conversion. 244 | - The position of the snippet is kept transparently (i.e. it does not use 245 | markers/placeholders written to the buffer), which allows you to escape 246 | out of an incomplete snippet, something particularly useful in Vim. 247 | - Variables in snippets are updated as-you-type. 248 | - Snippets can have multiple matches. 249 | - Snippets can be out of order. For instance, in a do...while loop, the 250 | condition can be added before the code. 251 | - [New] File-based snippets are supported. 252 | - [New] Triggers after non-word delimiters are expanded, e.g. "foo" 253 | in "bar.foo". 254 | - [New] can now be used to jump tab stops in reverse order. 255 | 256 | ============================================================================== 257 | DISADVANTAGES *snipMate-disadvantages* 258 | 259 | snipMate.vim currently has the following disadvantages to TextMate's snippets: 260 | - There is no $0; the order of tab stops must be explicitly stated. 261 | - Placeholders within placeholders are not possible. E.g.: > 262 | 263 | '${3}
' 264 | < 265 | In TextMate this would first highlight ' id="some_id"', and if 266 | you hit delete it would automatically skip ${2} and go to ${3} 267 | on the next , but if you didn't delete it it would highlight 268 | "some_id" first. You cannot do this in snipMate.vim. 269 | - Regex cannot be performed on variables, such as "${1/.*/\U&}" 270 | - Placeholders cannot span multiple lines. 271 | - Activating snippets in different scopes of the same file is 272 | not possible. 273 | 274 | Perhaps some of these features will be added in a later release. 275 | 276 | ============================================================================== 277 | CONTACT *snipMate-contact* *snipMate-author* 278 | 279 | To contact the author (Michael Sanders), please email: 280 | msanders42+snipmate gmail com 281 | 282 | I greatly appreciate any suggestions or improvements offered for the script. 283 | 284 | ============================================================================== 285 | 286 | vim:tw=78:ts=8:ft=help:norl: 287 | -------------------------------------------------------------------------------- /bundle/snipmate/doc/tags: -------------------------------------------------------------------------------- 1 | 'snippets' snipMate.txt /*'snippets'* 2 | .snippet snipMate.txt /*.snippet* 3 | .snippets snipMate.txt /*.snippets* 4 | ExtractSnips() snipMate.txt /*ExtractSnips()* 5 | ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()* 6 | Filename() snipMate.txt /*Filename()* 7 | ResetSnippets() snipMate.txt /*ResetSnippets()* 8 | g:snippets_dir snipMate.txt /*g:snippets_dir* 9 | g:snips_author snipMate.txt /*g:snips_author* 10 | i_CTRL-R_ snipMate.txt /*i_CTRL-R_* 11 | list-snippets snipMate.txt /*list-snippets* 12 | multi_snip snipMate.txt /*multi_snip* 13 | snipMate snipMate.txt /*snipMate* 14 | snipMate-$# snipMate.txt /*snipMate-$#* 15 | snipMate-${#:} snipMate.txt /*snipMate-${#:}* 16 | snipMate-${#} snipMate.txt /*snipMate-${#}* 17 | snipMate-author snipMate.txt /*snipMate-author* 18 | snipMate-commands snipMate.txt /*snipMate-commands* 19 | snipMate-contact snipMate.txt /*snipMate-contact* 20 | snipMate-description snipMate.txt /*snipMate-description* 21 | snipMate-disadvantages snipMate.txt /*snipMate-disadvantages* 22 | snipMate-expandtab snipMate.txt /*snipMate-expandtab* 23 | snipMate-features snipMate.txt /*snipMate-features* 24 | snipMate-filename snipMate.txt /*snipMate-filename* 25 | snipMate-indenting snipMate.txt /*snipMate-indenting* 26 | snipMate-placeholders snipMate.txt /*snipMate-placeholders* 27 | snipMate-remap snipMate.txt /*snipMate-remap* 28 | snipMate-settings snipMate.txt /*snipMate-settings* 29 | snipMate-usage snipMate.txt /*snipMate-usage* 30 | snipMate.txt snipMate.txt /*snipMate.txt* 31 | snippet snipMate.txt /*snippet* 32 | snippet-syntax snipMate.txt /*snippet-syntax* 33 | snippets snipMate.txt /*snippets* 34 | -------------------------------------------------------------------------------- /bundle/snipmate/ftplugin/html_snip_helper.vim: -------------------------------------------------------------------------------- 1 | " Helper function for (x)html snippets 2 | if exists('s:did_snip_helper') || &cp || !exists('loaded_snips') 3 | finish 4 | endif 5 | let s:did_snip_helper = 1 6 | 7 | " Automatically closes tag if in xhtml 8 | fun! Close() 9 | return stridx(&ft, 'xhtml') == -1 ? '' : ' /' 10 | endf 11 | -------------------------------------------------------------------------------- /bundle/snipmate/plugin/snipMate.vim: -------------------------------------------------------------------------------- 1 | " File: snipMate.vim 2 | " Author: Michael Sanders 3 | " Last Updated: July 13, 2009 4 | " Version: 0.83 5 | " Description: snipMate.vim implements some of TextMate's snippets features in 6 | " Vim. A snippet is a piece of often-typed text that you can 7 | " insert into your document using a trigger word followed by a "". 8 | " 9 | " For more help see snipMate.txt; you can do this by using: 10 | " :helptags ~/.vim/doc 11 | " :h snipMate.txt 12 | 13 | if exists('loaded_snips') || &cp || version < 700 14 | finish 15 | endif 16 | let loaded_snips = 1 17 | if !exists('snips_author') | let snips_author = 'Me' | endif 18 | 19 | au BufRead,BufNewFile *.snippets\= set ft=snippet 20 | au FileType snippet setl noet fdm=indent 21 | 22 | let s:snippets = {} | let s:multi_snips = {} 23 | 24 | if !exists('snippets_dir') 25 | let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g') 26 | endif 27 | 28 | fun! MakeSnip(scope, trigger, content, ...) 29 | let multisnip = a:0 && a:1 != '' 30 | let var = multisnip ? 's:multi_snips' : 's:snippets' 31 | if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif 32 | if !has_key({var}[a:scope], a:trigger) 33 | let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content 34 | elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]] 35 | else 36 | echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.' 37 | \ .' See :h multi_snip for help on snippets with multiple matches.' 38 | endif 39 | endf 40 | 41 | fun! ExtractSnips(dir, ft) 42 | for path in split(globpath(a:dir, '*'), "\n") 43 | if isdirectory(path) 44 | let pathname = fnamemodify(path, ':t') 45 | for snipFile in split(globpath(path, '*.snippet'), "\n") 46 | call s:ProcessFile(snipFile, a:ft, pathname) 47 | endfor 48 | elseif fnamemodify(path, ':e') == 'snippet' 49 | call s:ProcessFile(path, a:ft) 50 | endif 51 | endfor 52 | endf 53 | 54 | " Processes a single-snippet file; optionally add the name of the parent 55 | " directory for a snippet with multiple matches. 56 | fun s:ProcessFile(file, ft, ...) 57 | let keyword = fnamemodify(a:file, ':t:r') 58 | if keyword == '' | return | endif 59 | try 60 | let text = join(readfile(a:file), "\n") 61 | catch /E484/ 62 | echom "Error in snipMate.vim: couldn't read file: ".a:file 63 | endtry 64 | return a:0 ? MakeSnip(a:ft, a:1, text, keyword) 65 | \ : MakeSnip(a:ft, keyword, text) 66 | endf 67 | 68 | fun! ExtractSnipsFile(file, ft) 69 | if !filereadable(a:file) | return | endif 70 | let text = readfile(a:file) 71 | let inSnip = 0 72 | for line in text + ["\n"] 73 | if inSnip && (line[0] == "\t" || line == '') 74 | let content .= strpart(line, 1)."\n" 75 | continue 76 | elseif inSnip 77 | call MakeSnip(a:ft, trigger, content[:-2], name) 78 | let inSnip = 0 79 | endif 80 | 81 | if line[:6] == 'snippet' 82 | let inSnip = 1 83 | let trigger = strpart(line, 8) 84 | let name = '' 85 | let space = stridx(trigger, ' ') + 1 86 | if space " Process multi snip 87 | let name = strpart(trigger, space) 88 | let trigger = strpart(trigger, 0, space - 1) 89 | endif 90 | let content = '' 91 | endif 92 | endfor 93 | endf 94 | 95 | fun! ResetSnippets() 96 | let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {} 97 | endf 98 | 99 | let g:did_ft = {} 100 | fun! GetSnippets(dir, filetypes) 101 | for ft in split(a:filetypes, '\.') 102 | if has_key(g:did_ft, ft) | continue | endif 103 | call s:DefineSnips(a:dir, ft, ft) 104 | if ft == 'objc' || ft == 'cpp' || ft == 'cs' 105 | call s:DefineSnips(a:dir, 'c', ft) 106 | elseif ft == 'xhtml' 107 | call s:DefineSnips(a:dir, 'html', 'xhtml') 108 | endif 109 | let g:did_ft[ft] = 1 110 | endfor 111 | endf 112 | 113 | " Define "aliasft" snippets for the filetype "realft". 114 | fun s:DefineSnips(dir, aliasft, realft) 115 | for path in split(globpath(a:dir, a:aliasft.'/')."\n". 116 | \ globpath(a:dir, a:aliasft.'-*/'), "\n") 117 | call ExtractSnips(path, a:realft) 118 | endfor 119 | for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n". 120 | \ globpath(a:dir, a:aliasft.'-*.snippets'), "\n") 121 | call ExtractSnipsFile(path, a:realft) 122 | endfor 123 | endf 124 | 125 | fun! TriggerSnippet() 126 | if exists('g:SuperTabMappingForward') 127 | if g:SuperTabMappingForward == "" 128 | let SuperTabKey = "\" 129 | elseif g:SuperTabMappingBackward == "" 130 | let SuperTabKey = "\" 131 | endif 132 | endif 133 | 134 | if pumvisible() " Update snippet if completion is used, or deal with supertab 135 | if exists('SuperTabKey') 136 | call feedkeys(SuperTabKey) | return '' 137 | endif 138 | call feedkeys("\a", 'n') " Close completion menu 139 | call feedkeys("\") | return '' 140 | endif 141 | 142 | if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif 143 | 144 | let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') 145 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 146 | let [trigger, snippet] = s:GetSnippet(word, scope) 147 | " If word is a trigger for a snippet, delete the trigger & expand 148 | " the snippet. 149 | if snippet != '' 150 | let col = col('.') - len(trigger) 151 | sil exe 's/\V'.escape(trigger, '/.').'\%#//' 152 | return snipMate#expandSnip(snippet, col) 153 | endif 154 | endfor 155 | 156 | if exists('SuperTabKey') 157 | call feedkeys(SuperTabKey) 158 | return '' 159 | endif 160 | return "\" 161 | endf 162 | 163 | fun! BackwardsSnippet() 164 | if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif 165 | 166 | if exists('g:SuperTabMappingForward') 167 | if g:SuperTabMappingBackward == "" 168 | let SuperTabKey = "\" 169 | elseif g:SuperTabMappingForward == "" 170 | let SuperTabKey = "\" 171 | endif 172 | endif 173 | if exists('SuperTabKey') 174 | call feedkeys(SuperTabKey) 175 | return '' 176 | endif 177 | return "\" 178 | endf 179 | 180 | " Check if word under cursor is snippet trigger; if it isn't, try checking if 181 | " the text after non-word characters is (e.g. check for "foo" in "bar.foo") 182 | fun s:GetSnippet(word, scope) 183 | let word = a:word | let snippet = '' 184 | while snippet == '' 185 | if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]') 186 | let snippet = s:snippets[a:scope][word] 187 | elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]') 188 | let snippet = s:ChooseSnippet(a:scope, word) 189 | if snippet == '' | break | endif 190 | else 191 | if match(word, '\W') == -1 | break | endif 192 | let word = substitute(word, '.\{-}\W', '', '') 193 | endif 194 | endw 195 | if word == '' && a:word != '.' && stridx(a:word, '.') != -1 196 | let [word, snippet] = s:GetSnippet('.', a:scope) 197 | endif 198 | return [word, snippet] 199 | endf 200 | 201 | fun s:ChooseSnippet(scope, trigger) 202 | let snippet = [] 203 | let i = 1 204 | for snip in s:multi_snips[a:scope][a:trigger] 205 | let snippet += [i.'. '.snip[0]] 206 | let i += 1 207 | endfor 208 | if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif 209 | let num = inputlist(snippet) - 1 210 | return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1] 211 | endf 212 | 213 | fun! ShowAvailableSnips() 214 | let line = getline('.') 215 | let col = col('.') 216 | let word = matchstr(getline('.'), '\S\+\%'.col.'c') 217 | let words = [word] 218 | if stridx(word, '.') 219 | let words += split(word, '\.', 1) 220 | endif 221 | let matchlen = 0 222 | let matches = [] 223 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 224 | let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : [] 225 | if has_key(s:multi_snips, scope) 226 | let triggers += keys(s:multi_snips[scope]) 227 | endif 228 | for trigger in triggers 229 | for word in words 230 | if word == '' 231 | let matches += [trigger] " Show all matches if word is empty 232 | elseif trigger =~ '^'.word 233 | let matches += [trigger] 234 | let len = len(word) 235 | if len > matchlen | let matchlen = len | endif 236 | endif 237 | endfor 238 | endfor 239 | endfor 240 | 241 | " This is to avoid a bug with Vim when using complete(col - matchlen, matches) 242 | " (Issue#46 on the Google Code snipMate issue tracker). 243 | call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', '')) 244 | call complete(col, matches) 245 | return '' 246 | endf 247 | " vim:noet:sw=4:ts=4:ft=vim 248 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/_.snippets: -------------------------------------------------------------------------------- 1 | # Global snippets 2 | 3 | # (c) holds no legal value ;) 4 | snippet c) 5 | `&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} 6 | snippet date 7 | `strftime("%Y-%m-%d")` 8 | snippet divcode 9 | {% highlight ${1:console} %} 10 | {% endhighlight %} 11 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/autoit.snippets: -------------------------------------------------------------------------------- 1 | snippet if 2 | If ${1:condition} Then 3 | ${2:; True code} 4 | EndIf 5 | snippet el 6 | Else 7 | ${1} 8 | snippet elif 9 | ElseIf ${1:condition} Then 10 | ${2:; True code} 11 | # If/Else block 12 | snippet ifel 13 | If ${1:condition} Then 14 | ${2:; True code} 15 | Else 16 | ${3:; Else code} 17 | EndIf 18 | # If/ElseIf/Else block 19 | snippet ifelif 20 | If ${1:condition 1} Then 21 | ${2:; True code} 22 | ElseIf ${3:condition 2} Then 23 | ${4:; True code} 24 | Else 25 | ${5:; Else code} 26 | EndIf 27 | # Switch block 28 | snippet switch 29 | Switch (${1:condition}) 30 | Case {$2:case1}: 31 | {$3:; Case 1 code} 32 | Case Else: 33 | {$4:; Else code} 34 | EndSwitch 35 | # Select block 36 | snippet select 37 | Select (${1:condition}) 38 | Case {$2:case1}: 39 | {$3:; Case 1 code} 40 | Case Else: 41 | {$4:; Else code} 42 | EndSelect 43 | # While loop 44 | snippet while 45 | While (${1:condition}) 46 | ${2:; code...} 47 | WEnd 48 | # For loop 49 | snippet for 50 | For ${1:n} = ${3:1} to ${2:count} 51 | ${4:; code...} 52 | Next 53 | # New Function 54 | snippet func 55 | Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 56 | ${4:Return} 57 | EndFunc 58 | # Message box 59 | snippet msg 60 | MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"}) 61 | # Debug Message 62 | snippet debug 63 | MsgBox(0, "Debug", ${1:"Debug Message"}) 64 | # Show Variable Debug Message 65 | snippet showvar 66 | MsgBox(0, "${1:VarName}", $1) 67 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/c.snippets: -------------------------------------------------------------------------------- 1 | snippet dog 2 | I love dog 3 | 4 | # test 5 | snippet oo 6 | (${1})${2} 7 | # main() 8 | snippet main 9 | #include 10 | 11 | int main(int argc, const char *argv[]) 12 | { 13 | ${1} 14 | return 0; 15 | } 16 | # #include <...> 17 | snippet inc 18 | #include <${1:stdio}.h>${2} 19 | # #include "..." 20 | snippet Inc 21 | snippet Def 22 | #ifndef $1 23 | #define ${1:SYMBOL} ${2:value} 24 | #endif${3} 25 | snippet def 26 | #define 27 | snippet ifdef 28 | #ifdef ${1:FOO} 29 | ${2:#define } 30 | #endif 31 | snippet #if 32 | #if ${1:FOO} 33 | ${2} 34 | #endif 35 | # Header Include-Guard 36 | # (the randomizer code is taken directly from TextMate; it could probably be 37 | # cleaner, I don't know how to do it in vim script) 38 | snippet once 39 | #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`} 40 | 41 | #define $1 42 | 43 | ${2} 44 | 45 | #endif /* end of include guard: $1 */ 46 | # If Condition 47 | snippet if 48 | if (${1:/* condition */}) 49 | { 50 | ${2:/* code */} 51 | } 52 | snippet el 53 | else 54 | { 55 | ${1} 56 | } 57 | # Tertiary conditional 58 | snippet t 59 | ${1:/* condition */} ? ${2:a} : ${3:b} 60 | # Do While Loop 61 | snippet do 62 | do 63 | { 64 | ${2:/* code */} 65 | } while (${1:/* condition */}); 66 | # While Loop 67 | snippet wh 68 | while (${1:/* condition */}) 69 | { 70 | ${2:/* code */} 71 | } 72 | # For Loop 73 | snippet for 74 | for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) 75 | { 76 | ${4:/* code */} 77 | } 78 | # Custom For Loop 79 | snippet forr 80 | for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { 81 | ${5:/* code */} 82 | } 83 | # Function 84 | snippet fun 85 | ${1:void} ${2:function_name}(${3}) 86 | { 87 | ${4:/* code */} 88 | } 89 | # Function Declaration 90 | snippet fund 91 | ${1:void} ${2:function_name}(${3});${4} 92 | # Typedef 93 | snippet td 94 | typedef ${1:int} ${2:MyCustomType};${3} 95 | # Struct 96 | snippet st 97 | struct ${1:`Filename('$1_t', 'name')`} { 98 | ${2:/* data */} 99 | }${3: /* optional variable list */};${4} 100 | # Typedef struct 101 | snippet tds 102 | typedef struct ${2:_$1 }{ 103 | ${3:/* data */} 104 | } ${1:`Filename('$1_t', 'name')`}; 105 | # Typdef enum 106 | snippet tde 107 | typedef enum { 108 | ${1:/* data */} 109 | } ${2:foo}; 110 | # printf 111 | # unfortunately version this isn't as nice as TextMates's, given the lack of a 112 | # dynamic `...` 113 | snippet pr 114 | printf("${1:%s}\n"${2});${3} 115 | # fprintf (again, this isn't as nice as TextMate's version, but it works) 116 | snippet fpr 117 | fprintf(${1:stderr}, "${2:%s}\n"${3});${4} 118 | snippet . 119 | [${1}]${2} 120 | snippet un 121 | unsigned 122 | 123 | snippet xxx 124 | ${1:id} ${2:name}() 125 | { 126 | print hello 127 | ${3:/* peter */} 128 | } 129 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/cpp.snippets: -------------------------------------------------------------------------------- 1 | # Read File Into Vector 2 | snippet readfile 3 | std::vector v; 4 | if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) { 5 | char buf[1024]; 6 | while (size_t len = fread(buf, 1, sizeof(buf), $2)) 7 | v.insert(v.end(), buf, buf + len); 8 | fclose($2); 9 | }${3} 10 | # std::map 11 | snippet map 12 | std::map<${1:key}, ${2:value}> map${3}; 13 | # std::vector 14 | snippet vector 15 | std::vector<${1:char}> v${2}; 16 | # Namespace 17 | snippet ns 18 | namespace ${1:`Filename('', 'my')`} { 19 | ${2} 20 | } /* $1 */ 21 | # Class 22 | snippet cl 23 | class ${1:`Filename('$1_t', 'name')`} { 24 | public: 25 | $1 (${2:arguments}); 26 | virtual ~$1 (); 27 | 28 | private: 29 | ${3:/* data */} 30 | }; 31 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/css.snippets: -------------------------------------------------------------------------------- 1 | snippet border 2 | border: 1px solid ${1:red};${2} 3 | snippet t 4 | ${1:name} { 5 | ${2:attr}: ${3:value}; 6 | } 7 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/eruby.snippets: -------------------------------------------------------------------------------- 1 | snippet div 2 |
3 | ${2} 4 |
5 | snippet == 6 | <%= ${1} %> 7 | snippet -- 8 | <% ${1:} %> 9 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/html.snippets: -------------------------------------------------------------------------------- 1 | snippet ul 2 |
    3 |
  • ${2}
  • 4 |
  • ${3}
  • 5 |
6 | snippet img 7 | 8 | ${2} 9 | snippet ipsum 10 | Pellentesque habitant morbi tristique senectus et netus et malesuada fames 11 | ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, 12 | tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean 13 | ultricies mi vitae est. Mauris placerat eleifend leo. 14 | snippet t 15 | ${1:name} { 16 | ${2:attr}: ${3:value}; 17 | } 18 | snippet jq 19 | 20 | snippet js 21 | 22 | # Some useful Unicode entities 23 | # Non-Breaking Space 24 | snippet nbs 25 |   26 | # ← 27 | snippet left 28 | ← 29 | # → 30 | snippet right 31 | → 32 | # ↑ 33 | snippet up 34 | ↑ 35 | # ↓ 36 | snippet down 37 | ↓ 38 | # ↩ 39 | # ⌘ 40 | snippet command 41 | ⌘ 42 | # ⌥ 43 | snippet option 44 | ⌥ 45 | # ⎋ 46 | snippet escape 47 | ⎋ 48 | # Generic Doctype 49 | # HTML Doctype 5 50 | snippet doct5 51 | 52 | # XHTML Doctype 1.0 Frameset 53 | snippet html 54 | 55 | 56 | ${1} 57 | 58 | snippet body 59 | 60 | ${1} 61 | 62 | snippet head 63 | 64 | 65 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} 66 | ${2} 67 | 68 | snippet title 69 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}${2} 70 | snippet script 71 | ${2} 74 | snippet scriptsrc 75 | ${2} 76 | snippet jquery 77 | 78 | 79 | snippet style 80 | ${2} 83 | snippet div 84 |
85 | ${2} 86 |
87 | snippet p 88 |

89 | ${1} 90 |

${2} 91 |

92 | ${2} 93 | snippet span 94 | 95 | ${2} 96 | 97 | # Embed QT Movie 98 | snippet form 99 |
100 | ${3} 101 | 102 | 103 |

104 |
105 | snippet h1 106 |

${1}

107 | snippet input 108 | ${4} 109 | snippet label 110 | ${7} 111 | snippet link 112 | ${2} 113 | snippet mailto 114 | ${3:email me} 115 | snippet meta 116 | ${3} 117 | snippet opt 118 | ${3} 119 | snippet optt 120 | ${2} 121 | snippet select 122 | ${5} 125 | snippet table 126 | 127 | 128 | 129 |
${2:Header}
${3:Data}
${4} 130 | snippet textarea 131 | 132 | snippet hello 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | ${1} 142 | 143 | 144 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/java.snippets: -------------------------------------------------------------------------------- 1 | snippet main 2 | public static void main (String [] args) 3 | { 4 | ${1:/* code */} 5 | } 6 | snippet pu 7 | public 8 | snippet po 9 | protected 10 | snippet pr 11 | private 12 | snippet st 13 | static 14 | snippet fi 15 | final 16 | snippet ab 17 | abstract 18 | snippet re 19 | return 20 | snippet br 21 | break; 22 | snippet de 23 | default: 24 | ${1} 25 | snippet ca 26 | catch(${1:Exception} ${2:e}) ${3} 27 | snippet th 28 | throw 29 | snippet sy 30 | synchronized 31 | snippet im 32 | import 33 | snippet j.u 34 | java.util 35 | snippet j.i 36 | java.io. 37 | snippet j.b 38 | java.beans. 39 | snippet j.n 40 | java.net. 41 | snippet j.m 42 | java.math. 43 | snippet if 44 | if (${1}) ${2} 45 | snippet el 46 | else 47 | snippet elif 48 | else if (${1}) ${2} 49 | snippet wh 50 | while (${1}) ${2} 51 | snippet for 52 | for (${1}; ${2}; ${3}) ${4} 53 | snippet fore 54 | for (${1} : ${2}) ${3} 55 | snippet sw 56 | switch (${1}) ${2} 57 | snippet cs 58 | case ${1}: 59 | ${2} 60 | ${3} 61 | snippet tc 62 | public class ${1:`Filename()`} extends ${2:TestCase} 63 | snippet t 64 | public void test${1:Name}() throws Exception ${2} 65 | snippet cl 66 | class ${1:`Filename("", "untitled")`} ${2} 67 | snippet in 68 | interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} 69 | snippet m 70 | ${1:void} ${2:method}(${3}) ${4:throws }${5} 71 | snippet v 72 | ${1:String} ${2:var}${3: = null}${4};${5} 73 | snippet co 74 | static public final ${1:String} ${2:var} = ${3};${4} 75 | snippet cos 76 | static public final String ${1:var} = "${2}";${3} 77 | snippet as 78 | assert ${1:test} : "${2:Failure message}";${3} 79 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/javascript.snippets: -------------------------------------------------------------------------------- 1 | # Prototype 2 | snippet proto 3 | ${1:class_name}.prototype.${2:method_name} = 4 | function(${3:first_argument}) { 5 | ${4:// body...} 6 | }; 7 | # Function 8 | snippet fun 9 | function ${1:function_name} (${2:argument}) { 10 | ${3:// body...} 11 | } 12 | # Anonymous Function 13 | snippet f 14 | function(${1}) {${2}}; 15 | # if 16 | snippet if 17 | if (${1:true}) {${2}}; 18 | # if ... else 19 | snippet ife 20 | if (${1:true}) {${2}} 21 | else{${3}}; 22 | # tertiary conditional 23 | snippet t 24 | ${1:/* condition */} ? ${2:a} : ${3:b} 25 | # switch 26 | snippet switch 27 | switch(${1:expression}) { 28 | case '${3:case}': 29 | ${4:// code} 30 | break; 31 | ${5} 32 | default: 33 | ${2:// code} 34 | } 35 | # case 36 | snippet case 37 | case '${1:case}': 38 | ${2:// code} 39 | break; 40 | ${3} 41 | # for (...) {...} 42 | snippet for 43 | for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { 44 | ${4:$1[$2]} 45 | }; 46 | # for (...) {...} (Improved Native For-Loop) 47 | snippet forr 48 | for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { 49 | ${4:$1[$2]} 50 | }; 51 | # while (...) {...} 52 | snippet wh 53 | while (${1:/* condition */}) { 54 | ${2:/* code */} 55 | } 56 | # do...while 57 | snippet do 58 | do { 59 | ${2:/* code */} 60 | } while (${1:/* condition */}); 61 | # Object Method 62 | snippet :f 63 | ${1:method_name}: function(${2:attribute}) { 64 | ${4} 65 | }${3:,} 66 | # setTimeout function 67 | snippet timeout 68 | setTimeout(function() {${3}}${2}, ${1:10}; 69 | # Get Elements 70 | snippet get 71 | getElementsBy${1:TagName}('${2}')${3} 72 | # Get Element 73 | snippet gett 74 | getElementBy${1:Id}('${2}')${3} 75 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/mako.snippets: -------------------------------------------------------------------------------- 1 | snippet def 2 | <%def name="${1:name}"> 3 | ${2:} 4 | 5 | snippet call 6 | <%call expr="${1:name}"> 7 | ${2:} 8 | 9 | snippet doc 10 | <%doc> 11 | ${1:} 12 | 13 | snippet text 14 | <%text> 15 | ${1:} 16 | 17 | snippet for 18 | % for ${1:i} in ${2:iter}: 19 | ${3:} 20 | % endfor 21 | snippet if if 22 | % if ${1:condition}: 23 | ${2:} 24 | % endif 25 | snippet if if/else 26 | % if ${1:condition}: 27 | ${2:} 28 | % else: 29 | ${3:} 30 | % endif 31 | snippet try 32 | % try: 33 | ${1:} 34 | % except${2:}: 35 | ${3:pass} 36 | % endtry 37 | snippet wh 38 | % while ${1:}: 39 | ${2:} 40 | % endwhile 41 | snippet $ 42 | ${ ${1:} } 43 | snippet <% 44 | <% ${1:} %> 45 | snippet 47 | snippet inherit 48 | <%inherit file="${1:filename}" /> 49 | snippet include 50 | <%include file="${1:filename}" /> 51 | snippet namespace 52 | <%namespace file="${1:name}" /> 53 | snippet page 54 | <%page args="${1:}" /> 55 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/objc.snippets: -------------------------------------------------------------------------------- 1 | # #import <...> 2 | snippet Imp 3 | #import <${1:Cocoa/Cocoa.h}>${2} 4 | # #import "..." 5 | snippet imp 6 | #import "${1:`Filename()`.h}"${2} 7 | # @selector(...) 8 | snippet sel 9 | @selector(${1:method}:)${3} 10 | # @"..." string 11 | snippet s 12 | @"${1}"${2} 13 | # Object 14 | snippet o 15 | ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5} 16 | # NSLog(...) 17 | snippet log 18 | NSLog(@"${1:%@}"${2});${3} 19 | # Class 20 | snippet objc 21 | @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} 22 | { 23 | } 24 | @end 25 | 26 | @implementation $1 27 | ${3} 28 | @end 29 | # Class Interface 30 | snippet int 31 | @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} 32 | {${3} 33 | } 34 | ${4} 35 | @end 36 | # Class Implementation 37 | snippet impl 38 | @implementation ${1:`Filename('', 'someClass')`} 39 | ${2} 40 | @end 41 | snippet init 42 | - (id)init 43 | { 44 | [super init]; 45 | return self; 46 | } 47 | snippet ifself 48 | if (self = [super init]) { 49 | ${1:/* code */} 50 | } 51 | return self; 52 | snippet ibo 53 | IBOutlet ${1:NSSomeClass} *${2:$1};${3} 54 | # Category 55 | snippet cat 56 | @interface ${1:NSObject} (${2:Category}) 57 | @end 58 | 59 | @implementation $1 ($2) 60 | ${3} 61 | @end 62 | # Category Interface 63 | snippet cath 64 | @interface ${1:NSObject} (${2:Category}) 65 | ${3} 66 | @end 67 | # NSArray 68 | snippet array 69 | NSMutableArray *${1:array} = [NSMutable array];${2} 70 | # NSDictionary 71 | snippet dict 72 | NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} 73 | # NSBezierPath 74 | snippet bez 75 | NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2} 76 | # Method 77 | snippet m 78 | - (${1:id})${2:method} 79 | { 80 | ${3} 81 | } 82 | # Method declaration 83 | snippet md 84 | - (${1:id})${2:method};${3} 85 | # IBAction declaration 86 | snippet ibad 87 | - (IBAction)${1:method}:(${2:id})sender;${3} 88 | # IBAction method 89 | snippet iba 90 | - (IBAction)${1:method}:(${2:id})sender 91 | { 92 | ${3} 93 | } 94 | # awakeFromNib method 95 | snippet wake 96 | - (void)awakeFromNib 97 | { 98 | ${1} 99 | } 100 | # Class Method 101 | snippet M 102 | + (${1:id})${2:method} 103 | {${3} 104 | return nil; 105 | } 106 | # Sub-method (Call super) 107 | snippet sm 108 | - (${1:id})${2:method} 109 | { 110 | [super $2];${3} 111 | return self; 112 | } 113 | # Method: Initialize 114 | snippet I 115 | + (void) initialize 116 | { 117 | [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys: 118 | ${1}@"value", @"key", 119 | nil]]; 120 | } 121 | # Accessor Methods For: 122 | # Object 123 | snippet objacc 124 | - (${1:id})${2:thing} 125 | { 126 | return $2; 127 | } 128 | 129 | - (void)set$2:($1)${3:new$2} 130 | { 131 | [$3 retain]; 132 | [$2 release]; 133 | $2 = $3; 134 | }${4} 135 | # for (object in array) 136 | snippet forin 137 | for (${1:Class} *${2:some$1} in ${3:array}) { 138 | ${4} 139 | } 140 | snippet forarray 141 | unsigned int ${1:object}Count = [${2:array} count]; 142 | 143 | for (unsigned int index = 0; index < $1Count; index++) { 144 | ${3:id} $1 = [$2 $1AtIndex:index]; 145 | ${4} 146 | } 147 | # IBOutlet 148 | # @property (Objective-C 2.0) 149 | snippet prop 150 | @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4} 151 | # @synthesize (Objective-C 2.0) 152 | snippet syn 153 | @synthesize ${1:property};${2} 154 | # [[ alloc] init] 155 | snippet alloc 156 | [[${1:foo} alloc] init${2}];${3} 157 | # retain 158 | snippet ret 159 | [${1:foo} retain];${2} 160 | # release 161 | snippet rel 162 | [${1:foo} release]; 163 | ${2:$1 = nil;} 164 | # autorelease 165 | snippet arel 166 | [${1:foo} autorelease]; 167 | # autorelease pool 168 | snippet pool 169 | NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; 170 | ${2:/* code */} 171 | [$1 drain]; 172 | # Throw an exception 173 | snippet except 174 | NSException *${1:badness}; 175 | $1 = [NSException exceptionWithName:@"${2:$1Name}" 176 | reason:@"${3}" 177 | userInfo:nil]; 178 | [$1 raise]; 179 | snippet prag 180 | #pragma mark ${1:foo} 181 | snippet cl 182 | @class ${1:Foo};${2} 183 | snippet color 184 | [[NSColor ${1:blackColor}] set]; 185 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/perl.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/perl 2 | snippet #! 3 | #!/usr/bin/perl 4 | 5 | # Hash Pointer 6 | snippet . 7 | => 8 | # Function 9 | snippet sub 10 | sub ${1:function_name} { 11 | ${2:#body ...} 12 | } 13 | # Conditional 14 | snippet if 15 | if (${1}) { 16 | ${2:# body...} 17 | } 18 | # Conditional if..else 19 | snippet ife 20 | if (${1}) { 21 | ${2:# body...} 22 | } else { 23 | ${3:# else...} 24 | } 25 | # Conditional if..elsif..else 26 | snippet ifee 27 | if (${1}) { 28 | ${2:# body...} 29 | } elsif (${3}) { 30 | ${4:# elsif...} 31 | } else { 32 | ${5:# else...} 33 | } 34 | # Conditional One-line 35 | snippet xif 36 | ${1:expression} if ${2:condition};${3} 37 | # Unless conditional 38 | snippet unless 39 | unless (${1}) { 40 | ${2:# body...} 41 | } 42 | # Unless conditional One-line 43 | snippet xunless 44 | ${1:expression} unless ${2:condition};${3} 45 | # Try/Except 46 | snippet eval 47 | eval { 48 | ${1:# do something risky...} 49 | }; 50 | if ($@) { 51 | ${2:# handle failure...} 52 | } 53 | # While Loop 54 | snippet wh 55 | while (${1}) { 56 | ${2:# body...} 57 | } 58 | # While Loop One-line 59 | snippet xwh 60 | ${1:expression} while ${2:condition};${3} 61 | # For Loop 62 | snippet for 63 | for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { 64 | ${4:# body...} 65 | } 66 | # Foreach Loop 67 | snippet fore 68 | foreach my $${1:x} (@${2:array}) { 69 | ${3:# body...} 70 | } 71 | # Foreach Loop One-line 72 | snippet xfore 73 | ${1:expression} foreach @${2:array};${3} 74 | # Package 75 | snippet cl 76 | package ${1:ClassName}; 77 | 78 | use base qw(${2:ParentClass}); 79 | 80 | sub new { 81 | my $class = shift; 82 | $class = ref $class if ref $class; 83 | my $self = bless {}, $class; 84 | $self; 85 | } 86 | 87 | 1;${3} 88 | # Read File 89 | snippet slurp 90 | my $${1:var}; 91 | { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE }${3} 92 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/php.snippets: -------------------------------------------------------------------------------- 1 | snippet php 2 | 5 | snippet ec 6 | echo "${1:string}"${2}; 7 | snippet inc 8 | include '${1:file}';${2} 9 | snippet inc1 10 | include_once '${1:file}';${2} 11 | snippet req 12 | require '${1:file}';${2} 13 | snippet req1 14 | require_once '${1:file}';${2} 15 | # $GLOBALS['...'] 16 | snippet globals 17 | $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} 18 | snippet $_ COOKIE['...'] 19 | $_COOKIE['${1:variable}']${2} 20 | snippet $_ ENV['...'] 21 | $_ENV['${1:variable}']${2} 22 | snippet $_ FILES['...'] 23 | $_FILES['${1:variable}']${2} 24 | snippet $_ Get['...'] 25 | $_GET['${1:variable}']${2} 26 | snippet $_ POST['...'] 27 | $_POST['${1:variable}']${2} 28 | snippet $_ REQUEST['...'] 29 | $_REQUEST['${1:variable}']${2} 30 | snippet $_ SERVER['...'] 31 | $_SERVER['${1:variable}']${2} 32 | snippet $_ SESSION['...'] 33 | $_SESSION['${1:variable}']${2} 34 | # Start Docblock 35 | snippet /* 36 | /** 37 | * ${1} 38 | **/ 39 | # Class - post doc 40 | snippet doc_cp 41 | /** 42 | * ${1:undocumented class} 43 | * 44 | * @package ${2:default} 45 | * @author ${3:`g:snips_author`} 46 | **/${4} 47 | # Class Variable - post doc 48 | snippet doc_vp 49 | /** 50 | * ${1:undocumented class variable} 51 | * 52 | * @var ${2:string} 53 | **/${3} 54 | # Class Variable 55 | snippet doc_v 56 | /** 57 | * ${3:undocumented class variable} 58 | * 59 | * @var ${4:string} 60 | **/ 61 | ${1:var} $${2};${5} 62 | # Class 63 | snippet doc_c 64 | /** 65 | * ${3:undocumented class} 66 | * 67 | * @packaged ${4:default} 68 | * @author ${5:`g:snips_author`} 69 | **/ 70 | ${1:}class ${2:} 71 | {${6} 72 | } // END $1class $2 73 | # Constant Definition - post doc 74 | snippet doc_dp 75 | /** 76 | * ${1:undocumented constant} 77 | **/${2} 78 | # Constant Definition 79 | snippet doc_d 80 | /** 81 | * ${3:undocumented constant} 82 | **/ 83 | define(${1}, ${2});${4} 84 | # Function - post doc 85 | snippet doc_fp 86 | /** 87 | * ${1:undocumented function} 88 | * 89 | * @return ${2:void} 90 | * @author ${3:`g:snips_author`} 91 | **/${4} 92 | # Function signature 93 | snippet doc_s 94 | /** 95 | * ${4:undocumented function} 96 | * 97 | * @return ${5:void} 98 | * @author ${6:`g:snips_author`} 99 | **/ 100 | ${1}function ${2}(${3});${7} 101 | # Function 102 | snippet doc_f 103 | /** 104 | * ${4:undocumented function} 105 | * 106 | * @return ${5:void} 107 | * @author ${6:`g:snips_author`} 108 | **/ 109 | ${1}function ${2}(${3}) 110 | {${7} 111 | } 112 | # Header 113 | snippet doc_h 114 | /** 115 | * ${1} 116 | * 117 | * @author ${2:`g:snips_author`} 118 | * @version ${3:$Id$} 119 | * @copyright ${4:$2}, `strftime('%d %B, %Y')` 120 | * @package ${5:default} 121 | **/ 122 | 123 | /** 124 | * Define DocBlock 125 | *// 126 | # Interface 127 | snippet doc_i 128 | /** 129 | * ${2:undocumented class} 130 | * 131 | * @package ${3:default} 132 | * @author ${4:`g:snips_author`} 133 | **/ 134 | interface ${1:} 135 | {${5} 136 | } // END interface $1 137 | # class ... 138 | snippet class 139 | /** 140 | * ${1} 141 | **/ 142 | class ${2:ClassName} 143 | { 144 | ${3} 145 | function ${4:__construct}(${5:argument}) 146 | { 147 | ${6:// code...} 148 | } 149 | } 150 | # define(...) 151 | snippet def 152 | define('${1}'${2});${3} 153 | # defined(...) 154 | snippet def? 155 | ${1}defined('${2}')${3} 156 | snippet wh 157 | while (${1:/* condition */}) { 158 | ${2:// code...} 159 | } 160 | # do ... while 161 | snippet do 162 | do { 163 | ${2:// code... } 164 | } while (${1:/* condition */}); 165 | snippet if 166 | if (${1:/* condition */}) { 167 | ${2:// code...} 168 | } 169 | snippet ife 170 | if (${1:/* condition */}) { 171 | ${2:// code...} 172 | } else { 173 | ${3:// code...} 174 | } 175 | ${4} 176 | snippet else 177 | else { 178 | ${1:// code...} 179 | } 180 | snippet elseif 181 | elseif (${1:/* condition */}) { 182 | ${2:// code...} 183 | } 184 | # Tertiary conditional 185 | snippet t 186 | $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} 187 | snippet switch 188 | switch ($${1:variable}) { 189 | case '${2:value}': 190 | ${3:// code...} 191 | break; 192 | ${5} 193 | default: 194 | ${4:// code...} 195 | break; 196 | } 197 | snippet case 198 | case '${1:value}': 199 | ${2:// code...} 200 | break;${3} 201 | snippet for 202 | for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { 203 | ${4: // code...} 204 | } 205 | snippet foreach 206 | foreach ($${1:variable} as $${2:key}) { 207 | ${3:// code...} 208 | } 209 | snippet fun 210 | ${1:public }function ${2:FunctionName}(${3}) 211 | { 212 | ${4:// code...} 213 | } 214 | # $... = array (...) 215 | snippet array 216 | $${1:arrayName} = array('${2}' => ${3});${4} 217 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/python.snippets: -------------------------------------------------------------------------------- 1 | snippet pdb 2 | import pdb; pdb.set_trace() 3 | snippet #! 4 | #!/usr/bin/python 5 | 6 | snippet imp 7 | import ${1:module} 8 | # Module Docstring 9 | snippet docs 10 | ''' 11 | File: ${1:`Filename('$1.py', 'foo.py')`} 12 | Author: ${2:`g:snips_author`} 13 | Description: ${3} 14 | ''' 15 | snippet wh 16 | while ${1:condition}: 17 | ${2:# code...} 18 | snippet for 19 | for ${1:needle} in ${2:haystack}: 20 | ${3:# code...} 21 | # New Class 22 | snippet cl 23 | class ${1:ClassName}(${2:object}): 24 | """${3:docstring for $1}""" 25 | def __init__(self, ${4:arg}): 26 | ${5:super($1, self).__init__()} 27 | self.$4 = $4 28 | ${6} 29 | # New Function 30 | snippet def 31 | def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 32 | """${3:docstring for $1}""" 33 | ${4:pass} 34 | snippet deff 35 | def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 36 | ${3} 37 | # New Method 38 | snippet defs 39 | def ${1:mname}(self, ${2:arg}): 40 | ${3:pass} 41 | # New Property 42 | snippet property 43 | def ${1:foo}(): 44 | doc = "${2:The $1 property.}" 45 | def fget(self): 46 | ${3:return self._$1} 47 | def fset(self, value): 48 | ${4:self._$1 = value} 49 | # Lambda 50 | snippet ld 51 | ${1:var} = lambda ${2:vars} : ${3:action} 52 | snippet . 53 | self. 54 | snippet try Try/Except 55 | try: 56 | ${1:pass} 57 | except ${2:Exception}, ${3:e}: 58 | ${4:raise $3} 59 | snippet try Try/Except/Else 60 | try: 61 | ${1:pass} 62 | except ${2:Exception}, ${3:e}: 63 | ${4:raise $3} 64 | else: 65 | ${5:pass} 66 | snippet try Try/Except/Finally 67 | try: 68 | ${1:pass} 69 | except ${2:Exception}, ${3:e}: 70 | ${4:raise $3} 71 | finally: 72 | ${5:pass} 73 | snippet try Try/Except/Else/Finally 74 | try: 75 | ${1:pass} 76 | except ${2:Exception}, ${3:e}: 77 | ${4:raise $3} 78 | else: 79 | ${5:pass} 80 | finally: 81 | ${6:pass} 82 | # if __name__ == '__main__': 83 | snippet ifmain 84 | if __name__ == '__main__': 85 | ${1:main()} 86 | # __magic__ 87 | snippet _ 88 | __${1:init}__${2} 89 | snippet pr 90 | print "${1:hello}"${2: } 91 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/ruby.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/ruby 2 | snippet #! 3 | #!/usr/bin/ruby 4 | 5 | snippet get 6 | get "${1}" => "${2}" 7 | # New Block 8 | snippet =b 9 | =begin rdoc 10 | ${1} 11 | =end 12 | snippet y 13 | :yields: ${1:arguments} 14 | snippet rb 15 | #!/usr/bin/env ruby -wKU 16 | 17 | snippet req 18 | require "${1}"${2} 19 | snippet # 20 | # => 21 | snippet end 22 | __END__ 23 | snippet case 24 | case ${1:object} 25 | when ${2:condition} 26 | ${3} 27 | end 28 | snippet when 29 | when ${1:condition} 30 | ${2} 31 | snippet def 32 | def ${1:method_name} 33 | ${2} 34 | end 35 | snippet deft 36 | def test_${1:case_name} 37 | ${2} 38 | end 39 | snippet if 40 | if ${1:condition} 41 | ${2} 42 | end 43 | snippet ife 44 | if ${1:condition} 45 | ${2} 46 | else 47 | ${3} 48 | end 49 | snippet elsif 50 | elsif ${1:condition} 51 | ${2} 52 | snippet unless 53 | unless ${1:condition} 54 | ${2} 55 | end 56 | snippet while 57 | while ${1:condition} 58 | ${2} 59 | end 60 | snippet until 61 | until ${1:condition} 62 | ${2} 63 | end 64 | snippet cla class .. end 65 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} 66 | ${2} 67 | end 68 | snippet cla class .. initialize .. end 69 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} 70 | def initialize(${2:args}) 71 | ${3} 72 | end 73 | 74 | 75 | end 76 | snippet cla class .. < ParentClass .. initialize .. end 77 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass} 78 | def initialize(${3:args}) 79 | ${4} 80 | end 81 | 82 | 83 | end 84 | snippet cla ClassName = Struct .. do .. end 85 | ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do 86 | def ${3:method_name} 87 | ${4} 88 | end 89 | 90 | 91 | end 92 | snippet cla class BlankSlate .. initialize .. end 93 | class ${1:BlankSlate} 94 | instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } 95 | snippet cla class << self .. end 96 | class << ${1:self} 97 | ${2} 98 | end 99 | # class .. < DelegateClass .. initialize .. end 100 | snippet cla- 101 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass}) 102 | def initialize(${3:args}) 103 | super(${4:del_obj}) 104 | 105 | ${5} 106 | end 107 | 108 | 109 | end 110 | snippet mod module .. end 111 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 112 | ${2} 113 | end 114 | snippet mod module .. module_function .. end 115 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 116 | module_function 117 | 118 | ${2} 119 | end 120 | snippet mod module .. ClassMethods .. end 121 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 122 | module ClassMethods 123 | ${2} 124 | end 125 | 126 | module InstanceMethods 127 | 128 | end 129 | 130 | def self.included(receiver) 131 | receiver.extend ClassMethods 132 | receiver.send :include, InstanceMethods 133 | end 134 | end 135 | # attr_reader 136 | snippet r 137 | attr_reader :${1:attr_names} 138 | # attr_writer 139 | snippet w 140 | attr_writer :${1:attr_names} 141 | # attr_accessor 142 | snippet rw 143 | attr_accessor :${1:attr_names} 144 | # include Enumerable 145 | snippet Enum 146 | include Enumerable 147 | 148 | def each(&block) 149 | ${1} 150 | end 151 | # include Comparable 152 | snippet Comp 153 | include Comparable 154 | 155 | def <=>(other) 156 | ${1} 157 | end 158 | # extend Forwardable 159 | snippet Forw- 160 | extend Forwardable 161 | # def self 162 | snippet defs 163 | def self.${1:class_method_name} 164 | ${2} 165 | end 166 | # def method_missing 167 | snippet defmm 168 | def method_missing(meth, *args, &blk) 169 | ${1} 170 | end 171 | snippet defd 172 | def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name} 173 | snippet defds 174 | def_delegators :${1:@del_obj}, :${2:del_methods} 175 | snippet am 176 | alias_method :${1:new_name}, :${2:old_name} 177 | snippet app 178 | if __FILE__ == $PROGRAM_NAME 179 | ${1} 180 | end 181 | # usage_if() 182 | snippet usai 183 | if ARGV.${1} 184 | abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} 185 | end 186 | # usage_unless() 187 | snippet usau 188 | unless ARGV.${1} 189 | abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} 190 | end 191 | snippet array 192 | Array.new(${1:10}) { |${2:i}| ${3} } 193 | snippet hash 194 | Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} } 195 | snippet file File.foreach() { |line| .. } 196 | File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} } 197 | snippet file File.read() 198 | File.read(${1:"path/to/file"})${2} 199 | snippet Dir Dir.global() { |file| .. } 200 | Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} } 201 | snippet Dir Dir[".."] 202 | Dir[${1:"glob/**/*.rb"}]${2} 203 | snippet dir 204 | Filename.dirname(__FILE__) 205 | snippet deli 206 | delete_if { |${1:e}| ${2} } 207 | snippet fil 208 | fill(${1:range}) { |${2:i}| ${3} } 209 | # flatten_once() 210 | snippet flao 211 | inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3} 212 | snippet zip 213 | zip(${1:enums}) { |${2:row}| ${3} } 214 | # downto(0) { |n| .. } 215 | snippet dow 216 | downto(${1:0}) { |${2:n}| ${3} } 217 | snippet ste 218 | step(${1:2}) { |${2:n}| ${3} } 219 | snippet tim 220 | times { |${1:n}| ${2} } 221 | snippet upt 222 | upto(${1:1.0/0.0}) { |${2:n}| ${3} } 223 | snippet loo 224 | loop { ${1} } 225 | snippet ea 226 | each { |${1:e}| ${2} } 227 | snippet eab 228 | each_byte { |${1:byte}| ${2} } 229 | snippet eac- each_char { |chr| .. } 230 | each_char { |${1:chr}| ${2} } 231 | snippet eac- each_cons(..) { |group| .. } 232 | each_cons(${1:2}) { |${2:group}| ${3} } 233 | snippet eai 234 | each_index { |${1:i}| ${2} } 235 | snippet eak 236 | each_key { |${1:key}| ${2} } 237 | snippet eal 238 | each_line { |${1:line}| ${2} } 239 | snippet eap 240 | each_pair { |${1:name}, ${2:val}| ${3} } 241 | snippet eas- 242 | each_slice(${1:2}) { |${2:group}| ${3} } 243 | snippet eav 244 | each_value { |${1:val}| ${2} } 245 | snippet eawi 246 | each_with_index { |${1:e}, ${2:i}| ${3} } 247 | snippet reve 248 | reverse_each { |${1:e}| ${2} } 249 | snippet inj 250 | inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } 251 | snippet map 252 | map { |${1:e}| ${2} } 253 | snippet mapwi- 254 | enum_with_index.map { |${1:e}, ${2:i}| ${3} } 255 | snippet sor 256 | sort { |a, b| ${1} } 257 | snippet sorb 258 | sort_by { |${1:e}| ${2} } 259 | snippet ran 260 | sort_by { rand } 261 | snippet all 262 | all? { |${1:e}| ${2} } 263 | snippet any 264 | any? { |${1:e}| ${2} } 265 | snippet cl 266 | classify { |${1:e}| ${2} } 267 | snippet col 268 | collect { |${1:e}| ${2} } 269 | snippet det 270 | detect { |${1:e}| ${2} } 271 | snippet fet 272 | fetch(${1:name}) { |${2:key}| ${3} } 273 | snippet fin 274 | find { |${1:e}| ${2} } 275 | snippet fina 276 | find_all { |${1:e}| ${2} } 277 | snippet gre 278 | grep(${1:/pattern/}) { |${2:match}| ${3} } 279 | snippet sub 280 | ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} } 281 | snippet sca 282 | scan(${1:/pattern/}) { |${2:match}| ${3} } 283 | snippet max 284 | max { |a, b|, ${1} } 285 | snippet min 286 | min { |a, b|, ${1} } 287 | snippet par 288 | partition { |${1:e}|, ${2} } 289 | snippet rej 290 | reject { |${1:e}|, ${2} } 291 | snippet sel 292 | select { |${1:e}|, ${2} } 293 | snippet lam 294 | lambda { |${1:args}| ${2} } 295 | snippet do 296 | do |${1:variable}| 297 | ${2} 298 | end 299 | snippet : 300 | :${1:key} => ${2:"value"}${3} 301 | snippet ope 302 | open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } 303 | # path_from_here() 304 | snippet patfh 305 | File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} 306 | # unix_filter {} 307 | snippet unif 308 | ARGF.each_line${1} do |${2:line}| 309 | ${3} 310 | end 311 | # option_parse {} 312 | snippet optp 313 | require "optparse" 314 | 315 | options = {${1:default => "args"}} 316 | 317 | ARGV.options do |opts| 318 | opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} 319 | snippet opt 320 | opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String}, 321 | "${4:Option description.}") do |${5:opt}| 322 | ${6} 323 | end 324 | snippet tc 325 | require "test/unit" 326 | 327 | require "${1:library_file_name}" 328 | 329 | class Test${2:$1} < Test::Unit::TestCase 330 | def test_${3:case_name} 331 | ${4} 332 | end 333 | end 334 | snippet ts 335 | require "test/unit" 336 | 337 | require "tc_${1:test_case_file}" 338 | require "tc_${2:test_case_file}"${3} 339 | snippet as 340 | assert(${1:test}, "${2:Failure message.}")${3} 341 | snippet ase 342 | assert_equal(${1:expected}, ${2:actual})${3} 343 | snippet asne 344 | assert_not_equal(${1:unexpected}, ${2:actual})${3} 345 | snippet asid 346 | assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4} 347 | snippet asio 348 | assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3} 349 | snippet asko 350 | assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3} 351 | snippet asn 352 | assert_nil(${1:instance})${2} 353 | snippet asnn 354 | assert_not_nil(${1:instance})${2} 355 | snippet asm 356 | assert_match(/${1:expected_pattern}/, ${2:actual_string})${3} 357 | snippet asnm 358 | assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3} 359 | snippet aso 360 | assert_operator(${1:left}, :${2:operator}, ${3:right})${4} 361 | snippet asr 362 | assert_raise(${1:Exception}) { ${2} } 363 | snippet asnr 364 | assert_nothing_raised(${1:Exception}) { ${2} } 365 | snippet asrt 366 | assert_respond_to(${1:object}, :${2:method})${3} 367 | snippet ass assert_same(..) 368 | assert_same(${1:expected}, ${2:actual})${3} 369 | snippet ass assert_send(..) 370 | assert_send([${1:object}, :${2:message}, ${3:args}])${4} 371 | snippet asns 372 | assert_not_same(${1:unexpected}, ${2:actual})${3} 373 | snippet ast 374 | assert_throws(:${1:expected}) { ${2} } 375 | snippet asnt 376 | assert_nothing_thrown { ${1} } 377 | snippet fl 378 | flunk("${1:Failure message.}")${2} 379 | # Benchmark.bmbm do .. end 380 | snippet bm- 381 | TESTS = ${1:10_000} 382 | Benchmark.bmbm do |results| 383 | ${2} 384 | end 385 | snippet rep 386 | results.report("${1:name}:") { TESTS.times { ${2} }} 387 | # Marshal.dump(.., file) 388 | snippet Md 389 | File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4} 390 | # Mashal.load(obj) 391 | snippet Ml 392 | File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3} 393 | # deep_copy(..) 394 | snippet deec 395 | Marshal.load(Marshal.dump(${1:obj_to_copy}))${2} 396 | snippet Pn- 397 | PStore.new(${1:"file_name.pstore"})${2} 398 | snippet tra 399 | transaction(${1:true}) { ${2} } 400 | # xmlread(..) 401 | snippet xml- 402 | REXML::Document.new(File.read(${1:"path/to/file"}))${2} 403 | # xpath(..) { .. } 404 | snippet xpa 405 | elements.each(${1:"//Xpath"}) do |${2:node}| 406 | ${3} 407 | end 408 | # class_from_name() 409 | snippet clafn 410 | split("::").inject(Object) { |par, const| par.const_get(const) } 411 | # singleton_class() 412 | snippet sinc 413 | class << self; self end 414 | snippet nam 415 | namespace :${1:`Filename()`} do 416 | ${2} 417 | end 418 | snippet tas 419 | desc "${1:Task description\}" 420 | task :${2:task_name => [:dependent, :tasks]} do 421 | ${3} 422 | end 423 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/scss.snippets: -------------------------------------------------------------------------------- 1 | snippet border 2 | border: 1px solid ${1:red}; 3 | snippet t 4 | ${1:name} { 5 | ${2:attr}: ${3:value}; 6 | } 7 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/sh.snippets: -------------------------------------------------------------------------------- 1 | # #!/bin/bash 2 | snippet #! 3 | #!/usr/bin/env bash 4 | 5 | snippet if 6 | if [[ ${1:condition} ]]; then 7 | ${2:#statements} 8 | fi 9 | snippet elif 10 | elif [[ ${1:condition} ]]; then 11 | ${2:#statements} 12 | snippet for 13 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 14 | ${3:#statements} 15 | done 16 | snippet wh 17 | while [[ ${1:condition} ]]; do 18 | ${2:#statements} 19 | done 20 | snippet until 21 | until [[ ${1:condition} ]]; do 22 | ${2:#statements} 23 | done 24 | snippet case 25 | case ${1:word} in 26 | ${2:pattern}) 27 | ${3};; 28 | esac 29 | 30 | snippet h 31 | 32 | ################################# 33 | # 34 | # ${1:hi} 35 | # 36 | ################################# 37 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/snippet.snippets: -------------------------------------------------------------------------------- 1 | # snippets for making snippets :) 2 | snippet snip 3 | snippet ${1:trigger} 4 | ${2} 5 | snippet msnip 6 | snippet ${1:trigger} ${2:description} 7 | ${3} 8 | 9 | snippet dog 10 | I love dog 11 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/tcl.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/tclsh 2 | snippet #! 3 | #!/usr/bin/tclsh 4 | 5 | # Process 6 | snippet pro 7 | proc ${1:function_name} {${2:args}} { 8 | ${3:#body ...} 9 | } 10 | #xif 11 | snippet xif 12 | ${1:expr}? ${2:true} : ${3:false} 13 | # Conditional 14 | snippet if 15 | if {${1}} { 16 | ${2:# body...} 17 | } 18 | # Conditional if..else 19 | snippet ife 20 | if {${1}} { 21 | ${2:# body...} 22 | } else { 23 | ${3:# else...} 24 | } 25 | # Conditional if..elsif..else 26 | snippet ifee 27 | if {${1}} { 28 | ${2:# body...} 29 | } elseif {${3}} { 30 | ${4:# elsif...} 31 | } else { 32 | ${5:# else...} 33 | } 34 | # If catch then 35 | snippet ifc 36 | if { [catch {${1:#do something...}} ${2:err}] } { 37 | ${3:# handle failure...} 38 | } 39 | # Catch 40 | snippet catch 41 | catch {${1}} ${2:err} ${3:options} 42 | # While Loop 43 | snippet wh 44 | while {${1}} { 45 | ${2:# body...} 46 | } 47 | # For Loop 48 | snippet for 49 | for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { 50 | ${4:# body...} 51 | } 52 | # Foreach Loop 53 | snippet fore 54 | foreach ${1:x} {${2:#list}} { 55 | ${3:# body...} 56 | } 57 | # after ms script... 58 | snippet af 59 | after ${1:ms} ${2:#do something} 60 | # after cancel id 61 | snippet afc 62 | after cancel ${1:id or script} 63 | # after idle 64 | snippet afi 65 | after idle ${1:script} 66 | # after info id 67 | snippet afin 68 | after info ${1:id} 69 | # Expr 70 | snippet exp 71 | expr {${1:#expression here}} 72 | # Switch 73 | snippet sw 74 | switch ${1:var} { 75 | ${3:pattern 1} { 76 | ${4:#do something} 77 | } 78 | default { 79 | ${2:#do something} 80 | } 81 | } 82 | # Case 83 | snippet ca 84 | ${1:pattern} { 85 | ${2:#do something} 86 | }${3} 87 | # Namespace eval 88 | snippet ns 89 | namespace eval ${1:path} {${2:#script...}} 90 | # Namespace current 91 | snippet nsc 92 | namespace current 93 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/tex.snippets: -------------------------------------------------------------------------------- 1 | # \begin{}...\end{} 2 | snippet begin 3 | \begin{${1:env}} 4 | ${2} 5 | \end{$1} 6 | # Tabular 7 | snippet tab 8 | \begin{${1:tabular}}{${2:c}} 9 | ${3} 10 | \end{$1} 11 | # Align(ed) 12 | snippet ali 13 | \begin{align${1:ed}} 14 | ${2} 15 | \end{align$1} 16 | # Gather(ed) 17 | snippet gat 18 | \begin{gather${1:ed}} 19 | ${2} 20 | \end{gather$1} 21 | # Equation 22 | snippet eq 23 | \begin{equation} 24 | ${1} 25 | \end{equation} 26 | # Unnumbered Equation 27 | snippet \ 28 | \\[ 29 | ${1} 30 | \\] 31 | # Enumerate 32 | snippet enum 33 | \begin{enumerate} 34 | \item ${1} 35 | \end{enumerate} 36 | # Itemize 37 | snippet item 38 | \begin{itemize} 39 | \item ${1} 40 | \end{itemize} 41 | # Description 42 | snippet desc 43 | \begin{description} 44 | \item[${1}] ${2} 45 | \end{description} 46 | # Matrix 47 | snippet mat 48 | \begin{${1:p/b/v/V/B/small}matrix} 49 | ${2} 50 | \end{$1matrix} 51 | # Cases 52 | snippet cas 53 | \begin{cases} 54 | ${1:equation}, &\text{ if }${2:case}\\ 55 | ${3} 56 | \end{cases} 57 | # Split 58 | snippet spl 59 | \begin{split} 60 | ${1} 61 | \end{split} 62 | # Part 63 | snippet part 64 | \part{${1:part name}} % (fold) 65 | \label{prt:${2:$1}} 66 | ${3} 67 | % part $2 (end) 68 | # Chapter 69 | snippet cha 70 | \chapter{${1:chapter name}} % (fold) 71 | \label{cha:${2:$1}} 72 | ${3} 73 | % chapter $2 (end) 74 | # Section 75 | snippet sec 76 | \section{${1:section name}} % (fold) 77 | \label{sec:${2:$1}} 78 | ${3} 79 | % section $2 (end) 80 | # Sub Section 81 | snippet sub 82 | \subsection{${1:subsection name}} % (fold) 83 | \label{sub:${2:$1}} 84 | ${3} 85 | % subsection $2 (end) 86 | # Sub Sub Section 87 | snippet subs 88 | \subsubsection{${1:subsubsection name}} % (fold) 89 | \label{ssub:${2:$1}} 90 | ${3} 91 | % subsubsection $2 (end) 92 | # Paragraph 93 | snippet par 94 | \paragraph{${1:paragraph name}} % (fold) 95 | \label{par:${2:$1}} 96 | ${3} 97 | % paragraph $2 (end) 98 | # Sub Paragraph 99 | snippet subp 100 | \subparagraph{${1:subparagraph name}} % (fold) 101 | \label{subp:${2:$1}} 102 | ${3} 103 | % subparagraph $2 (end) 104 | snippet itd 105 | \item[${1:description}] ${2:item} 106 | snippet figure 107 | ${1:Figure}~\ref{${2:fig:}}${3} 108 | snippet table 109 | ${1:Table}~\ref{${2:tab:}}${3} 110 | snippet listing 111 | ${1:Listing}~\ref{${2:list}}${3} 112 | snippet section 113 | ${1:Section}~\ref{${2:sec:}}${3} 114 | snippet page 115 | ${1:page}~\pageref{${2}}${3} 116 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/vim.snippets: -------------------------------------------------------------------------------- 1 | snippet header 2 | " File: ${1:`expand('%:t')`} 3 | " Author: ${2:`g:snips_author`} 4 | " Description: ${3} 5 | ${4:" Last Modified: `strftime("%B %d, %Y")`} 6 | snippet guard 7 | if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} 8 | finish 9 | endif 10 | let $1 = 1${3} 11 | snippet f 12 | fun ${1:function_name}(${2}) 13 | ${3:" code} 14 | endf 15 | snippet for 16 | for ${1:needle} in ${2:haystack} 17 | ${3:" code} 18 | endfor 19 | snippet wh 20 | while ${1:condition} 21 | ${2:" code} 22 | endw 23 | snippet if 24 | if ${1:condition} 25 | ${2:" code} 26 | endif 27 | snippet ife 28 | if ${1:condition} 29 | ${2} 30 | else 31 | ${3} 32 | endif 33 | snippet h 34 | """""""""""""""""""""""""""""""""""""""" 35 | " 36 | " ${1:title} 37 | " 38 | """""""""""""""""""""""""""""""""""""""" 39 | ${2:text} 40 | 41 | -------------------------------------------------------------------------------- /bundle/snipmate/snippets/zsh.snippets: -------------------------------------------------------------------------------- 1 | # #!/bin/zsh 2 | snippet #! 3 | #!/bin/zsh 4 | 5 | snippet if 6 | if ${1:condition}; then 7 | ${2:# statements} 8 | fi 9 | snippet ife 10 | if ${1:condition}; then 11 | ${2:# statements} 12 | else 13 | ${3:# statements} 14 | fi 15 | snippet elif 16 | elif ${1:condition} ; then 17 | ${2:# statements} 18 | snippet for 19 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 20 | ${3:# statements} 21 | done 22 | snippet fore 23 | for ${1:item} in ${2:list}; do 24 | ${3:# statements} 25 | done 26 | snippet wh 27 | while ${1:condition}; do 28 | ${2:# statements} 29 | done 30 | snippet until 31 | until ${1:condition}; do 32 | ${2:# statements} 33 | done 34 | snippet repeat 35 | repeat ${1:integer}; do 36 | ${2:# statements} 37 | done 38 | snippet case 39 | case ${1:word} in 40 | ${2:pattern}) 41 | ${3};; 42 | esac 43 | snippet select 44 | select ${1:answer} in ${2:choices}; do 45 | ${3:# statements} 46 | done 47 | snippet ( 48 | ( ${1:#statements} ) 49 | snippet { 50 | { ${1:#statements} } 51 | snippet [ 52 | [[ ${1:test} ]] 53 | snippet always 54 | { ${1:try} } always { ${2:always} } 55 | snippet fun 56 | function ${1:name} (${2:args}) { 57 | ${3:# body} 58 | } 59 | -------------------------------------------------------------------------------- /bundle/snipmate/syntax/snippet.vim: -------------------------------------------------------------------------------- 1 | " Syntax highlighting for snippet files (used for snipMate.vim) 2 | " Hopefully this should make snippets a bit nicer to write! 3 | syn match snipComment '^#.*' 4 | syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand 5 | syn match tabStop '\$\d\+' 6 | syn match snipCommand '`.\{-}`' 7 | syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword 8 | syn match multiSnipText '\S\+ \zs.*' contained 9 | syn match snipKeyword '^snippet'me=s+8 contained 10 | syn match snipError "^[^#s\t].*$" 11 | 12 | hi link snipComment Comment 13 | hi link multiSnipText String 14 | hi link snipKeyword Keyword 15 | hi link snipComment Comment 16 | hi link placeHolder Special 17 | hi link tabStop Special 18 | hi link snipCommand String 19 | hi link snipError Error 20 | -------------------------------------------------------------------------------- /bundle/surround.vim/doc/surround.txt: -------------------------------------------------------------------------------- 1 | *surround.txt* Plugin for deleting, changing, and adding "surroundings" 2 | 3 | Author: Tim Pope 4 | License: Same terms as Vim itself (see |license|) 5 | 6 | This plugin is only available if 'compatible' is not set. 7 | 8 | INTRODUCTION *surround* 9 | 10 | This plugin is a tool for dealing with pairs of "surroundings." Examples 11 | of surroundings include parentheses, quotes, and HTML tags. They are 12 | closely related to what Vim refers to as |text-objects|. Provided 13 | are mappings to allow for removing, changing, and adding surroundings. 14 | 15 | Details follow on the exact semantics, but first, consider the following 16 | examples. An asterisk (*) is used to denote the cursor position. 17 | 18 | Old text Command New text ~ 19 | "Hello *world!" ds" Hello world! 20 | [123+4*56]/2 cs]) (123+456)/2 21 | "Look ma, I'm *HTML!" cs" Look ma, I'm HTML! 22 | if *x>3 { ysW( if ( x>3 ) { 23 | my $str = *whee!; vllllS' my $str = 'whee!'; 24 | 25 | While a few features of this plugin will work in older versions of Vim, 26 | Vim 7 is recommended for full functionality. 27 | 28 | MAPPINGS *surround-mappings* 29 | 30 | Delete surroundings is *ds* . The next character given determines the target 31 | to delete. The exact nature of the target is explained in |surround-targets| 32 | but essentially it is the last character of a |text-object|. This mapping 33 | deletes the difference between the "i"nner object and "a"n object. This is 34 | easiest to understand with some examples: 35 | 36 | Old text Command New text ~ 37 | "Hello *world!" ds" Hello world! 38 | (123+4*56)/2 ds) 123+456/2 39 |
Yo!*
dst Yo! 40 | 41 | Change surroundings is *cs* . It takes two arguments, a target like with 42 | |ds|, and a replacement. Details about the second argument can be found 43 | below in |surround-replacements|. Once again, examples are in order. 44 | 45 | Old text Command New text ~ 46 | "Hello *world!" cs"' 'Hello world!' 47 | "Hello *world!" cs" Hello world! 48 | (123+4*56)/2 cs)] [123+456]/2 49 | (123+4*56)/2 cs)[ [ 123+456 ]/2 50 |
Yo!*
cst

Yo!

51 | 52 | *ys* takes a valid Vim motion or text object as the first object, and wraps 53 | it using the second argument as with |cs|. (It's a stretch, but a good 54 | mnemonic for "ys" is "you surround".) 55 | 56 | Old text Command New text ~ 57 | Hello w*orld! ysiw) Hello (world)! 58 | 59 | As a special case, *yss* operates on the current line, ignoring leading 60 | whitespace. 61 | 62 | Old text Command New text ~ 63 | Hello w*orld! yssB {Hello world!} 64 | 65 | There is also *yS* and *ySS* which indent the surrounded text and place it 66 | on a line of its own. 67 | 68 | In visual mode, a simple "S" with an argument wraps the selection. This is 69 | referred to as the *vS* mapping, although ordinarily there will be 70 | additional keystrokes between the v and S. In linewise visual mode, the 71 | surroundings are placed on separate lines and indented. In blockwise visual 72 | mode, each line is surrounded. 73 | 74 | A "gS" in visual mode, known as *vgS* , behaves similarly. In linewise visual 75 | mode, the automatic indenting is suppressed. In blockwise visual mode, this 76 | enables surrounding past the end of the line with 'virtualedit' set (there 77 | seems to be no way in Vim Script to differentiate between a jagged end of line 78 | selection and a virtual block selected past the end of the line, so two maps 79 | were needed). 80 | 81 | *i_CTRL-G_s* *i_CTRL-G_S* 82 | Finally, there is an experimental insert mode mapping on s and . 83 | Beware that the latter won't work on terminals with flow control (if you 84 | accidentally freeze your terminal, use to unfreeze it). The mapping 85 | inserts the specified surroundings and puts the cursor between them. If, 86 | immediately after the mapping and before the replacement, a second or 87 | carriage return is pressed, the prefix, cursor, and suffix will be placed on 88 | three separate lines. S (not s) also exhibits this behavior. 89 | 90 | TARGETS *surround-targets* 91 | 92 | The |ds| and |cs| commands both take a target as their first argument. The 93 | possible targets are based closely on the |text-objects| provided by Vim. 94 | All targets are currently just one character. 95 | 96 | Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves 97 | and their counterparts. If the opening mark is used, contained whitespace is 98 | also trimmed. The targets b, B, r, and a are aliases for ), }, ], and > 99 | (the first two mirror Vim; the second two are completely arbitrary and 100 | subject to change). 101 | 102 | Three quote marks, ', ", `, represent themselves, in pairs. They are only 103 | searched for on the current line. 104 | 105 | A t is a pair of HTML or XML tags. See |tag-blocks| for details. Remember 106 | that you can specify a numerical argument if you want to get to a tag other 107 | than the innermost one. 108 | 109 | The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|, 110 | respectively. These are special in that they have nothing to delete, and 111 | used with |ds| they are a no-op. With |cs|, one could consider them a 112 | slight shortcut for ysi (cswb == ysiwb, more or less). 113 | 114 | A p represents a |paragraph|. This behaves similarly to w, W, and s above; 115 | however, newlines are sometimes added and/or removed. 116 | 117 | REPLACEMENTS *surround-replacements* 118 | 119 | A replacement argument is a single character, and is required by |cs|, |ys|, 120 | and |vS|. Undefined replacement characters (with the exception of alphabetic 121 | characters) default to placing themselves at the beginning and end of the 122 | destination, which can be useful for characters like / and |. 123 | 124 | If either ), }, ], or > is used, the text is wrapped in the appropriate pair 125 | of characters. Similar behavior can be found with (, {, and [ (but not <), 126 | which append an additional space to the inside. Like with the targets above, 127 | b, B, r, and a are aliases for ), }, ], and >. To fulfill the common need for 128 | code blocks in C-style languages, (which is really ) adds braces on 129 | lines separate from the content. 130 | 131 | If t or < is used, Vim prompts for an HTML/XML tag to insert. You may specify 132 | attributes here and they will be stripped from the closing tag. End your 133 | input by pressing or >. If is used, the tags will appear on lines 134 | by themselves. 135 | 136 | If s is used, a leading but not trailing space is added. This is useful for 137 | removing parentheses from a function call with csbs. 138 | 139 | CUSTOMIZING *surround-customizing* 140 | 141 | The following adds a potential replacement on "-" (ASCII 45) in PHP files. 142 | (To determine the ASCII code to use, :echo char2nr("-")). The carriage 143 | return will be replaced by the original text. 144 | > 145 | autocmd FileType php let b:surround_45 = "" 146 | < 147 | This can be used in a PHP file as in the following example. 148 | 149 | Old text Command New text ~ 150 | print "Hello *world!" yss- 151 | 152 | Additionally, one can use a global variable for globally available 153 | replacements. 154 | > 155 | let g:surround_45 = "<% \r %>" 156 | let g:surround_61 = "<%= \r %>" 157 | < 158 | Advanced, experimental, and subject to change: One can also prompt for 159 | replacement text. The syntax for this is to surround the replacement in pairs 160 | of low numbered control characters. If this sounds confusing, that's because 161 | it is (but it makes the parsing easy). Consider the following example for a 162 | LaTeX environment on the "l" replacement. 163 | > 164 | let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\1}" 165 | < 166 | When this replacement is used, the user is prompted with an "environment: " 167 | prompt for input. This input is inserted between each set of \1's. 168 | Additional inputs up to \7 can be used. 169 | 170 | Furthermore, one can specify a regular expression substitution to apply. 171 | > 172 | let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\r}.*\r\1}" 173 | < 174 | This will remove anything after the first } in the input when the text is 175 | placed within the \end{} slot. The first \r marks where the pattern begins, 176 | and the second where the replacement text begins. 177 | 178 | Here's a second example for creating an HTML
. The substitution cleverly 179 | prompts for an id, but only adds id="" if it is non-blank. You may have to 180 | read this one a few times slowly before you understand it. 181 | > 182 | let g:surround_{char2nr("d")} = "\r
" 183 | < 184 | Inputting text replacements is a proof of concept at this point. The ugly, 185 | unintuitive interface and the brevity of the documentation reflect this. 186 | 187 | Finally, It is possible to always append a string to surroundings in insert 188 | mode (and only insert mode). This is useful with certain plugins and mappings 189 | that allow you to jump to such markings. 190 | > 191 | let g:surround_insert_tail = "<++>" 192 | < 193 | ISSUES *surround-issues* 194 | 195 | Vim could potentially get confused when deleting/changing occurs at the very 196 | end of the line. Please report any repeatable instances of this. 197 | 198 | Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? 199 | 200 | Indenting is handled haphazardly. Need to decide the most appropriate 201 | behavior and implement it. Right now one can do :let b:surround_indent = 1 202 | (or the global equivalent) to enable automatic re-indenting by Vim via |=|; 203 | should this be the default? 204 | 205 | vim:tw=78:ts=8:ft=help:norl: 206 | -------------------------------------------------------------------------------- /bundle/surround.vim/doc/tags: -------------------------------------------------------------------------------- 1 | cs surround.txt /*cs* 2 | ds surround.txt /*ds* 3 | i_CTRL-G_S surround.txt /*i_CTRL-G_S* 4 | i_CTRL-G_s surround.txt /*i_CTRL-G_s* 5 | surround surround.txt /*surround* 6 | surround-customizing surround.txt /*surround-customizing* 7 | surround-issues surround.txt /*surround-issues* 8 | surround-mappings surround.txt /*surround-mappings* 9 | surround-replacements surround.txt /*surround-replacements* 10 | surround-targets surround.txt /*surround-targets* 11 | surround.txt surround.txt /*surround.txt* 12 | vS surround.txt /*vS* 13 | vgS surround.txt /*vgS* 14 | yS surround.txt /*yS* 15 | ySS surround.txt /*ySS* 16 | ys surround.txt /*ys* 17 | yss surround.txt /*yss* 18 | -------------------------------------------------------------------------------- /bundle/tComment/README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=1173 2 | 3 | :TComment works like a toggle, i.e., it will comment out text that 4 | contains uncommented lines, and it will uncomment already 5 | commented text (i.e. text that contains no uncommented lines). 6 | 7 | If the file-type is properly defined, :TComment will figure out which 8 | comment string to use based on the values of &commentstring or &comments. 9 | For some filetypes, the comment definition is explicitly defined. You can 10 | |tcomment#DefineType()| to add your own definitions. 11 | 12 | TComment knows how to deal with embedded code of a different filetype 13 | than the main filetype, e.g., ruby/python/perl regions in vim scripts, HTML or 14 | JavaScript in php code etc. 15 | 16 | As operator (the prefix can be customized via g:tcommentMapLeaderOp1 17 | and g:tcommentMapLeaderOp2): 18 | 19 | gc{motion} :: Toggle comments (for small comments within one line 20 | the &filetype_inline style will be used, if 21 | defined) 22 | gcc :: Toggle comment for the current line 23 | gC{motion} :: Comment region 24 | gCc :: Comment the current line 25 | 26 | Primary key maps: 27 | 28 | :: :TComment 29 | :: :TComment 30 | b :: :TCommentBlock 31 | a :: :TCommentAs 32 | n :: :TCommentAs &filetype 33 | s :: :TCommentAs &filetype_ 34 | i :: :TCommentInline 35 | r :: :TCommentRight 36 | p :: Comment the current inner paragraph 37 | 38 | There is also a secondary set of key maps with _ as leader (more 39 | preferable on terminals). 40 | 41 | The full documentation is available here: 42 | http://github.com/tomtom/tcomment_vim/blob/master/doc/tcomment.txt 43 | 44 | Demo: 45 | http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html 46 | 47 | Also available via git 48 | http://github.com/tomtom/tcomment_vim 49 | -------------------------------------------------------------------------------- /bundle/tComment/plugin/tcomment.vim: -------------------------------------------------------------------------------- 1 | " tComment.vim -- An easily extensible & universal comment plugin 2 | " @Author: Tom Link (micathom AT gmail com) 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Created: 27-Dez-2004. 5 | " @Last Change: 2012-11-26. 6 | " @Revision: 762 7 | " GetLatestVimScripts: 1173 1 tcomment.vim 8 | 9 | if &cp || exists('loaded_tcomment') 10 | finish 11 | endif 12 | let loaded_tcomment = 208 13 | 14 | if !exists("g:tcommentMapLeader1") 15 | " g:tcommentMapLeader1 should be a shortcut that can be used with 16 | " map, imap, vmap. 17 | let g:tcommentMapLeader1 = '' "{{{2 18 | endif 19 | if !exists("g:tcommentMapLeader2") 20 | " g:tcommentMapLeader2 should be a shortcut that can be used with 21 | " map, xmap. 22 | let g:tcommentMapLeader2 = '_' "{{{2 23 | endif 24 | if !exists("g:tcommentMapLeaderOp1") 25 | " See |tcomment-operator|. 26 | let g:tcommentMapLeaderOp1 = 'gc' "{{{2 27 | endif 28 | if !exists("g:tcommentMapLeaderOp2") 29 | " See |tcomment-operator|. 30 | let g:tcommentMapLeaderOp2 = 'gC' "{{{2 31 | endif 32 | 33 | 34 | " :display: :[range]TComment[!] ?ARGS... 35 | " If there is a visual selection that begins and ends in the same line, 36 | " then |:TCommentInline| is used instead. 37 | " The optional range defaults to the current line. With a bang '!', 38 | " always comment the line. 39 | " 40 | " ARGS... are either (see also |tcomment#Comment()|): 41 | " 1. a list of key=value pairs 42 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 43 | command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TComment 44 | \ keepjumps call tcomment#Comment(, , 'G', "", ) 45 | 46 | " :display: :[range]TCommentAs[!] commenttype ?ARGS... 47 | " TCommentAs requires g:tcomment_{filetype} to be defined. 48 | " With a bang '!', always comment the line. 49 | " 50 | " ARGS... are either (see also |tcomment#Comment()|): 51 | " 1. a list of key=value pairs 52 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 53 | command! -bang -complete=customlist,tcomment#Complete -range -nargs=+ TCommentAs 54 | \ call tcomment#CommentAs(, , "", ) 55 | 56 | " :display: :[range]TCommentRight[!] ?ARGS... 57 | " Comment the text to the right of the cursor. If a visual selection was 58 | " made (be it block-wise or not), all lines are commented out at from 59 | " the current cursor position downwards. 60 | " With a bang '!', always comment the line. 61 | " 62 | " ARGS... are either (see also |tcomment#Comment()|): 63 | " 1. a list of key=value pairs 64 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 65 | command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentRight 66 | \ keepjumps call tcomment#Comment(, , 'R', "", ) 67 | 68 | " :display: :[range]TCommentBlock[!] ?ARGS... 69 | " Comment as "block", e.g. use the {&ft}_block comment style. The 70 | " commented text isn't indented or reformated. 71 | " With a bang '!', always comment the line. 72 | " 73 | " ARGS... are either (see also |tcomment#Comment()|): 74 | " 1. a list of key=value pairs 75 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 76 | command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentBlock 77 | \ keepjumps call tcomment#Comment(, , 'B', "", ) 78 | 79 | " :display: :[range]TCommentInline[!] ?ARGS... 80 | " Use the {&ft}_inline comment style. 81 | " With a bang '!', always comment the line. 82 | " 83 | " ARGS... are either (see also |tcomment#Comment()|): 84 | " 1. a list of key=value pairs 85 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 86 | command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentInline 87 | \ keepjumps call tcomment#Comment(, , 'I', "", ) 88 | 89 | " :display: :[range]TCommentMaybeInline[!] ?ARGS... 90 | " With a bang '!', always comment the line. 91 | " 92 | " ARGS... are either (see also |tcomment#Comment()|): 93 | " 1. a list of key=value pairs 94 | " 2. 1-2 values for: ?commentBegin, ?commentEnd 95 | command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentMaybeInline 96 | \ keepjumps call tcomment#Comment(, , 'i', "", ) 97 | 98 | 99 | 100 | if (g:tcommentMapLeader1 != '') 101 | exec 'noremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' 102 | exec 'vnoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline' 103 | exec 'inoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' 104 | exec 'noremap '. g:tcommentMapLeader1 .'p m`vip:TComment``' 105 | exec 'inoremap '. g:tcommentMapLeader1 .'p :norm! m`vip:TComment``' 106 | exec 'noremap '. g:tcommentMapLeader1 .' :TComment ' 107 | exec 'inoremap '. g:tcommentMapLeader1 .' :TComment ' 108 | exec 'inoremap '. g:tcommentMapLeader1 .'r :TCommentRight' 109 | exec 'noremap '. g:tcommentMapLeader1 .'r :TCommentRight' 110 | exec 'vnoremap '. g:tcommentMapLeader1 .'i :TCommentInline' 111 | exec 'noremap '. g:tcommentMapLeader1 .'i v:TCommentInline mode=I#' 112 | exec 'inoremap '. g:tcommentMapLeader1 .'i v:TCommentInline mode=#' 113 | exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock' 114 | exec 'inoremap '. g:tcommentMapLeader1 .'b :TCommentBlock' 115 | exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs ' 116 | exec 'inoremap '. g:tcommentMapLeader1 .'a :TCommentAs ' 117 | exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' 118 | exec 'inoremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' 119 | exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' 120 | exec 'inoremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' 121 | exec 'noremap '. g:tcommentMapLeader1 .'cc :call tcomment#SetOption("count", v:count1)' 122 | exec 'noremap '. g:tcommentMapLeader1 .'ca :call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))' 123 | for s:i in range(1, 9) 124 | exec 'noremap '. g:tcommentMapLeader1 . s:i .' :TComment count='. s:i .'' 125 | exec 'inoremap '. g:tcommentMapLeader1 . s:i .' :TComment count='. s:i .'' 126 | exec 'vnoremap '. g:tcommentMapLeader1 . s:i .' :TCommentMaybeInline count='. s:i .'' 127 | endfor 128 | unlet s:i 129 | endif 130 | if (g:tcommentMapLeader2 != '') 131 | exec 'noremap '. g:tcommentMapLeader2 .'_ :TComment' 132 | exec 'xnoremap '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline' 133 | exec 'noremap '. g:tcommentMapLeader2 .'p vip:TComment' 134 | exec 'noremap '. g:tcommentMapLeader2 .' :TComment ' 135 | exec 'xnoremap '. g:tcommentMapLeader2 .'i :TCommentInline' 136 | exec 'noremap '. g:tcommentMapLeader2 .'r :TCommentRight' 137 | exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock' 138 | exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs ' 139 | exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs =&ft ' 140 | exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs =&ft_' 141 | endif 142 | if (g:tcommentMapLeaderOp1 != '') 143 | exec 'nnoremap '. g:tcommentMapLeaderOp1 .' :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operatorg@' 144 | for s:i in range(1, 9) 145 | exec 'nnoremap '. g:tcommentMapLeaderOp1 . s:i .'c :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("count", '. s:i .') \| set opfunc=tcomment#Operatorg@' 146 | endfor 147 | unlet s:i 148 | exec 'nnoremap '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineg@$' 149 | exec 'xnoremap '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline' 150 | endif 151 | if (g:tcommentMapLeaderOp2 != '') 152 | exec 'nnoremap '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnywayg@' 153 | exec 'nnoremap '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnywayg@$' 154 | exec 'xnoremap '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline!' 155 | endif 156 | 157 | " vi: ft=vim:tw=72:ts=4:fo=w2croql 158 | -------------------------------------------------------------------------------- /bundle/vim-auto-save/README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=4521 2 | 3 | AutoSave - automatically save changes to disk without having to use :w (or any binding to it) every time a buffer has been modified. 4 | AutoSave is disabled by default, run :AutoSaveToggle to enable/disable AutoSave. 5 | If you want plugin to be always enabled it can be done with g:auto_save option (place 'let g:auto_save = 1' in your .vimrc). 6 | Inspired by the same feature in RubyMine text editor. 7 | -------------------------------------------------------------------------------- /bundle/vim-auto-save/README.md: -------------------------------------------------------------------------------- 1 | # AutoSave 2 | 3 | ## Description 4 | 5 | AutoSave - automatically save changes to disk without having to use `:w` (or any binding to it) every time a buffer has been modified. 6 | 7 | Inspired by the same feature in RubyMine text editor. 8 | 9 | ## Installation and Usage 10 | 11 | Use [vundle](https://github.com/gmarik/vundle) to install the plugin. 12 | 13 | Also you can download [packaged version](http://www.vim.org/scripts/script.php?script_id=4521) from vim.org. 14 | 15 | AutoSave is disabled by default, run `:AutoSaveToggle` to enable/disable it. 16 | If you want plugin to be always enabled it can be done with`g:auto_save` option: 17 | 18 | ```VimL 19 | " .vimrc 20 | let g:auto_save = 1 21 | 22 | ``` 23 | 24 | ## License 25 | 26 | Distributed under the MIT License (see LICENSE.txt). 27 | 28 | Copyright (c) 2013 Alexey Chernenkov 29 | -------------------------------------------------------------------------------- /bundle/vim-auto-save/doc/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Alexey Chernenkov 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /bundle/vim-auto-save/plugin/AutoSave.vim: -------------------------------------------------------------------------------- 1 | "====================================== 2 | " Script Name: vim-auto-save (http://www.vim.org/scripts/script.php?script_id=4521) 3 | " Plugin Name: AutoSave 4 | " Version: 0.1.2 5 | " Last Modified: 24.04.2013 21:25 6 | "====================================== 7 | 8 | if exists("g:auto_save_loaded") 9 | finish 10 | else 11 | let g:auto_save_loaded = 1 12 | endif 13 | 14 | let s:save_cpo = &cpo 15 | set cpo&vim 16 | 17 | if !exists("g:auto_save") 18 | let g:auto_save = 0 19 | end 20 | 21 | set updatetime=200 22 | au CursorHold,InsertLeave * call AutoSave() 23 | command! AutoSaveToggle :call AutoSaveToggle() 24 | 25 | function! AutoSave() 26 | if g:auto_save >= 1 27 | let was_modified = &modified 28 | silent! wa 29 | if was_modified && !&modified 30 | echo "(AutoSaved at " . strftime("%T") . ")" 31 | endif 32 | endif 33 | endfunction 34 | 35 | function! AutoSaveToggle() 36 | if g:auto_save >= 1 37 | let g:auto_save = 0 38 | echo "AutoSave is OFF" 39 | else 40 | let g:auto_save = 1 41 | echo "AutoSave is ON" 42 | endif 43 | endfunction 44 | 45 | let &cpo = s:save_cpo 46 | unlet s:save_cpo 47 | -------------------------------------------------------------------------------- /bundle/vim-rails/.gitignore: -------------------------------------------------------------------------------- 1 | /rails.zip 2 | /rails.vba 3 | /doc/tags 4 | -------------------------------------------------------------------------------- /bundle/vim-rails/CONTRIBUTING.markdown: -------------------------------------------------------------------------------- 1 | If your [commit message sucks][suck], I'm not going to accept your pull 2 | request. I've explained very politely dozens of times that [my general 3 | guidelines][guidelines] are absolute rules on my own repositories, so I may 4 | lack the energy to explain it to you yet another time. And please, if I ask 5 | you to change something, `git commit --amend` and `git push -f`. 6 | 7 | If a feature idea is nontrivial, you should probably open an issue to [discuss 8 | it][] before attempting a pull request. One of the biggest challenges in 9 | maintaining rails.vim has been beating back the bloat, so do not assume that 10 | your idea will make the cut. And if I like your idea, I'm generally amenable 11 | to just knocking it out myself, rather than making you familiarize yourself 12 | with a 4 thousand line code base. 13 | 14 | [suck]: http://stopwritingramblingcommitmessages.com/ 15 | [guidelines]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 16 | [discuss it]: http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/ 17 | -------------------------------------------------------------------------------- /bundle/vim-rails/README.markdown: -------------------------------------------------------------------------------- 1 | # rails.vim 2 | 3 | Remember when everybody and their mother was using TextMate for Ruby on 4 | Rails development? Well if it wasn't for rails.vim, we'd still be in 5 | that era. So shut up and pay some respect. And check out these 6 | features: 7 | 8 | * Easy navigation of the Rails directory structure. `gf` considers 9 | context and knows about partials, fixtures, and much more. There are 10 | two commands, `:A` (alternate) and `:R` (related) for easy jumping 11 | between files, including favorites like model to schema, template to 12 | helper, and controller to functional test. For more advanced usage, 13 | `:Rmodel`, `:Rview`, `:Rcontroller`, and several other commands are 14 | provided. `:help rails-navigation` 15 | 16 | * Enhanced syntax highlighting. From `has_and_belongs_to_many` to 17 | `distance_of_time_in_words`, it's here. For easy completion of these 18 | long method names, `'completefunc'` is set to enable syntax based 19 | completion on CTRL-X CTRL-U. 20 | 21 | * Interface to rake. Use `:Rake` to run the current test, spec, or 22 | feature. Use `:.Rake` to do a focused run of just the method, 23 | example, or scenario on the current line. `:Rake` can also run 24 | arbitrary migrations, load individual fixtures, and more. 25 | `:help rails-rake` 26 | 27 | * Interface to the `rails` command. Generally, use `:Rails console` to 28 | call `rails console` or `script/console`. Most commands have wrappers 29 | with additional features: `:Rgenerate controller Blog` generates a 30 | blog controller and edits `app/controllers/blog_controller.rb`. 31 | `:help rails-scripts` 32 | 33 | * Partial and concern extraction. In a view, `:Rextract {file}` 34 | replaces the desired range (typically selected in visual line mode) 35 | with `render '{file}'`, which is automatically created with your 36 | content. In a model or controller, a concern is created, with the 37 | appropriate `include` declaration left behind. 38 | `:help rails-:Rextract` 39 | 40 | * Integration with other plugins. `:Rtree` spawns 41 | [NERDTree.vim](https://github.com/scrooloose/nerdtree). If 42 | [dbext.vim](http://www.vim.org/scripts/script.php?script_id=356) is 43 | installed, it will be transparently configured to reflect 44 | `database.yml`. Users of 45 | [abolish.vim](https://github.com/tpope/vim-abolish) get pluralize and 46 | tableize coercions, and users of 47 | [bundler.vim](https://github.com/tpope/vim-bundler) get a smattering of 48 | features. `:help rails-integration` 49 | 50 | ## Installation 51 | 52 | If you don't have a preferred installation method, I recommend 53 | installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and 54 | then simply copy and paste: 55 | 56 | cd ~/.vim/bundle 57 | git clone git://github.com/tpope/vim-rails.git 58 | git clone git://github.com/tpope/vim-bundler.git 59 | 60 | 61 | You don't strictly need [bundler.vim][], but it helps. 62 | 63 | Once help tags have been generated, you can view the manual with 64 | `:help rails`. 65 | 66 | [bundler.vim]: https://github.com/tpope/vim-bundler 67 | 68 | ## FAQ 69 | 70 | > I installed the plugin and started Vim. Why does only the `:Rails` 71 | > command exist? 72 | 73 | This plugin cares about the current file, not the current working 74 | directory. Edit a file from a Rails application. 75 | 76 | > I opened a new tab. Why does only the `:Rails` command exist? 77 | 78 | This plugin cares about the current file, not the current working 79 | directory. Edit a file from a Rails application. You can use the `:RT` 80 | family of commands to open a new tab and edit a file at the same time. 81 | 82 | > Can I use rails.vim to edit Rails engines? 83 | 84 | It's not supported, but if you `touch config/environment.rb` in the root 85 | of the engine, things should mostly work. 86 | 87 | > Can I use rails.vim to edit other Ruby projects? 88 | 89 | I wrote [rake.vim](https://github.com/tpope/vim-rake) for exactly that 90 | purpose. It activates for any project with a `Rakefile` that's not a 91 | Rails application. 92 | 93 | > What Rails versions are supported? 94 | 95 | All of them. A few features like syntax highlighting tend to reflect the 96 | latest version only. 97 | 98 | > Rake is slow. How about making `:Rake` run 99 | > `testrb`/`rspec`/`cucumber` directly instead of `rake`? 100 | 101 | Well then it wouldn't make sense to call it `:Rake`, now, would it? 102 | Maybe one day I'll add a separate `:Run` command or something. In the 103 | meantime, here's how you can set up `:make` to run the current test: 104 | 105 | autocmd FileType cucumber compiler cucumber | setl makeprg=cucumber\ \"%:p\" 106 | autocmd FileType ruby 107 | \ if expand('%') =~# '_test\.rb$' | 108 | \ compiler rubyunit | setl makeprg=testrb\ \"%:p\" | 109 | \ elseif expand('%') =~# '_spec\.rb$' | 110 | \ compiler rspec | setl makeprg=rspec\ \"%:p\" | 111 | \ else | 112 | \ compiler ruby | setl makeprg=ruby\ -wc\ \"%:p\" | 113 | \ endif 114 | autocmd User Bundler 115 | \ if &makeprg !~# 'bundle' | setl makeprg^=bundle\ exec\ | endif 116 | 117 | ## Self-Promotion 118 | 119 | Like rails.vim? Follow the repository on 120 | [GitHub](https://github.com/tpope/vim-rails) and vote for it on 121 | [vim.org](http://www.vim.org/scripts/script.php?script_id=1567). And if 122 | you're feeling especially charitable, follow [tpope](http://tpo.pe/) on 123 | [Twitter](http://twitter.com/tpope) and 124 | [GitHub](https://github.com/tpope). 125 | 126 | ## License 127 | 128 | Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. 129 | See `:help license`. 130 | -------------------------------------------------------------------------------- /bundle/vim-rails/plugin/rails.vim: -------------------------------------------------------------------------------- 1 | " rails.vim - Detect a rails application 2 | " Author: Tim Pope 3 | " GetLatestVimScripts: 1567 1 :AutoInstall: rails.vim 4 | 5 | " Install this file as plugin/rails.vim. 6 | 7 | if exists('g:loaded_rails') || &cp || v:version < 700 8 | finish 9 | endif 10 | let g:loaded_rails = 1 11 | 12 | " Utility Functions {{{1 13 | 14 | function! s:error(str) 15 | echohl ErrorMsg 16 | echomsg a:str 17 | echohl None 18 | let v:errmsg = a:str 19 | endfunction 20 | 21 | function! s:autoload(...) 22 | if !exists("g:autoloaded_rails") && v:version >= 700 23 | runtime! autoload/rails.vim 24 | endif 25 | if exists("g:autoloaded_rails") 26 | if a:0 27 | exe a:1 28 | endif 29 | return 1 30 | endif 31 | if !exists("g:rails_no_autoload_warning") 32 | let g:rails_no_autoload_warning = 1 33 | if v:version >= 700 34 | call s:error("Disabling rails.vim: autoload/rails.vim is missing") 35 | else 36 | call s:error("Disabling rails.vim: Vim version 7 or higher required") 37 | endif 38 | endif 39 | return "" 40 | endfunction 41 | 42 | " }}}1 43 | " Configuration {{{ 44 | 45 | function! s:SetOptDefault(opt,val) 46 | if !exists("g:".a:opt) 47 | let g:{a:opt} = a:val 48 | endif 49 | endfunction 50 | 51 | call s:SetOptDefault("rails_abbreviations", {}) 52 | call s:SetOptDefault("rails_ctags_arguments","--languages=-javascript") 53 | call s:SetOptDefault("rails_root_url",'http://localhost:3000/') 54 | 55 | " }}}1 56 | " Detection {{{1 57 | 58 | function! s:escvar(r) 59 | let r = fnamemodify(a:r,':~') 60 | let r = substitute(r,'\W','\="_".char2nr(submatch(0))."_"','g') 61 | let r = substitute(r,'^\d','_&','') 62 | return r 63 | endfunction 64 | 65 | function! s:Detect(filename) 66 | if exists('b:rails_root') 67 | return s:BufInit(b:rails_root) 68 | endif 69 | let fn = substitute(fnamemodify(a:filename,":p"),'\c^file://','','') 70 | let sep = matchstr(fn,'^[^\\/]\{3,\}\zs[\\/]') 71 | if sep != "" 72 | let fn = getcwd().sep.fn 73 | endif 74 | if fn =~ '[\/]config[\/]environment\.rb$' 75 | return s:BufInit(strpart(fn,0,strlen(fn)-22)) 76 | endif 77 | if isdirectory(fn) 78 | let fn = fnamemodify(fn,':s?[\/]$??') 79 | else 80 | let fn = fnamemodify(fn,':s?\(.*\)[\/][^\/]*$?\1?') 81 | endif 82 | let ofn = "" 83 | let nfn = fn 84 | while nfn != ofn && nfn != "" 85 | if exists("s:_".s:escvar(nfn)) 86 | return s:BufInit(nfn) 87 | endif 88 | let ofn = nfn 89 | let nfn = fnamemodify(nfn,':h') 90 | endwhile 91 | let ofn = "" 92 | while fn != ofn 93 | if filereadable(fn . "/config/environment.rb") 94 | return s:BufInit(fn) 95 | endif 96 | let ofn = fn 97 | let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|extras\|features\|lib\|log\|public\|script\|spec\|stories\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?') 98 | endwhile 99 | return 0 100 | endfunction 101 | 102 | function! s:BufInit(path) 103 | let s:_{s:escvar(a:path)} = 1 104 | if s:autoload() 105 | return RailsBufInit(a:path) 106 | endif 107 | endfunction 108 | 109 | " }}}1 110 | " Initialization {{{1 111 | 112 | augroup railsPluginDetect 113 | autocmd! 114 | autocmd BufNewFile,BufRead * call s:Detect(expand(":p")) 115 | autocmd VimEnter * if expand("") == "" && !exists("b:rails_root") | call s:Detect(getcwd()) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif 116 | autocmd FileType netrw if !exists("b:rails_root") | call s:Detect(expand("%:p")) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif 117 | autocmd BufEnter * if exists("b:rails_root")|silent doau User BufEnterRails|endif 118 | autocmd BufLeave * if exists("b:rails_root")|silent doau User BufLeaveRails|endif 119 | autocmd Syntax railslog if s:autoload()|call rails#log_syntax()|endif 120 | augroup END 121 | 122 | command! -bar -bang -nargs=* -complete=dir Rails :if s:autoload()|execute rails#new_app_command(0,)|endif 123 | 124 | " }}}1 125 | " abolish.vim support {{{1 126 | 127 | function! s:function(name) 128 | return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) 129 | endfunction 130 | 131 | augroup railsPluginAbolish 132 | autocmd! 133 | autocmd VimEnter * call s:abolish_setup() 134 | augroup END 135 | 136 | function! s:abolish_setup() 137 | if exists('g:Abolish') && has_key(g:Abolish,'Coercions') 138 | if !has_key(g:Abolish.Coercions,'l') 139 | let g:Abolish.Coercions.l = s:function('s:abolish_l') 140 | endif 141 | if !has_key(g:Abolish.Coercions,'t') 142 | let g:Abolish.Coercions.t = s:function('s:abolish_t') 143 | endif 144 | endif 145 | endfunction 146 | 147 | function! s:abolish_l(word) 148 | let singular = rails#singularize(a:word) 149 | return a:word ==? singular ? rails#pluralize(a:word) : singular 150 | endfunction 151 | 152 | function! s:abolish_t(word) 153 | if a:word =~# '\u' 154 | return rails#pluralize(rails#underscore(a:word)) 155 | else 156 | return rails#singularize(rails#camelize(a:word)) 157 | endif 158 | endfunction 159 | 160 | " }}}1 161 | " vim:set sw=2 sts=2: 162 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | """"""""""""""""""""""""""""""""""""""""" 2 | " 3 | " CtrlP 4 | " 5 | """""""""""""""""""""""""""""""""""""""" 6 | let g:ctrlp_map = ',,' 7 | let g:ctrlp_open_multiple_files = 'v' 8 | let g:ctrlp_by_filename = 1 9 | 10 | set wildignore+=*/tmp/*,*.so,*.swp,*.zip 11 | let g:ctrlp_custom_ignore = { 12 | \ 'dir': '\v[\/]\.(git)$', 13 | \ 'file': '\v\.(log|jpg|png|jpeg)$', 14 | \ } 15 | 16 | """""""""""""""""""""""""""""""""""""""" 17 | " 18 | " auto-save 19 | " 20 | """""""""""""""""""""""""""""""""""""""" 21 | let g:auto_save = 1 22 | 23 | """"""""""""""""""""""""""""""""""""""""" 24 | " 25 | " tComment 26 | " 27 | """""""""""""""""""""""""""""""""""""""" 28 | 29 | " Use Ctrl-c to comment and uncomment, cool 30 | map gcc 31 | 32 | """"""""""""""""""""""""""""""""""""""""" 33 | " 34 | " rails.vim 35 | " 36 | """""""""""""""""""""""""""""""""""""""" 37 | " I don't use Rcontroller... stuff a lot 38 | " cause I have CtrlP, but rails.vim provide me `gf` for rails projects 39 | 40 | """""""""""""""""""""""""""""""""""""""" 41 | " 42 | " for Mac 43 | " 44 | """""""""""""""""""""""""""""""""""""""" 45 | 46 | " vim run in Mac terminal, does not have syntax highlighting without this 47 | syntax on 48 | 49 | """""""""""""""""""""""""""""""""""""""" 50 | " 51 | " for markdown 52 | " 53 | """""""""""""""""""""""""""""""""""""""" 54 | 55 | " when you have .md file, default ft=modula2, thus wrong highlighting 56 | autocmd FileType modula2 set ft= 57 | 58 | 59 | """""""""""""""""""""""""""""""""""""""" 60 | " 61 | " pathogen 62 | " 63 | """""""""""""""""""""""""""""""""""""""" 64 | 65 | " doorkeeper of all my vim plugins 66 | call pathogen#infect() 67 | 68 | """""""""""""""""""""""""""""""""""""""" 69 | " 70 | " ack 71 | " 72 | """""""""""""""""""""""""""""""""""""""" 73 | 74 | " sudo apt-get install ack-grep, on ubuntu box 75 | map ,k :Ack 76 | 77 | 78 | """""""""""""""""""""""""""""""""""""""" 79 | " 80 | " EOL whitespace 81 | " 82 | """""""""""""""""""""""""""""""""""""""" 83 | 84 | " now if you have spaces at end of lines, you get notified 85 | set list 86 | set listchars=trail:+ 87 | 88 | 89 | """""""""""""""""""""""""""""""""""""""" 90 | " 91 | " paste 92 | " 93 | """""""""""""""""""""""""""""""""""""""" 94 | 95 | " for insert mode 96 | set pastetoggle= 97 | 98 | """""""""""""""""""""""""""""""""""""""" 99 | " 100 | " filetype 101 | " 102 | """""""""""""""""""""""""""""""""""""""" 103 | 104 | " Enable filetype plugin 105 | " for i_Ctrl-X_Ctrl-O 106 | filetype plugin on 107 | 108 | """""""""""""""""""""""""""""""""""""""" 109 | " 110 | " indent 111 | " 112 | """""""""""""""""""""""""""""""""""""""" 113 | 114 | " check :h filetype-indent-on 115 | " have proper indent level based on syntax 116 | " `=` also depends on this to work 117 | filetype indent on 118 | 119 | " if you use to indent the code 120 | " vim use tabs other than spaces for the indentaion 121 | " expandtab will turn a tab into 'tabstop' spaces 122 | set expandtab 123 | set tabstop=2 124 | 125 | 126 | " if you use '>' or to indent the code, this matters 127 | " this default to 8 128 | set shiftwidth=2 129 | 130 | " you can also set different indent level for other languages 131 | autocmd FileType c setlocal shiftwidth=4 tabstop=4 132 | 133 | """""""""""""""""""""""""""""""""""""""" 134 | " 135 | " buffers 136 | " 137 | """""""""""""""""""""""""""""""""""""""" 138 | 139 | set hidden "in order to switch between buffers with unsaved change 140 | map :bp 141 | map :bn 142 | map ,bd :bd 143 | 144 | """""""""""""""""""""""""""""""""""""""" 145 | " 146 | " why I use *,* to do mapping? 147 | " 148 | """""""""""""""""""""""""""""""""""""""" 149 | 150 | " inspired by Derek, the reasons: 151 | " 1. is too long to type 152 | " 2. *,* is easier to reach than *\* 153 | " 3. in practice you nerver type in *,v*, but *, v* 154 | " Derek also do a nomap for *,* 155 | " nnomap , 156 | " I do not do it, since I do not use *,* as a command a lot 157 | 158 | 159 | """""""""""""""""""""""""""""""""""""""" 160 | " 161 | " quit quickly 162 | " 163 | """""""""""""""""""""""""""""""""""""""" 164 | 165 | map ,f :q! 166 | 167 | """""""""""""""""""""""""""""""""""""""" 168 | " 169 | " vimrc editing 170 | " 171 | """""""""""""""""""""""""""""""""""""""" 172 | 173 | " I need a fake ~/.vimrc: runtime vimrc 174 | " http://www.derekwyatt.org/vim/the-vimrc-file/my-vimrc-file/ 175 | map ,e :e ~/.vim/vimrc 176 | " When vimrc is edited, reload it 177 | " copied from http://amix.dk/vim/vimrc.html 178 | autocmd! bufwritepost vimrc source ~/.vim/vimrc 179 | 180 | 181 | """""""""""""""""""""""""""""""""""""""" 182 | " 183 | " quick escape 184 | " 185 | """""""""""""""""""""""""""""""""""""""" 186 | 187 | " set quick escape from insert mode, and now I can go without arrow keys and 188 | " use j and k to move around in insert mode 189 | imap jj 190 | 191 | """""""""""""""""""""""""""""""""""""""" 192 | " 193 | " wildmode 194 | " 195 | """""""""""""""""""""""""""""""""""""""" 196 | 197 | " use with this to get a list 198 | set wildmenu 199 | 200 | """""""""""""""""""""""""""""""""""""""" 201 | " 202 | " dictionary 203 | " 204 | """""""""""""""""""""""""""""""""""""" 205 | 206 | " i_CTRL_X_K 207 | set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words 208 | 209 | """""""""""""""""""""""""""""""""""""""" 210 | " 211 | " Search 212 | " 213 | """""""""""""""""""""""""""""""""""""""" 214 | 215 | " ic also has effect on dictionary settings 216 | set ic 217 | "set hlsearch 218 | set incsearch 219 | 220 | """""""""""""""""""""""""""""""""""""""" 221 | " 222 | " status line 223 | " 224 | """""""""""""""""""""""""""""""""""""""" 225 | 226 | " Set the status line the way i like it 227 | set statusline=%F:\ %l 228 | 229 | " tell VIM to always put a status line in, even if there is only one window 230 | " this means I can also see what is the filename I am in, finally! 231 | set laststatus=2 232 | 233 | """""""""""""""""""""""""""""""""""""""" 234 | " 235 | " misc 236 | " 237 | """""""""""""""""""""""""""""""""""""""" 238 | 239 | " have nice $ sign when you use `cw` 240 | set cpoptions+=$ 241 | 242 | " Do not know how to use autocmd yet, so the following line not working 243 | " autocmd FileType text setlocal textwidth=78 244 | " set textwidth=78 245 | 246 | 247 | " get rid of the silly characters in window separators 248 | set fillchars="" 249 | 250 | " hello-world is now one world 251 | set isk+=- 252 | 253 | " change cwd to current buffer 254 | nmap ,cd :lcd %:h 255 | --------------------------------------------------------------------------------