1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

Updated plugins

This commit is contained in:
amix 2013-07-17 19:06:05 -04:00
parent 879a7b6bd4
commit a448b32309
85 changed files with 2174 additions and 941 deletions

View file

@ -68,6 +68,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'key_loop': ['s:keyloop', 0], \ 'key_loop': ['s:keyloop', 0],
\ 'lazy_update': ['s:lazy', 0], \ 'lazy_update': ['s:lazy', 0],
\ 'match_func': ['s:matcher', {}], \ 'match_func': ['s:matcher', {}],
\ 'match_window': ['s:mw', ''],
\ 'match_window_bottom': ['s:mwbottom', 1], \ 'match_window_bottom': ['s:mwbottom', 1],
\ 'match_window_reversed': ['s:mwreverse', 1], \ 'match_window_reversed': ['s:mwreverse', 1],
\ 'max_depth': ['s:maxdepth', 40], \ 'max_depth': ['s:maxdepth', 40],
@ -102,7 +103,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
" Global options " Global options
let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0, let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n', \ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'ttimeout': 0,
\ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 } \ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 }
" Keymaps " Keymaps
@ -181,7 +182,7 @@ let s:hlgrps = {
\ 'PrtText': 'Normal', \ 'PrtText': 'Normal',
\ 'PrtCursor': 'Constant', \ 'PrtCursor': 'Constant',
\ } \ }
" s:opts() {{{2 " Get the options {{{2
fu! s:opts(...) fu! s:opts(...)
unl! s:usrign s:usrcmd s:urprtmaps unl! s:usrign s:usrcmd s:urprtmaps
for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each) for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each)
@ -201,6 +202,9 @@ fu! s:opts(...)
let {va} = {s:bpref.ke} let {va} = {s:bpref.ke}
en en
endfo endfo
" Match window options
cal s:match_window_opts()
" One-time values
if a:0 && a:1 != {} if a:0 && a:1 != {}
unl va unl va
for [ke, va] in items(a:1) for [ke, va] in items(a:1)
@ -217,7 +221,6 @@ fu! s:opts(...)
en | endfo en | endfo
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
let s:maxdepth = min([s:maxdepth, 100]) let s:maxdepth = min([s:maxdepth, 100])
let s:mxheight = max([s:mxheight, 1])
let s:glob = s:showhidden ? '.*\|*' : '*' let s:glob = s:showhidden ? '.*\|*' : '*'
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign) let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
let s:lash = ctrlp#utils#lash() let s:lash = ctrlp#utils#lash()
@ -238,13 +241,32 @@ fu! s:opts(...)
cal extend(s:prtmaps, s:urprtmaps) cal extend(s:prtmaps, s:urprtmaps)
en en
endf endf
fu! s:match_window_opts()
let s:mw_pos =
\ s:mw =~ 'top\|bottom' ? matchstr(s:mw, 'top\|bottom') :
\ exists('g:ctrlp_match_window_bottom') ? ( s:mwbottom ? 'bottom' : 'top' )
\ : 'bottom'
let s:mw_order =
\ s:mw =~ 'order:[^,]\+' ? matchstr(s:mw, 'order:\zs[^,]\+') :
\ exists('g:ctrlp_match_window_reversed') ? ( s:mwreverse ? 'btt' : 'ttb' )
\ : 'btt'
let s:mw_max =
\ s:mw =~ 'max:[^,]\+' ? str2nr(matchstr(s:mw, 'max:\zs\d\+')) :
\ exists('g:ctrlp_max_height') ? s:mxheight
\ : 10
let s:mw_min =
\ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
let s:mw_min = min([s:mw_min, s:mw_max])
endf
"}}}1 "}}}1
" * Open & Close {{{1 " * Open & Close {{{1
fu! s:Open() fu! s:Open()
cal s:log(1) cal s:log(1)
cal s:getenv() cal s:getenv()
cal s:execextvar('enter') cal s:execextvar('enter')
sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP' sil! exe 'keepa' ( s:mw_pos == 'top' ? 'to' : 'bo' ) '1new ControlP'
cal s:buffunc(1) cal s:buffunc(1)
let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)] let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)]
let [s:focus, s:prompt] = [1, ['', '', '']] let [s:focus, s:prompt] = [1, ['', '', '']]
@ -297,7 +319,7 @@ fu! ctrlp#clra()
if isdirectory(cadir) if isdirectory(cadir)
let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n") let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n")
let eval = '!isdirectory(v:val) && v:val !~ ''\v[\/]cache[.a-z]+$|\.log$''' let eval = '!isdirectory(v:val) && v:val !~ ''\v[\/]cache[.a-z]+$|\.log$'''
sil! cal map(filter(cafiles, eval), 'delete(v:val)') sil! cal map(s:ifilter(cafiles, eval), 'delete(v:val)')
en en
cal ctrlp#clr() cal ctrlp#clr()
endf endf
@ -362,7 +384,7 @@ fu! s:UserCmd(lscmd)
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
en en
if has('win32') || has('win64') if has('win32') || has('win64')
let lscmd = substitute(lscmd, '\v(^|&&\s*)\zscd (/d)@!', 'cd /d ', '') let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
en en
let path = exists('*shellescape') ? shellescape(path) : path let path = exists('*shellescape') ? shellescape(path) : path
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n") let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
@ -433,7 +455,7 @@ endf
fu! s:MatchIt(items, pat, limit, exc) fu! s:MatchIt(items, pat, limit, exc)
let [lines, id] = [[], 0] let [lines, id] = [[], 0]
let pat = let pat =
\ s:byfname ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val') \ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
\ : s:martcs.a:pat \ : s:martcs.a:pat
for item in a:items for item in a:items
let id += 1 let id += 1
@ -450,7 +472,16 @@ fu! s:MatchedItems(items, pat, limit)
let exc = exists('s:crfilerel') ? s:crfilerel : '' let exc = exists('s:crfilerel') ? s:crfilerel : ''
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
if s:matcher != {} if s:matcher != {}
let argms = [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp] let argms =
\ has_key(s:matcher, 'arg_type') && s:matcher['arg_type'] == 'dict' ? [{
\ 'items': items,
\ 'str': a:pat,
\ 'limit': a:limit,
\ 'mmode': s:mmode(),
\ 'ispath': s:ispath,
\ 'crfile': exc,
\ 'regex': s:regexp,
\ }] : [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
let lines = call(s:matcher['match'], argms, s:matcher) let lines = call(s:matcher['match'], argms, s:matcher)
el el
let lines = s:MatchIt(items, a:pat, a:limit, exc) let lines = s:MatchIt(items, a:pat, a:limit, exc)
@ -480,7 +511,7 @@ fu! s:SplitPattern(str)
if exists('lst') if exists('lst')
let pat = '' let pat = ''
if !empty(lst) if !empty(lst)
if s:byfname && index(lst, ';') > 0 if s:byfname() && index(lst, ';') > 0
let fbar = index(lst, ';') let fbar = index(lst, ';')
let lst_1 = s:sublist(lst, 0, fbar - 1) let lst_1 = s:sublist(lst, 0, fbar - 1)
let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : [''] let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : ['']
@ -494,15 +525,19 @@ fu! s:SplitPattern(str)
endf endf
" * BuildPrompt() {{{1 " * BuildPrompt() {{{1
fu! s:Render(lines, pat) fu! s:Render(lines, pat)
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])] let [&ma, lines, s:res_count] = [1, a:lines, len(a:lines)]
let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let cur_cmd = 'keepj norm! '.( s:mw_order == 'btt' ? 'G' : 'gg' ).'1|'
" Setup the match window " Setup the match window
sil! exe '%d _ | res' s:height sil! exe '%d _ | res' height
" Print the new items " Print the new items
if empty(lines) if empty(lines)
let [s:matched, s:lines] = [[], []] let [s:matched, s:lines] = [[], []]
cal setline(1, ' == NO ENTRIES ==') let lines = [' == NO ENTRIES ==']
cal setline(1, s:offset(lines, height - 1))
setl noma nocul setl noma nocul
exe cur_cmd
cal s:unmarksigns() cal s:unmarksigns()
if s:dohighlight() | cal clearmatches() | en if s:dohighlight() | cal clearmatches() | en
retu retu
@ -514,12 +549,12 @@ fu! s:Render(lines, pat)
cal sort(lines, 's:mixedsort') cal sort(lines, 's:mixedsort')
unl s:compat unl s:compat
en en
if s:mwreverse | cal reverse(lines) | en if s:mw_order == 'btt' | cal reverse(lines) | en
let s:lines = copy(lines) let s:lines = copy(lines)
cal map(lines, 's:formatline(v:val)') cal map(lines, 's:formatline(v:val)')
cal setline(1, lines) cal setline(1, s:offset(lines, height))
setl noma cul setl noma cul
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|' exe cur_cmd
cal s:unmarksigns() cal s:unmarksigns()
cal s:remarksigns() cal s:remarksigns()
if exists('s:cline') && s:nolim != 1 if exists('s:cline') && s:nolim != 1
@ -541,7 +576,7 @@ fu! s:Update(str)
let s:martcs = &scs && str =~ '\u' ? '\C' : '' let s:martcs = &scs && str =~ '\u' ? '\C' : ''
let pat = s:matcher == {} ? s:SplitPattern(str) : str let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines) let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winh) \ : s:MatchedItems(g:ctrlp_lines, pat, s:winmaxh)
cal s:Render(lines, pat) cal s:Render(lines, pat)
endf endf
@ -550,7 +585,7 @@ fu! s:ForceUpdate()
endf endf
fu! s:BuildPrompt(upd) fu! s:BuildPrompt(upd)
let base = ( s:regexp ? 'r' : '>' ).( s:byfname ? 'd' : '>' ).'> ' let base = ( s:regexp ? 'r' : '>' ).( s:byfname() ? 'd' : '>' ).'> '
let str = escape(s:getinput(), '\') let str = escape(s:getinput(), '\')
let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy
if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp') if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp')
@ -581,11 +616,8 @@ fu! s:SetDefTxt()
if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
let txt = s:deftxt let txt = s:deftxt
if !type(txt) if !type(txt)
let txt = txt && !stridx(s:crfpath, s:dyncwd) let path = s:crfpath.s:lash(s:crfpath)
\ ? ctrlp#rmbasedir([s:crfpath])[0] : '' let txt = txt && !stridx(path, s:dyncwd) ? ctrlp#rmbasedir([path])[0] : ''
let txt = txt != '' ? txt.s:lash(s:crfpath) : ''
el
let txt = expand(txt, 1)
en en
let s:prompt[0] = txt let s:prompt[0] = txt
endf endf
@ -735,7 +767,7 @@ endf
fu! s:PrtSelectJump(char) fu! s:PrtSelectJump(char)
let lines = copy(s:lines) let lines = copy(s:lines)
if s:byfname if s:byfname()
cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]') cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]')
en en
" Cycle through matches, use s:jmpchr to store last jump " Cycle through matches, use s:jmpchr to store last jump
@ -904,6 +936,11 @@ fu! s:ToggleKeyLoop()
en en
endf endf
fu! s:ToggleMRURelative()
cal ctrlp#mrufiles#tgrel()
cal s:PrtClearCache()
endf
fu! s:PrtSwitcher() fu! s:PrtSwitcher()
let [s:force, s:matches] = [1, 1] let [s:force, s:matches] = [1, 1]
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
@ -937,14 +974,21 @@ fu! s:SetWD(args)
en en
endf endf
" * AcceptSelection() {{{1 " * AcceptSelection() {{{1
fu! ctrlp#acceptfile(mode, line, ...) fu! ctrlp#acceptfile(...)
let [md, useb] = [a:mode, 0] let useb = 0
if !type(a:line) if a:0 == 1 && type(a:1) == 4
let [filpath, bufnr, useb] = [a:line, a:line, 1] let [md, line] = [a:1['action'], a:1['line']]
let atl = has_key(a:1, 'tail') ? a:1['tail'] : ''
el el
let filpath = fnamemodify(a:line, ':p') let [md, line] = [a:1, a:2]
if s:nonamecond(a:line, filpath) let atl = a:0 > 2 ? a:3 : ''
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) en
if !type(line)
let [filpath, bufnr, useb] = [line, line, 1]
el
let filpath = fnamemodify(line, ':p')
if s:nonamecond(line, filpath)
let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let [filpath, useb] = [bufnr, 1] let [filpath, useb] = [bufnr, 1]
el el
let bufnr = bufnr('^'.filpath.'$') let bufnr = bufnr('^'.filpath.'$')
@ -952,7 +996,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
en en
cal s:PrtExit() cal s:PrtExit()
let tail = s:tail() let tail = s:tail()
let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$') let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
\ && !( md == 'e' && bufnr == bufnr('%') ) \ && !( md == 'e' && bufnr == bufnr('%') )
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
@ -980,7 +1024,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
" Reset &switchbuf option " Reset &switchbuf option
let [swb, &swb] = [&swb, ''] let [swb, &swb] = [&swb, '']
" Open new window/buffer " Open new window/buffer
let [fid, tail] = [( useb ? bufnr : filpath ), ( a:0 ? ' +'.a:1 : tail )] let [fid, tail] = [( useb ? bufnr : filpath ), ( atl != '' ? ' +'.atl : tail )]
let args = [cmd, fid, tail, 1, [useb, j2l]] let args = [cmd, fid, tail, 1, [useb, j2l]]
cal call('s:openfile', args) cal call('s:openfile', args)
let &swb = swb let &swb = swb
@ -1011,24 +1055,34 @@ fu! s:SpecInputs(str)
retu 0 retu 0
endf endf
fu! s:AcceptSelection(mode) fu! s:AcceptSelection(action)
if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en let [md, icr] = [a:action[0], match(a:action, 'r') >= 0]
let subm = icr || ( !icr && md == 'e' )
if !subm && s:OpenMulti(md) != -1 | retu | en
let str = s:getinput() let str = s:getinput()
if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en if subm | if s:SpecInputs(str) | retu | en | en
" Get the selected line " Get the selected line
let line = ctrlp#getcline() let line = ctrlp#getcline()
if a:mode != 'e' && !s:itemtype && line == '' if !subm && !s:itemtype && line == '' && line('.') > s:offset
\ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$' \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
cal s:CreateNewFile(a:mode) | retu cal s:CreateNewFile(md) | retu
en en
if empty(line) | retu | en if empty(line) | retu | en
" Do something with it " Do something with it
if s:openfunc != {} && has_key(s:openfunc, s:ctype) if s:openfunc != {} && has_key(s:openfunc, s:ctype)
let actfunc = s:openfunc[s:ctype] let actfunc = s:openfunc[s:ctype]
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
el el
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept') if s:itemtype < 3
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
el
let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
let type = exttype == 'dict' ? exttype : 'list'
en
en en
cal call(actfunc, [a:mode, line]) let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr }]
\ : [md, line]
cal call(actfunc, actargs)
endf endf
" - CreateNewFile() {{{1 " - CreateNewFile() {{{1
fu! s:CreateNewFile(...) fu! s:CreateNewFile(...)
@ -1187,7 +1241,10 @@ fu! s:OpenNoMarks(md, line)
cal s:remarksigns() cal s:remarksigns()
cal s:BuildPrompt(0) cal s:BuildPrompt(0)
elsei a:md == 'x' elsei a:md == 'x'
cal call(s:openfunc[s:ctype], [a:md, a:line], s:openfunc) let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict'
let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }]
\ : [a:md, a:line]
cal call(s:openfunc[s:ctype], argms, s:openfunc)
elsei a:md == 'd' elsei a:md == 'd'
let dir = fnamemodify(a:line, ':h') let dir = fnamemodify(a:line, ':h')
if isdirectory(dir) if isdirectory(dir)
@ -1278,7 +1335,7 @@ fu! s:mixedsort(...)
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)] let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
if s:ispath if s:ispath
let ms = [] let ms = []
if s:height < 21 if s:res_count < 21
let ms += [s:compfnlen(a:1, a:2)] let ms += [s:compfnlen(a:1, a:2)]
if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
@ -1324,12 +1381,21 @@ fu! ctrlp#statusline()
let prv = tps[s:walker(max, s:itemtype, -1)][1] let prv = tps[s:walker(max, s:itemtype, -1)][1]
let s:ctype = tps[s:itemtype][0] let s:ctype = tps[s:itemtype][0]
let focus = s:focus ? 'prt' : 'win' let focus = s:focus ? 'prt' : 'win'
let byfname = s:byfname ? 'file' : 'path' let byfname = s:ispath ? s:byfname ? 'file' : 'path' : 'line'
let marked = s:opmul != '0' ? let marked = s:opmul != '0' ?
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
if s:status != {} if s:status != {}
let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked] let argms =
let &l:stl = call(s:status['main'], args, s:status) \ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{
\ 'focus': focus,
\ 'byfname': byfname,
\ 'regex': s:regexp,
\ 'prev': prv,
\ 'item': s:ctype,
\ 'next': nxt,
\ 'marked': marked,
\ }] : [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
let &l:stl = call(s:status['main'], argms, s:status)
el el
let item = '%#CtrlPMode1# '.s:ctype.' %*' let item = '%#CtrlPMode1# '.s:ctype.' %*'
let focus = '%#CtrlPMode2# '.focus.' %*' let focus = '%#CtrlPMode2# '.focus.' %*'
@ -1349,8 +1415,13 @@ endf
fu! ctrlp#progress(enum, ...) fu! ctrlp#progress(enum, ...)
if has('macunix') || has('mac') | sl 1m | en if has('macunix') || has('mac') | sl 1m | en
let txt = a:0 ? '(press ctrl-c to abort)' : '' let txt = a:0 ? '(press ctrl-c to abort)' : ''
let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum], s:status) if s:status != {}
\ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*' let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict'
\ ? [{ 'str': a:enum }] : [a:enum]
let &l:stl = call(s:status['prog'], argms, s:status)
el
let &l:stl = '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
en
redraws redraws
endf endf
" *** Paths {{{2 " *** Paths {{{2
@ -1376,6 +1447,11 @@ fu! s:pathshorten(str)
retu matchstr(a:str, '^.\{9}').'...' retu matchstr(a:str, '^.\{9}').'...'
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
endf endf
fu! s:offset(lines, height)
let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0
retu s:offset > 0 ? ( repeat([''], s:offset) + a:lines ) : a:lines
endf
" Directory completion {{{3 " Directory completion {{{3
fu! s:dircompl(be, sd) fu! s:dircompl(be, sd)
if a:sd == '' | retu [] | en if a:sd == '' | retu [] | en
@ -1464,7 +1540,7 @@ fu! s:samerootsyml(each, isfile, cwd)
endf endf
fu! ctrlp#rmbasedir(items) fu! ctrlp#rmbasedir(items)
let cwd = s:dyncwd.( s:dyncwd !~ '[\/]$' ? s:lash : '' ) let cwd = s:dyncwd.s:lash()
if a:items != [] && !stridx(a:items[0], cwd) if a:items != [] && !stridx(a:items[0], cwd)
let idx = strlen(cwd) let idx = strlen(cwd)
retu map(a:items, 'strpart(v:val, idx)') retu map(a:items, 'strpart(v:val, idx)')
@ -1599,6 +1675,18 @@ fu! s:dosigns()
retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs') retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs')
endf endf
" Lists & Dictionaries {{{2 " Lists & Dictionaries {{{2
fu! s:ifilter(list, str)
let [rlist, estr] = [[], substitute(a:str, 'v:val', 'each', 'g')]
for each in a:list
try
if eval(estr)
cal add(rlist, each)
en
cat | con | endt
endfo
retu rlist
endf
fu! s:dictindex(dict, expr) fu! s:dictindex(dict, expr)
for key in keys(a:dict) for key in keys(a:dict)
if a:dict[key] == a:expr | retu key | en if a:dict[key] == a:expr | retu key | en
@ -1808,7 +1896,6 @@ endf
fu! s:modevar() fu! s:modevar()
let s:matchtype = s:mtype() let s:matchtype = s:mtype()
let s:ispath = s:ispathitem() let s:ispath = s:ispathitem()
if !s:ispath | let s:byfname = 0 | en
let s:mfunc = s:mfunc() let s:mfunc = s:mfunc()
let s:nolim = s:getextvar('nolim') let s:nolim = s:getextvar('nolim')
let s:dosort = s:getextvar('sort') let s:dosort = s:getextvar('sort')
@ -1820,6 +1907,10 @@ fu! s:nosort()
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort \ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
endf endf
fu! s:byfname()
retu s:ispath && s:byfname
endf
fu! s:narrowable() fu! s:narrowable()
retu exists('s:act_add') && exists('s:matched') && s:matched != [] retu exists('s:act_add') && exists('s:matched') && s:matched != []
\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp] \ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
@ -1834,7 +1925,7 @@ fu! s:getinput(...)
if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k' if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k'
retu join(prt, '') retu join(prt, '')
en en
let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )] let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
for dict in s:abbrev['abbrevs'] for dict in s:abbrev['abbrevs']
let dmd = has_key(dict, 'mode') ? dict['mode'] : '' let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
let pat = escape(dict['pattern'], '~') let pat = escape(dict['pattern'], '~')
@ -1916,7 +2007,7 @@ fu! s:getenv()
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)] let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)]
let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')] let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')]
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')] let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')]
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
let s:crfile = bufname('%') == '' let s:crfile = bufname('%') == ''
\ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1) \ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1)
@ -1939,7 +2030,8 @@ endf
fu! s:log(m) fu! s:log(m)
if exists('g:ctrlp_log') && g:ctrlp_log | if a:m if exists('g:ctrlp_log') && g:ctrlp_log | if a:m
let cadir = ctrlp#utils#cachedir() let cadir = ctrlp#utils#cachedir()
sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log' let apd = g:ctrlp_log > 1 ? '>' : ''
sil! exe 'redi! >'.apd cadir.s:lash(cadir).'ctrlp.log'
el el
sil! redi END sil! redi END
en | en en | en
@ -2023,7 +2115,7 @@ endf
fu! s:mfunc() fu! s:mfunc()
let mfunc = 'match' let mfunc = 'match'
if s:byfname && s:ispath if s:byfname()
let mfunc = 's:matchfname' let mfunc = 's:matchfname'
elsei s:itemtype > 2 elsei s:itemtype > 2
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
@ -2102,7 +2194,9 @@ fu! s:getextvar(key)
endf endf
fu! ctrlp#getcline() fu! ctrlp#getcline()
retu !empty(s:lines) ? s:lines[line('.') - 1] : '' let [linenr, offset] = [line('.'), ( s:offset > 0 ? s:offset : 0 )]
retu !empty(s:lines) && !( offset && linenr <= offset )
\ ? s:lines[linenr - 1 - offset] : ''
endf endf
fu! ctrlp#getmarkedlist() fu! ctrlp#getmarkedlist()
@ -2134,6 +2228,10 @@ endf
fu! ctrlp#call(func, ...) fu! ctrlp#call(func, ...)
retu call(a:func, a:000) retu call(a:func, a:000)
endf endf
fu! ctrlp#getvar(var)
retu {a:var}
endf
"}}}1 "}}}1
" * Initialization {{{1 " * Initialization {{{1
fu! ctrlp#setlines(...) fu! ctrlp#setlines(...)

View file

@ -248,7 +248,9 @@ endf
fu! ctrlp#buffertag#cmd(mode, ...) fu! ctrlp#buffertag#cmd(mode, ...)
let s:btmode = a:mode let s:btmode = a:mode
if a:0 && !empty(a:1) if a:0 && !empty(a:1)
let s:bufname = fnamemodify(a:1, ':p') let s:btmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufname = fnamemodify(bname, ':p')
en en
retu s:id retu s:id
endf endf

View file

@ -83,7 +83,9 @@ endf
fu! ctrlp#changes#cmd(mode, ...) fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode let s:clmode = a:mode
if a:0 && !empty(a:1) if a:0 && !empty(a:1)
let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$') let s:clmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en en
retu s:id retu s:id
endf endf

View file

@ -74,7 +74,7 @@ fu! ctrlp#dir#init(...)
endf endf
fu! ctrlp#dir#accept(mode, str) fu! ctrlp#dir#accept(mode, str)
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
if a:mode =~ 't\|v\|h' if a:mode =~ 't\|v\|h'
cal ctrlp#exit() cal ctrlp#exit()
en en

View file

@ -11,7 +11,7 @@ en
let g:loaded_ctrlp_line = 1 let g:loaded_ctrlp_line = 1
cal add(g:ctrlp_ext_vars, { cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#line#init()', \ 'init': 'ctrlp#line#init(s:crbufnr)',
\ 'accept': 'ctrlp#line#accept', \ 'accept': 'ctrlp#line#accept',
\ 'lname': 'lines', \ 'lname': 'lines',
\ 'sname': 'lns', \ 'sname': 'lns',
@ -29,8 +29,9 @@ fu! s:syntax()
en en
endf endf
" Public {{{1 " Public {{{1
fu! ctrlp#line#init() fu! ctrlp#line#init(bufnr)
let [bufs, lines] = [ctrlp#buffers('id'), []] let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
let bufs = exists('s:lnmode') && s:lnmode ? ctrlp#buffers('id') : [bufnr]
for bufnr in bufs for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)] let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
if lfb == [] && bufn != '' if lfb == [] && bufn != ''
@ -57,7 +58,13 @@ fu! ctrlp#line#accept(mode, str)
en en
endf endf
fu! ctrlp#line#id() fu! ctrlp#line#cmd(mode, ...)
let s:lnmode = a:mode
if a:0 && !empty(a:1)
let s:lnmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id retu s:id
endf endf
"}}} "}}}

View file

@ -126,6 +126,10 @@ fu! ctrlp#mrufiles#bufs()
retu s:mrbs retu s:mrbs
endf endf
fu! ctrlp#mrufiles#tgrel()
let {s:re} = !{s:re}
endf
fu! ctrlp#mrufiles#cachefile() fu! ctrlp#mrufiles#cachefile()
if !exists('s:cadir') || !exists('s:cafile') if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru' let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'

View file

@ -40,9 +40,7 @@ Overview:~
|ctrlp_cmd|...................Default command used for the default mapping. |ctrlp_cmd|...................Default command used for the default mapping.
|ctrlp_by_filename|...........Default to filename mode or not. |ctrlp_by_filename|...........Default to filename mode or not.
|ctrlp_regexp|................Default to regexp mode or not. |ctrlp_regexp|................Default to regexp mode or not.
|ctrlp_match_window_bottom|...Where to show the match window. |ctrlp_match_window|..........Order, height and position of the match window.
|ctrlp_match_window_reversed|.Sort order in the match window.
|ctrlp_max_height|............Max height of the match window.
|ctrlp_switch_buffer|.........Jump to an open buffer if already opened. |ctrlp_switch_buffer|.........Jump to an open buffer if already opened.
|ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc). |ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc).
|ctrlp_tabpage_position|......Where to put the new tab page. |ctrlp_tabpage_position|......Where to put the new tab page.
@ -77,6 +75,11 @@ Overview:~
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
|ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added. |ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
BufferTag mode: (to enable, see |ctrlp-extensions|)
|g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
|g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
|g:ctrlp_buftag_types|........Add new filetypes and set the cmd arguments.
Advanced options: Advanced options:
|ctrlp_open_func|.............Use custom file opening functions. |ctrlp_open_func|.............Use custom file opening functions.
|ctrlp_status_func|...........Change CtrlP's two statuslines. |ctrlp_status_func|...........Change CtrlP's two statuslines.
@ -114,21 +117,27 @@ Set this to 1 to set regexp search as the default: >
< <
Can be toggled on/off by pressing <c-r> inside the prompt. Can be toggled on/off by pressing <c-r> inside the prompt.
*'g:ctrlp_match_window_bottom'* *'g:ctrlp_match_window'*
Set this to 0 to show the match window at the top of the screen: > Change the postion, the listing order of results, the minimum and the maximum
let g:ctrlp_match_window_bottom = 1 heights of the match window: >
let g:ctrlp_match_window = ''
< <
Example: >
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10'
<
The position: (default: bottom)
top - show the match window at the top of the screen.
bottom - show the match window at the bottom of the screen.
*'g:ctrlp_match_window_reversed'* The listing order of results: (default: btt)
Change the listing order of the files in the match window. The default setting order:ttb - from top to bottom.
(1) is from bottom to top: > order:btt - from bottom to top.
let g:ctrlp_match_window_reversed = 1
<
*'g:ctrlp_max_height'* The minimum and maximum heights:
Set the maximum height of the match window: > min:{n} - show minimum {n} lines (default: 1).
let g:ctrlp_max_height = 10 max:{n} - show maximum {n} lines (default: 10).
<
Note: When a setting isn't set, its default value will be used.
*'g:ctrlp_switch_buffer'* *'g:ctrlp_switch_buffer'*
When opening a file, if it's already open in a window somewhere, CtrlP will try When opening a file, if it's already open in a window somewhere, CtrlP will try
@ -323,18 +332,21 @@ Some examples: >
let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') ' let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
\ . 'do hg --cwd %s status -numac -I . %%a'] " Windows \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows
< <
Note #1: if the fallback_command is empty or the 'fallback' key is not defined, Note #1: in the |Dictionary| format, 'fallback' and 'ignore' are optional. In
the |List| format, fallback_command is optional.
Note #2: if the fallback_command is empty or the 'fallback' key is not defined,
|globpath()| will then be used when scanning outside of a repository. |globpath()| will then be used when scanning outside of a repository.
Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set Note #3: unless the |Dictionary| format is used and 'ignore' is defined and set
to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
these custom commands are being used. When not present, 'ignore' is set to 0 by these custom commands are being used. When not present, 'ignore' is set to 0 by
default to retain the performance advantage of using external commands. default to retain the performance advantage of using external commands.
Note #3: when changing the option's variable type, remember to |:unlet| it Note #4: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error. first or restart Vim to avoid the "E706: Variable type mismatch" error.
Note #4: you can use a |b:var| to set this option on a per buffer basis. Note #5: you can use a |b:var| to set this option on a per buffer basis.
*'g:ctrlp_max_history'* *'g:ctrlp_max_history'*
The maximum number of input strings you want CtrlP to remember. The default The maximum number of input strings you want CtrlP to remember. The default
@ -563,6 +575,9 @@ Example: >
Set this to 1 to show only MRU files in the current working directory: > Set this to 1 to show only MRU files in the current working directory: >
let g:ctrlp_mruf_relative = 0 let g:ctrlp_mruf_relative = 0
< <
Note: you can use a custom mapping to toggle this option inside the prompt: >
let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': ['<F2>'] }
<
*'g:ctrlp_mruf_default_order'* *'g:ctrlp_mruf_default_order'*
Set this to 1 to disable sorting when searching in MRU mode: > Set this to 1 to disable sorting when searching in MRU mode: >
@ -734,6 +749,27 @@ Structure of the function: >
endfunction endfunction
< <
Note: you can extend any of the above options with { 'arg_type': 'dict' } to
enable passing all the function arguments in a single Dictionary argument. Use
the existing argument names as keys in this Dictionary.
Example: >
let g:ctrlp_status_func = {
\ 'arg_type' : 'dict',
\ 'enter': 'Function_Name_1',
\ 'exit': 'Function_Name_2',
\ }
function! Function_Name_1(dict)
" where dict == {
" \ 'focus': value,
" \ 'byfname': value,
" \ 'regex': value,
" \ ...
" }
endfunction
<
=============================================================================== ===============================================================================
COMMANDS *ctrlp-commands* COMMANDS *ctrlp-commands*
@ -1076,8 +1112,8 @@ Available extensions:~
*:CtrlPLine* *:CtrlPLine*
* Line mode:~ * Line mode:~
- Name: 'line' - Name: 'line'
- Command: ":CtrlPLine" - Command: ":CtrlPLine [buffer]"
- Search for a line in all listed buffers. - Search for a line in all listed buffers or in the specified [buffer].
*:CtrlPChange* *:CtrlPChange*
*:CtrlPChangeAll* *:CtrlPChangeAll*
@ -1164,7 +1200,7 @@ Highlighting:~
Statuslines:~ Statuslines:~
* Highlight groups: * Highlight groups:
CtrlPMode1 : 'file' or 'path', and the current mode (Character) CtrlPMode1 : 'file' or 'path' or 'line', and the current mode (Character)
CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|) CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|)
CtrlPStats : the scanning status (Function) CtrlPStats : the scanning status (Function)
@ -1253,6 +1289,10 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
+ Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and
*g:ctrlp_max_height* into |g:ctrlp_match_window|.
+ New option: |g:ctrlp_match_window|.
Before 2012/11/30~ Before 2012/11/30~
+ New options: |g:ctrlp_abbrev|, + New options: |g:ctrlp_abbrev|,

View file

@ -51,7 +51,9 @@ com! -n=? -com=buffer CtrlPBufTag
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
com! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
com! -n=? -com=buffer CtrlPChange com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>)) \ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))

View file

@ -76,8 +76,8 @@ syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+
syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic
syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
@ -86,7 +86,7 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end=
if main_syntax ==# 'markdown' if main_syntax ==# 'markdown'
for s:type in g:markdown_fenced_languages for s:type in g:markdown_fenced_languages
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
endfor endfor
unlet! s:type unlet! s:type
endif endif

View file

@ -1,3 +1,7 @@
## 2.2 (06/10/2013)
Bugfixes:
- Fix plugin break in PASTE mode. This fixes #44.
## 2.1 (04/26/2013) ## 2.1 (04/26/2013)
Bugfixes: Bugfixes:

View file

@ -69,7 +69,7 @@ let g:multi_cursor_start_key='<F6>'
## Setting ## Setting
Currently there're two additional global settings one can tweak: Currently there're two additional global settings one can tweak:
### ```g:multi_cursor_exit_from_visual_mode``` (Defaut: 1) ### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors. If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
@ -87,7 +87,6 @@ highlight link multiple_cursors_visual Visual
## Issues ## Issues
- Multi key commands like `ciw` do not work at the moment - Multi key commands like `ciw` do not work at the moment
- Insert mode can be slow. If you are using Neobundle and have many plugins, try switching to Vundle to see if it helps. See https://github.com/Shougo/neobundle.vim/issues/84 for additional info.
- All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input. - All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input.
- Select mode is not implemented - Select mode is not implemented

View file

@ -50,9 +50,9 @@ endif
" Internal Mappings " Internal Mappings
"=============================================================================== "===============================================================================
inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_inut()<CR> inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_input()<CR>
nnoremap <silent> <Plug>(i) :call <SID>process_user_inut()<CR> nnoremap <silent> <Plug>(i) :call <SID>process_user_input()<CR>
xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_inut()<CR> xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_input()<CR>
inoremap <silent> <Plug>(a) <C-o>:call <SID>apply_user_input_next('i')<CR> inoremap <silent> <Plug>(a) <C-o>:call <SID>apply_user_input_next('i')<CR>
nnoremap <silent> <Plug>(a) :call <SID>apply_user_input_next('n')<CR> nnoremap <silent> <Plug>(a) :call <SID>apply_user_input_next('n')<CR>
@ -97,8 +97,8 @@ endfunction
" attempted to be created at the next occurrence of the visual selection " attempted to be created at the next occurrence of the visual selection
function! multiple_cursors#new(mode) function! multiple_cursors#new(mode)
if a:mode ==# 'n' if a:mode ==# 'n'
" Reset all existing cursors, don't restore view " Reset all existing cursors, don't restore view and setting
call s:cm.reset(0) call s:cm.reset(0, 0)
" Select the word under cursor to set the '< and '> marks " Select the word under cursor to set the '< and '> marks
exec "normal! viw" exec "normal! viw"
@ -113,7 +113,7 @@ function! multiple_cursors#new(mode)
let start = line("'<") let start = line("'<")
let finish = line("'>") let finish = line("'>")
if start != finish if start != finish
call s:cm.reset(0) call s:cm.reset(0, 0)
let col = col("'<") let col = col("'<")
for line in range(line("'<"), line("'>")) for line in range(line("'<"), line("'>"))
let pos = [line, col] let pos = [line, col]
@ -124,7 +124,7 @@ function! multiple_cursors#new(mode)
else else
" Came directly from visual mode " Came directly from visual mode
if s:cm.is_empty() if s:cm.is_empty()
call s:cm.reset(0) call s:cm.reset(0, 0)
if visualmode() ==# 'V' if visualmode() ==# 'V'
let left = [line('.'), 1] let left = [line('.'), 1]
@ -133,7 +133,7 @@ function! multiple_cursors#new(mode)
return return
endif endif
call s:cm.add(right, [left, right]) call s:cm.add(right, [left, right])
else else
call s:cm.add(s:pos("'>"), s:region("'<", "'>")) call s:cm.add(s:pos("'>"), s:region("'<", "'>"))
endif endif
endif endif
@ -219,7 +219,7 @@ function! multiple_cursors#find(start, end, pattern)
call winrestview(s:cm.saved_winview) call winrestview(s:cm.saved_winview)
echohl ErrorMsg | echo 'No match found' | echohl None echohl ErrorMsg | echo 'No match found' | echohl None
return return
else else
echohl Normal | echo 'Added '.s:cm.size().' cursor'.(s:cm.size()>1?'s':'') | echohl None echohl Normal | echo 'Added '.s:cm.size().' cursor'.(s:cm.size()>1?'s':'') | echohl None
call s:wait_for_user_input('v') call s:wait_for_user_input('v')
endif endif
@ -318,6 +318,7 @@ function! s:CursorManager.new()
\ 'virtualedit': &virtualedit, \ 'virtualedit': &virtualedit,
\ 'cursorline': &cursorline, \ 'cursorline': &cursorline,
\ 'lazyredraw': &lazyredraw, \ 'lazyredraw': &lazyredraw,
\ 'paste': &paste,
\ } \ }
" We save the window view when multicursor mode is entered " We save the window view when multicursor mode is entered
let obj.saved_winview = [] let obj.saved_winview = []
@ -327,7 +328,7 @@ function! s:CursorManager.new()
endfunction endfunction
" Clear all cursors and their highlights " Clear all cursors and their highlights
function! s:CursorManager.reset(restore_view) dict function! s:CursorManager.reset(restore_view, restore_setting) dict
if a:restore_view if a:restore_view
" Return the view back to the beginning " Return the view back to the beginning
if !empty(self.saved_winview) if !empty(self.saved_winview)
@ -357,7 +358,9 @@ function! s:CursorManager.reset(restore_view) dict
let self.saved_winview = [] let self.saved_winview = []
let self.start_from_find = 0 let self.start_from_find = 0
let s:char = '' let s:char = ''
call self.restore_user_settings() if a:restore_setting
call self.restore_user_settings()
endif
endfunction endfunction
" Returns 0 if it's not managing any cursors at the moment " Returns 0 if it's not managing any cursors at the moment
@ -513,10 +516,17 @@ endfunction
" where the real vim cursor is " where the real vim cursor is
" lazyredraw needs to be turned on to prevent jerky screen behavior with many " lazyredraw needs to be turned on to prevent jerky screen behavior with many
" cursors on screen " cursors on screen
" paste mode needs to be switched off since it turns off a bunch of features
" that's critical for the plugin to function
function! s:CursorManager.initialize() dict function! s:CursorManager.initialize() dict
let self.saved_settings['virtualedit'] = &virtualedit
let self.saved_settings['cursorline'] = &cursorline
let self.saved_settings['lazyredraw'] = &lazyredraw
let self.saved_settings['paste'] = &paste
let &virtualedit = "onemore" let &virtualedit = "onemore"
let &cursorline = 0 let &cursorline = 0
let &lazyredraw = 1 let &lazyredraw = 1
let &paste = 0
" We could have already saved the view from multiple_cursors#find " We could have already saved the view from multiple_cursors#find
if !self.start_from_find if !self.start_from_find
let self.saved_winview = winsaveview() let self.saved_winview = winsaveview()
@ -529,6 +539,7 @@ function! s:CursorManager.restore_user_settings() dict
let &virtualedit = self.saved_settings['virtualedit'] let &virtualedit = self.saved_settings['virtualedit']
let &cursorline = self.saved_settings['cursorline'] let &cursorline = self.saved_settings['cursorline']
let &lazyredraw = self.saved_settings['lazyredraw'] let &lazyredraw = self.saved_settings['lazyredraw']
let &paste = self.saved_settings['paste']
endif endif
endfunction endfunction
@ -742,7 +753,7 @@ function! s:feedkeys(keys)
endfunction endfunction
" Take the user input and apply it at every cursor " Take the user input and apply it at every cursor
function! s:process_user_inut() function! s:process_user_input()
" Grr this is frustrating. In Insert mode, between the feedkey call and here, " Grr this is frustrating. In Insert mode, between the feedkey call and here,
" the current position could actually CHANGE for some odd reason. Forcing a " the current position could actually CHANGE for some odd reason. Forcing a
" position reset here " position reset here
@ -876,7 +887,7 @@ function! s:exit()
let exit = 1 let exit = 1
endif endif
if exit if exit
call s:cm.reset(1) call s:cm.reset(1, 1)
return 1 return 1
endif endif
return 0 return 0
@ -923,7 +934,7 @@ function! s:revert_highlight_fix()
if type(s:saved_line) == 1 if type(s:saved_line) == 1
if s:from_mode ==# 'i' if s:from_mode ==# 'i'
silent! undojoin | call setline('.', s:saved_line) silent! undojoin | call setline('.', s:saved_line)
else else
call setline('.', s:saved_line) call setline('.', s:saved_line)
endif endif
endif endif
@ -961,7 +972,7 @@ function! s:end_latency_measure()
silent! echom "Starting latency debug at ".reltimestr(reltime()) silent! echom "Starting latency debug at ".reltimestr(reltime())
redir END redir END
endif endif
if !s:skip_latency_measure if !s:skip_latency_measure
exec 'redir >> '.s:latency_debug_file exec 'redir >> '.s:latency_debug_file
silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode
@ -1000,7 +1011,7 @@ function! s:wait_for_user_input(mode)
if s:exit() if s:exit()
return return
endif endif
" If the key is a special key and we're in the right mode, handle it " If the key is a special key and we're in the right mode, handle it
if index(get(s:special_keys, s:from_mode, []), s:char) != -1 if index(get(s:special_keys, s:from_mode, []), s:char) != -1
call s:handle_special_key(s:char, s:from_mode) call s:handle_special_key(s:char, s:from_mode)

View file

@ -160,7 +160,6 @@ like the following in your vimrc: >
cursors is lost. This is a implementation decision to keep the input cursors is lost. This is a implementation decision to keep the input
perfectly synced in all locations, at the cost of potentially losing user perfectly synced in all locations, at the cost of potentially losing user
input. input.
- Performance in terminal vim degrades significantly with more cursors
- Select mode is not implemented - Select mode is not implemented
============================================================================== ==============================================================================

View file

@ -270,4 +270,19 @@ describe "Multiple Cursors" do
hello world hello world
EOF EOF
end end
specify "#set paste mode" do
before <<-EOF
hello
hello
EOF
type ':set paste<CR><C-n><C-n>cworld<Esc>:set nopaste<CR>'
after <<-EOF
world
world
EOF
end
end end

View file

@ -77,11 +77,10 @@ fun! snipMate#expandSnip(snip, col)
endif endif
endif endif
call setline(lnum, line.snipLines[0]) " Insert snippet with proper indentation
let indent = indent(lnum) + 1
" Autoindent snippet according to previous indentation call setline(lnum, line . snipLines[0])
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1 call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val"))
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
" Open any folds snippet expands into " Open any folds snippet expands into
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
@ -391,7 +390,8 @@ endf
" if triggername is not set 'default' is assumed " if triggername is not set 'default' is assumed
fun! snipMate#ReadSnippetsFile(file) fun! snipMate#ReadSnippetsFile(file)
let result = [] let result = []
if !filereadable(a:file) | return result | endif let new_scopes = []
if !filereadable(a:file) | return [result, new_scopes] | endif
let r_guard = '^guard\s\+\zs.*' let r_guard = '^guard\s\+\zs.*'
let inSnip = 0 let inSnip = 0
let guard = 1 let guard = 1
@ -421,9 +421,12 @@ fun! snipMate#ReadSnippetsFile(file)
let trigger = strpart(trigger, 0, space - 1) let trigger = strpart(trigger, 0, space - 1)
endif endif
let content = '' let content = ''
elseif line[:6] == 'extends'
call extend(new_scopes, map(split(strpart(line, 8)),
\ "substitute(v:val, ',*$', '', '')"))
endif endif
endfor endfor
return result return [result, new_scopes]
endf endf
" adds scope aliases to list. " adds scope aliases to list.
@ -448,7 +451,14 @@ fun! s:AddScopeAliases(list)
endf endf
function! s:Glob(path, expr) function! s:Glob(path, expr)
return filter(split(globpath(a:path, a:expr), "\n"), 'filereadable(v:val)') let res = []
for p in split(a:path, ',')
let h = fnamemodify(a:expr, ':h')
if isdirectory(p . '/' . h)
call extend(res, split(glob(p . '/' . a:expr), "\n"))
endif
endfor
return filter(res, 'filereadable(v:val)')
endfunction endfunction
" returns dict of " returns dict of
@ -467,7 +477,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
let paths = join(funcref#Call(s:c.snippet_dirs), ',') let paths = join(funcref#Call(s:c.snippet_dirs), ',')
let result = {} let result = {}
let scopes = s:AddScopeAliases(a:scopes) let scopes = s:AddScopeAliases(a:scopes)
let trigger = escape(a:trigger, '{}*[]`') let trigger = escape(a:trigger, "*[]?{}`'$")
" collect existing files " collect existing files
for scope in scopes for scope in scopes
@ -490,7 +500,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
if !a:mustExist if !a:mustExist
for p in split(paths, ',') for p in split(paths, ',')
let p .= '/' . scope . '.snippets' let p .= '/snippets/' . scope . '.snippets'
let result[p] = get(result, p, {'exists': 0, 'type': 'snippets'}) let result[p] = get(result, p, {'exists': 0, 'type': 'snippets'})
endfor endfor
endif endif
@ -514,21 +524,27 @@ endf
" default triggers based on paths " default triggers based on paths
fun! snipMate#DefaultPool(scopes, trigger, result) fun! snipMate#DefaultPool(scopes, trigger, result)
let triggerR = substitute(a:trigger,'*','.*','g') let triggerR = substitute(a:trigger,'*','.*','g')
let extra_scopes = []
for [f,opts] in items(snipMate#GetSnippetFiles(1, a:scopes, a:trigger)) for [f,opts] in items(snipMate#GetSnippetFiles(1, a:scopes, a:trigger))
let opts.name_prefix = matchstr(f, '\v[^/]+\ze/snippets') . ' ' . opts.name_prefix let opts.name_prefix = matchstr(f, '\v[^/]+\ze/snippets') . ' ' . opts.name_prefix
if opts.type == 'snippets' if opts.type == 'snippets'
for [trigger, name, contents, guard] in cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0) let [snippets, extension] = cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
for [trigger, name, contents, guard] in snippets
if trigger !~ escape(triggerR,'~') | continue | endif if trigger !~ escape(triggerR,'~') | continue | endif
if snipMate#EvalGuard(guard) if snipMate#EvalGuard(guard)
call snipMate#SetByPath(a:result, [trigger, opts.name_prefix.' '.name], contents) call snipMate#SetByPath(a:result, [trigger, opts.name_prefix.' '.name], contents)
endif endif
endfor endfor
call extend(extra_scopes, extension)
elseif opts.type == 'snippet' elseif opts.type == 'snippet'
call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], funcref#Function('return readfile('.string(f).')')) call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], funcref#Function('return readfile('.string(f).')'))
else else
throw "unexpected" throw "unexpected"
endif endif
endfor endfor
if !empty(extra_scopes)
call snipMate#DefaultPool(extra_scopes, a:trigger, a:result)
endif
endf endf
" return a dict of snippets found in runtimepath matching trigger " return a dict of snippets found in runtimepath matching trigger

View file

@ -1,7 +1,6 @@
*snipMate.txt* Plugin for using TextMate-style snippets in Vim. *snipMate.txt* Plugin for using TextMate-style snippets in Vim.
snipMate *snippet* *snippets* *snipMate* snipMate *snippet* *snippets* *snipMate*
Last Change: December 27, 2009
|snipMate-installation| Installation |snipMate-installation| Installation
|snipMate-description| Description |snipMate-description| Description
@ -306,6 +305,15 @@ TextMates's functionality, use the |system()| function. E.g.: >
will insert the current date, assuming you are on a Unix system. Note that you will insert the current date, assuming you are on a Unix system. Note that you
can also (and should) use |strftime()| for this example. can also (and should) use |strftime()| for this example.
*snipMate-extends*
Borrowing from UltiSnips, .snippets files can also contain an extends
directive, for example: >
extends html, javascript, css
will tell SnipMate to also read html, javascript, and css snippets.
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()* Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
Since the current filename is used often in snippets, a default function Since the current filename is used often in snippets, a default function
@ -420,6 +428,15 @@ Perhaps some of these features will be added in a later release.
============================================================================== ==============================================================================
CHANGELOG *snipMate-changelog* CHANGELOG *snipMate-changelog*
0.86 - 2013-06-15
-----------------
* Use more idiomatic <Plug> maps
* Fix disappearing variables bug (hpesoj)
* Fix cursor position bug when a variable is on the same line as the stop
* Fix undo point creation causing problems with Supertab
* Fix bug where SnipMate would use a typed trigger as a regular expression
0.85 - 2013-04-03 0.85 - 2013-04-03
----------------- -----------------

View file

@ -1,6 +1,6 @@
" File: snipMate.vim " File: snipMate.vim
" Author: Michael Sanders " Author: Michael Sanders
" Version: 0.85 " Version: 0.86
" Description: snipMate.vim implements some of TextMate's snippets features in " Description: snipMate.vim implements some of TextMate's snippets features in
" Vim. A snippet is a piece of often-typed text that you can " Vim. A snippet is a piece of often-typed text that you can
" insert into your document using a trigger word followed by a "<tab>". " insert into your document using a trigger word followed by a "<tab>".
@ -56,30 +56,15 @@ let s:snipMate['get_snippets'] = get(s:snipMate, 'get_snippets', funcref#Functio
" snippets. You can replace it with your own implementation. Defaults to all " snippets. You can replace it with your own implementation. Defaults to all
" directories in &rtp/snippets/* " directories in &rtp/snippets/*
let s:snipMate['snippet_dirs'] = get(s:snipMate, 'snippet_dirs', funcref#Function('return split(&runtimepath,",")')) let s:snipMate['snippet_dirs'] = get(s:snipMate, 'snippet_dirs', funcref#Function('return split(&runtimepath,",")'))
if type(s:snipMate['snippet_dirs']) == type([])
call map(s:snipMate['snippet_dirs'], 'expand(v:val)')
endif
" _ is default scope added always " _ is default scope added always
" "
" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO " &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO
let s:snipMate['get_scopes'] = get(s:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]')) let s:snipMate['get_scopes'] = get(s:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]'))
if !exists('snippets_dir')
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
endif
" Processes a single-snippet file; optionally add the name of the parent
" directory for a snippet with multiple matches.
fun! s:ProcessFile(file, ft, ...)
let keyword = fnamemodify(a:file, ':t:r')
if keyword == '' | return | endif
try
let text = join(readfile(a:file), "\n")
catch /E484/
echom "Error in snipMate.vim: couldn't read file: ".a:file
endtry
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
\ : MakeSnip(a:ft, keyword, text)
endf
" dummy for compatibility - will be removed " dummy for compatibility - will be removed
" moving to autoload to improve loading speed and debugging " moving to autoload to improve loading speed and debugging
fun! TriggerSnippet() fun! TriggerSnippet()

View file

@ -6,10 +6,11 @@ syn match tabStop '\$\d\+'
syn match snipEscape '\\\\\|\\`' syn match snipEscape '\\\\\|\\`'
syn match snipCommand '\%(\\\@<!\%(\\\\\)*\)\@<=`.\{-}\%(\\\@<!\%(\\\\\)*\)\@<=`' syn match snipCommand '\%(\\\@<!\%(\\\\\)*\)\@<=`.\{-}\%(\\\@<!\%(\\\\\)*\)\@<=`'
syn match snippet '^snippet.*' contains=multiSnipText,snipKeyword syn match snippet '^snippet.*' contains=multiSnipText,snipKeyword
syn match snippet '^extends.*' contains=snipKeyword
syn match snippet '^guard\s\+.*' contains=multiSnipText,snipKeyword syn match snippet '^guard\s\+.*' contains=multiSnipText,snipKeyword
syn match multiSnipText '\S\+ \zs.*' contained syn match multiSnipText '\S\+ \zs.*' contained
syn match snipKeyword '^snippet'me=s+8 contained syn match snipKeyword '^(snippet|extends)'me=s+8 contained
syn match snipError "^[^#s\t].*$" syn match snipError "^[^#se\t].*$"
hi link snippet Identifier hi link snippet Identifier
hi link snipComment Comment hi link snipComment Comment

View file

@ -10,6 +10,7 @@ Elliot Murphy
Eustaquio Rangel Eustaquio Rangel
Henrik Nyh Henrik Nyh
Honza Pokorny Honza Pokorny
Iuri Fernandes Queiroz
Jakub Nawalaniec Jakub Nawalaniec
James F. Herdman James F. Herdman
Jon Bernard Jon Bernard
@ -38,6 +39,7 @@ Dmitry Dementev
Travis Holton Travis Holton
Chrisyue Chrisyue
Erik Westrup Erik Westrup
Matt Deacalion Stevens
TODO: add contributors from github.com/SirVer/Ultisnip having contributed to TODO: add contributors from github.com/SirVer/Ultisnip having contributed to
github.com/SirVer/Ultisnip/UltiSnips/* files github.com/SirVer/Ultisnip/UltiSnips/* files

View file

@ -50,6 +50,49 @@ of the snippets by setting the "always_use_first_snippet" option to 1.
If you have VimL only (vim without python support) your best option is using If you have VimL only (vim without python support) your best option is using
garbas/vim-snipmate and cope with the minor bugs found in the engine. garbas/vim-snipmate and cope with the minor bugs found in the engine.
Policies / for contributors
===========================
Some snippets are useful for almost all languages, so let's try to have the same
triggers for them:
```
if : if without else
ife: if $1 else $2
eif : else if ($1) { .. }
el : else ..
```
If you're not satisfied with these defaults, open a ticket that we implement
aliasing. Then you can remap "else" to "el" or the like.
Don't add stupid placeholder default texts like
```
if (${1:condition}){
${2:some code here}
}
```
instead use:
```
if (${1}){
${2}
}
```
Exception: Functions which are used less often, such as Vim's matchall(), matchstr()
functions which case hints may be helpful to remember order. In the VimL case
get vim-dev plugin which has function completion
Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
Open questions:
What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ?
What about wh(ile), which trigger?
Discuss at: https://github.com/honza/vim-snippets/issues/230
Related repositories Related repositories
==================== ====================
We also encourage people to maintain sets of snippets for particular use cases We also encourage people to maintain sets of snippets for particular use cases
@ -63,10 +106,11 @@ so that all users can benefit from them. People can list their snippet reposito
Installation using VAM: "github:rbonvall/snipmate-snippets-bib" Installation using VAM: "github:rbonvall/snipmate-snippets-bib"
## If you believe in the success of vim-snipmate Future - ideas - examples
then you may also want to have a look at [vim-git-wiki](http://github.com/MarcWeber/vim-git-wiki). =========================
If you contribute to this git based wiki editable by Vim we have a chance [overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html)
of making it official at www.vim.org. If you have ideas you can add them to that list of "snippet engine features by example".
Historical notes Historical notes
================ ================
@ -86,19 +130,23 @@ add snippets/ruby-1.9.snippets (1.9 only)
then configure github.com/garbas/vim-snipmate this way: then configure github.com/garbas/vim-snipmate this way:
let g:snipMate = {}
let g:snipMate.scope_aliases = {} ```vim
let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9' let g:snipMate = {}
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'
```
or github.com/MarcWeber/UltiSnips this way: or github.com/MarcWeber/UltiSnips this way:
let g:UltiSnips = {} ```vim
let g:UltiSnips = {}
let g:UltiSnips.snipmate_ft_filter = {
\ 'default' : {'filetypes': ["FILETYPE"] },
\ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] },
let g:UltiSnips.snipmate_ft_filter = {
\ 'default' : {'filetypes': ["FILETYPE"] },
\ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] },
```
If it happens that you work on a project requiring ruby-1.8 snippets instead, If it happens that you work on a project requiring ruby-1.8 snippets instead,
consider using vim-addon-local-vimrc and override the filetypes. consider using vim-addon-local-vimrc and override the filetypes.
@ -129,6 +177,8 @@ vim-snippets is not like the "linux kernel".
* Ruby - [taq](http://github.com/taq) * Ruby - [taq](http://github.com/taq)
* PHP - [chrisyue](http://github.com/chrisyue) * PHP - [chrisyue](http://github.com/chrisyue)
* Scala - [gorodinskiy](https://github.com/gorodinskiy) * Scala - [gorodinskiy](https://github.com/gorodinskiy)
* Falcon - [steveno](https://github.com/steveno)
* Elixir - [iurifq](https://github.com/iurifq)
Contributing notes Contributing notes
------------------ ------------------

View file

@ -1,75 +1,83 @@
# From the TextMate bundle # From the TextMate bundle
# with some modification
snippet fun "Function" b snippet fun "Function" b
${1:name} = (${2:args}) -> ${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`->
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet bfun "Function (bound)" b snippet bfun "Function (bound)" i
${1:(${2:args}) }=> `!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr}
${0:# body...}
endsnippet endsnippet
snippet if "If" b snippet if "If"
if ${1:condition} if ${1:condition}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet ife "If .. Else" b snippet ife "If .. Else"
if ${1:condition} if ${1:condition}
${2:# body...} ${2:# body...}
else else
${3:# body...} ${3:# body...}
endsnippet endsnippet
snippet elif "Else if" b snippet eif "Else if" b
else if ${1:condition} else if ${1:condition}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet ifte "Ternary if" b snippet ifte "Ternary if"
if ${1:condition} then ${2:value} else ${3:other} if ${1:condition} then ${2:value} else ${3:other}
endsnippet endsnippet
snippet unl "Unless" b snippet unl "Unless"
${1:action} unless ${2:condition} ${1:action} unless ${2:condition}
endsnippet endsnippet
snippet fora "Array Comprehension" b snippet fora "Array Comprehension"
for ${1:name} in ${2:array} for ${1:name} in ${2:array}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet foro "Object Comprehension" b snippet foro "Object Comprehension"
for ${1:key}, ${2:value} of ${3:Object} for ${1:key}, ${2:value} of ${3:Object}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet forr "Range Comprehension (inclusive)" b snippet forr "Range Comprehension (inclusive)"
for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}} for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet forrex "Range Comprehension (exclusive)" b snippet forrex "Range Comprehension (exclusive)"
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}} for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...} ${0:# body...}
endsnippet endsnippet
snippet swi "Switch" b snippet swi "Switch"
switch ${1:object} switch ${1:object}
when ${2:value} when ${2:value}
${0:# body...} ${3:# body...}
else
$0
endsnippet
snippet swit "Switch when .. then"
switch ${1:object}
when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value}
else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value}
endsnippet endsnippet
snippet cla "Class" b snippet cla "Class" b
class ${1:ClassName}${2: extends ${3:Ancestor}} class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor}
${4:constructor: (${5:args}) -> ${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` ->
${6:# body...}} ${5:# body...}}
$7 $0
endsnippet endsnippet
snippet try "Try .. Catch" b snippet try "Try .. Catch"
try try
$1 $1
catch ${2:error} catch ${2:error}
@ -80,7 +88,7 @@ snippet req "Require" b
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'}) ${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
endsnippet endsnippet
snippet # "Interpolated Code" snippet # "Interpolated Code" i
#{$1}$0 #{$1}$0
endsnippet endsnippet

View file

@ -126,7 +126,7 @@ else
} }
endsnippet endsnippet
snippet elif "else if (elif)" b snippet eif "else if (elif)" b
else if(${1:/*condition*/}) else if(${1:/*condition*/})
{ {
${VISUAL}${0:/*code*/} ${VISUAL}${0:/*code*/}
@ -576,7 +576,7 @@ snippet module "New module (module)" b
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
module ${2}.`!v Filename('$1', 'name')`; module ${2}.`!v vim_snippets#Filename('$1', 'name')`;
${3} ${3}

View file

@ -76,7 +76,7 @@ snippet if
{% endif %} {% endif %}
endsnippet endsnippet
snippet else snippet el
{% else %} {% else %}
${1} ${1}
endsnippet endsnippet

View file

@ -263,7 +263,7 @@ snippet st "submit_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet endsnippet
snippet else "else (ERB)" snippet el "else (ERB)"
<% else %> <% else %>
endsnippet endsnippet

View file

@ -1,13 +1,13 @@
snippet if "if ... then ... else ..." snippet ife "if ... then ... else ..."
if ${1:condition} if ${1:condition}
then ${2:expression} then ${2:expression}
else ${3:expression} else ${3:expression}
endsnippet endsnippet
snippet case "case ... of ..." snippet case "case ... of ..."
case ${1:expression} of case ${1} of
${2:pattern} -> ${3:expression} ${2} -> ${3}
${4:pattern} -> ${5:expression} ${4} -> ${5}
endsnippet endsnippet
snippet :: "Type signature" snippet :: "Type signature"

View file

@ -0,0 +1,31 @@
# more can be found in snippets/html_minimal.snippets
# these UltiSnips override snippets because nested placeholders are being used
snippet id
id="${1}"${2}
endsnippet
snippet idn
id="${1}" name="${2:$1}"
endsnippet
snippet label_and_input
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="${7}" />${8}
endsnippet
snippet input
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}}/>${7}
endsnippet
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
endsnippet
snippet textarea
<textarea name="$2"${3: id="$4"}>$5</textarea>
endsnippet
snippet img
<img src="$1"${2: alt="$3"}/>
endsnippet

View file

@ -59,7 +59,7 @@ default:
$0 $0
endsnippet endsnippet
snippet elif "else if" b snippet eif "else if" b
else if ($1)`!p nl(snip)`{ else if ($1)`!p nl(snip)`{
$0 $0
} }

View file

@ -50,12 +50,19 @@ function ${1:function_name} (${2:argument}) {
} }
endsnippet endsnippet
# for one line if .. else you usually use a ? b : c
snippet ife "if ___ else" snippet ife "if ___ else"
if (${1:true}) {$0} else{}; if (${1}) {
{$2}
} else {
{$3}
};
endsnippet endsnippet
snippet if "if" snippet if "if"
if (${1:true}) {$0}; if (${1}) {
{$2}
};
endsnippet endsnippet
snippet timeout "setTimeout function" snippet timeout "setTimeout function"

View file

@ -4,17 +4,17 @@ endsnippet
snippet open "open" snippet open "open"
let open ${1:module} in let open ${1:module} in
${2:e} ${2}
endsnippet endsnippet
snippet try "try" snippet try "try"
try ${1:e} try ${1}
with ${2:Not_found} -> ${3:()} with ${2:Not_found} -> ${3:()}
endsnippet endsnippet
snippet ref "ref" snippet ref "ref"
let ${1:name} = ref ${2:val} in let ${1} = ref ${2} in
${3:e} ${3}
endsnippet endsnippet
snippet matchl "pattern match on a list" snippet matchl "pattern match on a list"
@ -24,88 +24,83 @@ match ${1:list} with
endsnippet endsnippet
snippet matcho "pattern match on an option type" snippet matcho "pattern match on an option type"
match ${1:x} with match ${1} with
| Some(${2:y}) -> ${3:()} | Some(${2}) -> ${3:()}
| None -> ${4:()} | None -> ${4:()}
endsnippet endsnippet
snippet fun "anonymous function" snippet fun "anonymous function"
(fun ${1:x} -> ${2:x}) (fun ${1} -> ${2})
endsnippet endsnippet
snippet cc "commment" snippet cc "commment"
(* ${1:comment} *) (* ${1} *)
endsnippet endsnippet
snippet let "let .. in binding" snippet let "let .. in binding"
let ${1:x} = ${2:v} in let ${1} = ${2} in
${3:e} ${3}
endsnippet endsnippet
snippet lr "let rec" snippet lr "let rec"
let rec ${1:f} = let rec ${1} =
${2:expr} ${2}
endsnippet endsnippet
snippet if "if" snippet ife "if"
if ${1:(* condition *)} then if ${1} then
${2:(* A *)} ${2}
else else
${3:(* B *)} ${3}
endsnippet endsnippet
snippet If "If" snippet if "If"
if ${1:(* condition *)} then if ${1} then
${2:(* A *)} ${2}
endsnippet endsnippet
snippet while "while" snippet while "while"
while ${1:(* condition *)} do while ${1} do
${2:(* A *)} ${2}
done done
endsnippet endsnippet
snippet for "for" snippet for "for"
for ${1:i} = ${2:1} to ${3:10} do for ${1:i} = ${2:1} to ${3:10} do
${4:(* BODY *)} ${4}
done done
endsnippet endsnippet
snippet match "match" snippet match "match"
match ${1:(* e1 *)} with match ${1} with
| ${2:p} -> ${3:e2} | ${2} -> ${3}
endsnippet
snippet Match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet endsnippet
snippet class "class" snippet class "class"
class ${1:name} = object class ${1:name} = object
${2:methods} ${2}
end end
endsnippet endsnippet
snippet obj "obj" snippet obj "obj"
object object
${2:methods} ${2}
end end
endsnippet endsnippet
snippet Obj "object" snippet Obj "object"
object (self) object (self)
${2:methods} ${2}
end end
endsnippet endsnippet
snippet {{ "object functional update" snippet {{ "object functional update"
{< ${1:x} = ${2:y} >} {< ${1} = ${2} >}
endsnippet endsnippet
snippet beg "beg" snippet beg "beg"
begin begin
${1:block} ${1}${VISUAL}
end end
endsnippet endsnippet
@ -115,19 +110,19 @@ endsnippet
snippet mod "module - no signature" snippet mod "module - no signature"
module ${1:(* Name *)} = struct module ${1:(* Name *)} = struct
${2:(* BODY *)} ${2}
end end
endsnippet endsnippet
snippet Mod "module with signature" snippet Mod "module with signature"
module ${1:(* Name *)} : ${2:(* SIG *)} = struct module ${1:(* Name *)} : ${2:(* SIG *)} = struct
${3:(* BODY *)} ${3}
end end
endsnippet endsnippet
snippet sig "anonymous signature" snippet sig "anonymous signature"
sig sig
${2:(* BODY *)} ${2}
end end
endsnippet endsnippet
@ -137,32 +132,32 @@ endsnippet
snippet func "define functor - no signature" snippet func "define functor - no signature"
module ${1:M} (${2:Arg} : ${3:ARG}) = struct module ${1:M} (${2:Arg} : ${3:ARG}) = struct
${4:(* BODY *)} ${4}
end end
endsnippet endsnippet
snippet Func "define functor - with signature" snippet Func "define functor - with signature"
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
${5:(* BODY *)} ${5}
end end
endsnippet endsnippet
snippet mot "Declare module signature" snippet mot "Declare module signature"
module type ${1:(* Name *)} = sig module type ${1:(* Name *)} = sig
${2:(* BODY *)} ${2}
end end
endsnippet endsnippet
snippet module "Module with anonymous signature" snippet module "Module with anonymous signature"
module ${1:(* Name *)} : sig module ${1:(* Name *)} : sig
${2:(* SIGNATURE *)} ${2}
end = struct end = struct
${3:(* BODY *)} ${3}
end end
endsnippet endsnippet
snippet oo "odoc" snippet oo "odoc"
(** ${1:odoc} *) (** ${1} *)
endsnippet endsnippet
snippet qt "inline qtest" snippet qt "inline qtest"

View file

@ -11,8 +11,8 @@ endsnippet
snippet do "do" snippet do "do"
do { do {
${2:// code... } ${2}
} while (${1:/* condition */});" } while (${1});"
endsnippet endsnippet
snippet doc_f "doc_f" snippet doc_f "doc_f"
@ -37,21 +37,21 @@ interface ${1:someClass}
} // END interface $1" } // END interface $1"
endsnippet endsnippet
snippet else "else" snippet el "else"
else { else {
${1:// code...} ${1}
} }
endsnippet endsnippet
snippet for "for" snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...} ${4}
} }
endsnippet endsnippet
snippet foreachk "foreachk" snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){ foreach ($${1:variable} as $${2:key} => $${3:value}){
${4:// code...} ${4}
} }
endsnippet endsnippet
@ -60,8 +60,8 @@ $_GET['${1}']${2}
endsnippet endsnippet
snippet if "if" snippet if "if"
if (${1:/* condition */}) { if (${1}) {
${2:// code...} ${2}
} }
endsnippet endsnippet
@ -210,9 +210,9 @@ endsnippet
snippet ife "if else" snippet ife "if else"
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:// code...} ${2}
} else { } else {
${3:// code...} ${3}
} }
$0 $0
endsnippet endsnippet
@ -227,7 +227,7 @@ class $1
{ {
public function ${3:__construct}(${4:$options}) public function ${3:__construct}(${4:$options})
{ {
${4:// code} ${4}
} }
} }
$0 $0

View file

@ -1,61 +1,314 @@
# -*- coding: utf-8 -*-
########################################################################### ###########################################################################
# General Stuff # # General Stuff #
########################################################################### ###########################################################################
global !p
import vim
from os import path as ospath
from string import Template
import re
from collections import Counter
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
"error", "hint", "important", "note",
"tip", "warning"]
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights',
'pull-quote','compound','container',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
'footer', 'date', 'include', 'title']
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
# CJK chars
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def real_filename(filename):
"""peal extension name off if possible
# i.e. "foo.bar.png will return "foo.bar"
"""
return ospath.splitext(filename)[0]
def check_file_exist(rst_path, relative_path):
"""
For RST file, it can just include files as relative path.
:param rst_path: absolute path to rst file
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
make lines with leading char multitimes
:param: times, how many times you need
:param: leading, leading character
"""
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
return ("%s Item\n" % leading) * times
def look_up_directives(regex, fpath):
"""
find all directive args in given file
:param: regex, the regex that needs to match
:param: path, to path to rst file
:return: list, empty list if nothing match
"""
try:
with open(fpath) as source:
match = re.findall(regex, source.read())
except IOError:
match = []
return match
def get_popular_code_type():
"""
find most popular code type in the given rst
:param path: file to detect
:return: string, most popular code type in file
"""
buf = "".join(vim.current.buffer)
types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf)
try:
popular_type = Counter(types).most_common()[0][0]
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
def complete(t, opts):
"""
get options that start with t
:param t: query string
:param opts: list that needs to be completed
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
endglobal
snippet part "Part" b snippet part "Part" b
`!p snip.rv = len(t[1])*'#'` `!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name} ${1:Part name}
`!p snip.rv = len(t[1])*'#'` `!p snip.rv = rst_char_len(t[1])*'#'`
$0 $0
endsnippet endsnippet
snippet sec "Section" b snippet sec "Section" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'='` `!p snip.rv = rst_char_len(t[1])*'='`
$0 $0
endsnippet endsnippet
snippet ssec "Subsection" b snippet ssec "Subsection" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'-'` `!p snip.rv = rst_char_len(t[1])*'-'`
$0 $0
endsnippet endsnippet
snippet sssec "Subsubsection" b snippet sssec "Subsubsection" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'^'` `!p snip.rv = rst_char_len(t[1])*'^'`
$0 $0
endsnippet endsnippet
snippet chap "Chapter" b snippet chap "Chapter" b
`!p snip.rv = len(t[1])*'*'` `!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name} ${1:Chapter name}
`!p snip.rv = len(t[1])*'*'` `!p snip.rv = rst_char_len(t[1])*'*'`
$0 $0
endsnippet endsnippet
snippet para "Paragraph" b snippet para "Paragraph" b
${1:Paragraph name} ${1:Paragraph name}
`!p snip.rv = len(t[1])*'"'` `!p snip.rv = rst_char_len(t[1])*'"'`
$0 $0
endsnippet endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet st "Strong string" i
`!p
if has_cjk(vim.current.line):
snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet "li(st)? (?P<num>\d+)" "List" br
$0
`!p
# usage: li 4<tab>
# which will extand into a unordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'])
`
endsnippet
snippet "ol(st)? (?P<num>\d+)" "Order List" br
$0
`!p
# usage: ol 4<tab>
# which will extand into a ordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'], 1)
`
endsnippet
########################################################################### ###########################################################################
# More Specialized Stuff. # # More Specialized Stuff. #
########################################################################### ###########################################################################
snippet cb "Code Block" b snippet cb "Code Block" b
.. code-block:: ${1:lua} .. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code} ${2:code}
$0 $0
endsnippet endsnippet
# match snippets :
# img, inc, fig
snippet id "Includable Directives" b
`!p
real_name=real_filename(ospath.basename(t[2]))
di=t[1][:2]
link=""
content=""
if di == 'im':
link = "|{0}|".format(real_name)
if di == 'fi':
content="""
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
if not check_file_exist(path, t[2]):
snip.rv='.. FILE {0} does not exist'.format(t[2])
else:
snip.rv=""
`$0
endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
$0
endsnippet
snippet nd "None Content Directives" b
.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2
$0
endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
$0
endsnippet
#it will be trigger at start of line or after a word
snippet ro "Text Roles" w
\ :$1`!p snip.rv=complete(t[1],
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
endsnippet
############
# Sphinx #
############
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -25,7 +25,7 @@ endsnippet
snippet if "if <condition> ... end" snippet if "if <condition> ... end"
if ${1:condition} if ${1:condition}
${2:# TODO} ${2}
end end
endsnippet endsnippet
@ -33,9 +33,9 @@ endsnippet
snippet ife "if <condition> ... else ... end" snippet ife "if <condition> ... else ... end"
if ${1:condition} if ${1:condition}
${2:# TODO} ${2}
else else
${3:# TODO} ${3}
end end
endsnippet endsnippet
@ -43,11 +43,11 @@ endsnippet
snippet ifee "if <condition> ... elseif <condition> ... else ... end" snippet ifee "if <condition> ... elseif <condition> ... else ... end"
if ${1:condition} if ${1:condition}
${2:# TODO} ${2}
elsif ${3:condition} elsif ${3:condition}
${4:# TODO} ${4}
else else
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -55,7 +55,7 @@ endsnippet
snippet unless "unless <condition> ... end" snippet unless "unless <condition> ... end"
unless ${1:condition} unless ${1:condition}
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -63,9 +63,9 @@ endsnippet
snippet unlesse "unless <condition> ... else ... end" snippet unlesse "unless <condition> ... else ... end"
unless ${1:condition} unless ${1:condition}
${2:# TODO} ${2}
else else
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -73,11 +73,11 @@ endsnippet
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end" snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
unless ${1:condition} unless ${1:condition}
${2:# TODO} ${2}
elsif ${3:condition} elsif ${3:condition}
${4:# TODO} ${4}
else else
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -85,7 +85,7 @@ endsnippet
snippet "\b(de)?f" "def <name>..." r snippet "\b(de)?f" "def <name>..." r
def ${1:function_name}${2: ${3:*args}} def ${1:function_name}${2: ${3:*args}}
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -93,7 +93,7 @@ endsnippet
snippet defi "def initialize ..." snippet defi "def initialize ..."
def initialize${1: ${2:*args}} def initialize${1: ${2:*args}}
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -101,23 +101,23 @@ endsnippet
snippet defr "def <name> ... rescue ..." snippet defr "def <name> ... rescue ..."
def ${1:function_name}${2: ${3:*args}} def ${1:function_name}${2: ${3:*args}}
${4:# TODO} ${4}
rescue rescue
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }" snippet For "(<from>..<to>).each { |<i>| <block> }"
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} } (${1:from}..${2:to}).each { |${3:i}| ${4} }
endsnippet endsnippet
snippet for "(<from>..<to>).each do |<i>| <block> end" snippet for "(<from>..<to>).each do |<i>| <block> end"
(${1:from}..${2:to}).each do |${3:i}| (${1:from}..${2:to}).each do |${3:i}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -138,42 +138,42 @@ endsnippet
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} } `!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} }
endsnippet endsnippet
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}| `!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} } `!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} }
endsnippet endsnippet
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| `!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} } `!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} }
endsnippet endsnippet
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| `!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -194,56 +194,56 @@ endsnippet
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} } `!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} }
endsnippet endsnippet
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| `!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} } `!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} }
endsnippet endsnippet
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
`!p snip.rv=match.group(1)`.each_key do |${1:key}| `!p snip.rv=match.group(1)`.each_key do |${1:key}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} } `!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} }
endsnippet endsnippet
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_value do |${1:value}| `!p snip.rv=match.group(1)`.each_value do |${1:value}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet Each "<elements>.each { |<element>| <block> }" snippet Each "<elements>.each { |<element>| <block> }"
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} } ${1:elements}.each { |${2:${1/s$//}}| ${3} }
endsnippet endsnippet
snippet each "<elements>.each do |<element>| <block> end" snippet each "<elements>.each do |<element>| <block> end"
${1:elements}.each do |${2:${1/s$//}}| ${1:elements}.each do |${2:${1/s$//}}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -251,14 +251,14 @@ endsnippet
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end" snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
each_slice(${1:2}) do |${2:slice}| each_slice(${1:2}) do |${2:slice}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }" snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
each_slice(${1:2}) { |${2:slice}| ${3:# TODO} } each_slice(${1:2}) { |${2:slice}| ${3} }
endsnippet endsnippet
@ -273,7 +273,7 @@ try:
snip.rv = wmatch.group(1).lower() snip.rv = wmatch.group(1).lower()
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| ${2:# TODO} } `}| ${2} }
endsnippet endsnippet
@ -288,7 +288,7 @@ try:
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| `}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -303,7 +303,7 @@ try:
snip.rv = wmatch.group(1).lower() snip.rv = wmatch.group(1).lower()
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| ${2:# TODO} } `}| ${2} }
endsnippet endsnippet
@ -318,7 +318,7 @@ try:
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| `}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -333,7 +333,7 @@ try:
snip.rv = wmatch.group(1).lower() snip.rv = wmatch.group(1).lower()
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| ${2:# TODO} } `}| ${2} }
endsnippet endsnippet
@ -348,7 +348,7 @@ try:
except: except:
snip.rv = 'element' snip.rv = 'element'
`}| `}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -364,7 +364,7 @@ try:
snip.rv = wmatch.group(1).lower() snip.rv = wmatch.group(1).lower()
except: except:
snip.rv = 'element' snip.rv = 'element'
`},${2:i}| ${3:# TODO} }$0 `},${2:i}| ${3} }$0
endsnippet endsnippet
@ -379,7 +379,7 @@ try:
except: except:
snip.rv = 'element' snip.rv = 'element'
`},${2:i}| `},${2:i}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -387,14 +387,14 @@ endsnippet
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} } `!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} }
endsnippet endsnippet
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}| `!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -424,26 +424,24 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r
end end
endsnippet endsnippet
# comments about do and dov see snippets/ruby.snippets
snippet do "do ... end" i
snippet do "do |<key>| ... end" i
do ${1:|${2:key}|}
$0
end
endsnippet
snippet Do "do ... end" i
do do
$0 $0
end end
endsnippet endsnippet
snippet dov "do |<key>| ... end" i
do |${0:v}|
$1
end
endsnippet
snippet until "until <expression> ... end" snippet until "until <expression> ... end"
until ${1:expression} until ${1:expression}
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -451,7 +449,7 @@ endsnippet
snippet Until "begin ... end until <expression>" snippet Until "begin ... end until <expression>"
begin begin
${0:# TODO} ${0}
end until ${1:expression} end until ${1:expression}
endsnippet endsnippet
@ -459,7 +457,7 @@ endsnippet
snippet while "while <expression> ... end" snippet while "while <expression> ... end"
while ${1:expression} while ${1:expression}
${0:# TODO} ${0}
end end
endsnippet endsnippet
@ -467,7 +465,7 @@ endsnippet
snippet While "begin ... end while <expression>" snippet While "begin ... end while <expression>"
begin begin
${0:# TODO} ${0}
end while ${1:expression} end while ${1:expression}
endsnippet endsnippet
@ -493,9 +491,9 @@ endsnippet
snippet begin "begin ... rescue ... end" snippet begin "begin ... rescue ... end"
begin begin
${1:# TODO} ${1}
rescue rescue
${0:# TODO} ${0}
end end
endsnippet endsnippet

View file

@ -16,14 +16,14 @@ foreach ${1:var} ${2:\$list} {
endsnippet endsnippet
snippet if "if... (if)" b snippet if "if... (if)" b
if {${1:condition}} { if {${1}} {
${2} ${2}
} }
endsnippet endsnippet
snippet proc "proc... (proc)" b snippet proc "proc... (proc)" b
proc ${1:name} {${2:args}} \ proc ${1} {${2}} \
{ {
${3} ${3}
} }
@ -41,7 +41,7 @@ switch ${1:-exact} -- ${2:\$var} {
endsnippet endsnippet
snippet while "while... (while)" b snippet while "while... (while)" b
while {${1:condition}} { while {${1}} {
${2} ${2}
} }

View file

@ -25,30 +25,30 @@ endsnippet
snippet f snippet f
fun ${1:function_name}(${2}) fun ${1:function_name}(${2})
${3:" code} ${3}
endf endf
endsnippet endsnippet
snippet for snippet for
for ${1:needle} in ${2:haystack} for ${1} in ${2}
${3:" code} ${3}
endfor endfor
endsnippet endsnippet
snippet wh snippet wh
while ${1:condition} while ${1}
${2:" code} ${2}
endw endw
endsnippet endsnippet
snippet if snippet if
if ${1:condition} if ${1}
${2:" code} ${2}
endif endif
endsnippet endsnippet
snippet ife snippet ife
if ${1:condition} if ${1}
${2} ${2}
else else
${3} ${3}

View file

@ -0,0 +1,27 @@
" this is well known Filename found in snipmate (and the other engines), but
" rewritten and documented :)
"
" optional arg1: string in which to replace '$1' by filename with extension
" and path dropped. Defaults to $1
" optional arg2: return this value if buffer has no filename
" But why not use the template in this case, too?
" Doesn't make sense to me
fun! vim_snippets#Filename(...)
let template = get(a:000, 0, "$1")
let arg2 = get(a:000, 1, "")
let basename = expand('%:t:r')
if basename == ''
return arg2
else
return substitute(template, '$1', basename, 'g')
endif
endf
" original code:
" fun! Filename(...)
" let filename = expand('%:t:r')
" if filename == '' | return a:0 == 2 ? a:2 : '' | endif
" return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
" endf

View file

@ -16,17 +16,17 @@ snippet lorem
snippet GPL2 snippet GPL2
${1:One line to give the program's name and a brief description.} ${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
@ -34,17 +34,17 @@ snippet GPL2
snippet LGPL2 snippet LGPL2
${1:One line to give the program's name and a brief description.} ${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>. along with this library; if not, see <http://www.gnu.org/licenses/>.
@ -52,35 +52,35 @@ snippet LGPL2
snippet GPL3 snippet GPL3
${1:one line to give the program's name and a brief description.} ${1:one line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
${3} ${3}
snippet LGPL3 snippet LGPL3
${1:One line to give the program's name and a brief description.} ${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 3 of the License, or by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>. along with this library; if not, see <http://www.gnu.org/licenses/>.
@ -89,7 +89,7 @@ snippet BSD2
${1:one line to give the program's name and a brief description} ${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
@ -97,7 +97,7 @@ snippet BSD2
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -108,9 +108,9 @@ snippet BSD2
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing are those of the authors and should not be interpreted as representing
official policies, either expressedor implied, of $2. official policies, either expressedor implied, of $2.
@ -119,7 +119,7 @@ snippet BSD3
${1:one line to give the program's name and a brief description} ${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
@ -130,7 +130,7 @@ snippet BSD3
3. Neither the name of the ${3:organization} nor the 3. Neither the name of the ${3:organization} nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -147,7 +147,7 @@ snippet BSD4
${1:one line to give the program's name and a brief description} ${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
@ -161,7 +161,7 @@ snippet BSD4
4. Neither the name of the $3 nor the 4. Neither the name of the $3 nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -177,17 +177,17 @@ snippet BSD4
snippet MIT snippet MIT
${1:one line to give the program's name and a brief description} ${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:copyright holder} Copyright (C) `strftime("%Y")` ${2:copyright holder}
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"), a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the 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: Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software. in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@ -200,13 +200,13 @@ snippet MIT
snippet APACHE snippet APACHE
${1:one line to give the program's name and a brief description} ${1:one line to give the program's name and a brief description}
Copyright `strftime("%Y")` ${2:copyright holder} Copyright `strftime("%Y")` ${2:copyright holder}
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -214,14 +214,14 @@ snippet APACHE
limitations under the License. limitations under the License.
${3} ${3}
snippet BEERWARE snippet BEERWARE
${2:one line to give the program's name and a brief description} ${2:one line to give the program's name and a brief description}
Copyright `strftime("%Y")` ${3:copyright holder} Copyright `strftime("%Y")` ${3:copyright holder}
Licensed under the "THE BEER-WARE LICENSE" (Revision 42): Licensed under the "THE BEER-WARE LICENSE" (Revision 42):
${1:`g:snips_author`} wrote this file. As long as you retain this notice you ${1:`g:snips_author`} wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer or coffee in return this stuff is worth it, you can buy me a beer or coffee in return
${4} ${4}

View file

@ -2,22 +2,22 @@ snippet main
package { package {
import flash.display.*; import flash.display.*;
import flash.Events.*; import flash.Events.*;
public class Main extends Sprite { public class Main extends Sprite {
public function Main ( ) { public function Main ( ) {
trace("start"); trace("start");
stage.scaleMode = StageScaleMode.NO_SCALE; stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeListener); stage.addEventListener(Event.RESIZE, resizeListener);
} }
private function resizeListener (e:Event):void { private function resizeListener (e:Event):void {
trace("The application window changed size!"); trace("The application window changed size!");
trace("New width: " + stage.stageWidth); trace("New width: " + stage.stageWidth);
trace("New height: " + stage.stageHeight); trace("New height: " + stage.stageHeight);
} }
} }
} }
snippet class snippet class
${1:public|internal} class ${2:name} ${3:extends } { ${1:public|internal} class ${2:name} ${3:extends } {
@ -109,17 +109,17 @@ snippet try
# For Loop (same as c.snippet) # For Loop (same as c.snippet)
snippet for for (..) {..} snippet for for (..) {..}
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */} ${4}
} }
# Custom For Loop # Custom For Loop
snippet forr snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */} ${5}
} }
# If Condition # If Condition
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:/* code */} ${2}
} }
snippet el snippet el
else { else {
@ -131,7 +131,7 @@ snippet t
snippet fun snippet fun
function ${1:function_name}(${2})${3} function ${1:function_name}(${2})${3}
{ {
${4:/* code */} ${4}
} }
# FlxSprite (usefull when using the flixel library) # FlxSprite (usefull when using the flixel library)
snippet FlxSprite snippet FlxSprite
@ -144,13 +144,13 @@ snippet FlxSprite
public function $1(${3: X:Number, Y:Number}):void public function $1(${3: X:Number, Y:Number}):void
{ {
super(X,Y); super(X,Y);
${4: //code...} ${4}
} }
override public function update():void override public function update():void
{ {
super.update(); super.update();
${5: //code...} ${5}
} }
} }
} }

View file

@ -6,7 +6,7 @@ snippet dir
Order Deny,Allow Order Deny,Allow
Deny from All Deny from All
</Directory> </Directory>
# <FilesMatch> # <FilesMatch>
snippet filesmatch snippet filesmatch
<FilesMatch "${1:regex}"> <FilesMatch "${1:regex}">
${2} ${2}

View file

@ -5,17 +5,17 @@ snippet if
snippet el snippet el
Else Else
${1} ${1}
snippet elif snippet eif
ElseIf ${1:condition} Then ElseIf ${1:condition} Then
${2:; True code} ${2:; True code}
# If/Else block # If/Else block
snippet ifel snippet ife
If ${1:condition} Then If ${1:condition} Then
${2:; True code} ${2:; True code}
Else Else
${3:; Else code} ${3:; Else code}
EndIf EndIf
# If/ElseIf/Else block # If/ElseIf/Else block - because there is eif this is not really neccessary
snippet ifelif snippet ifelif
If ${1:condition 1} Then If ${1:condition 1} Then
${2:; True code} ${2:; True code}

View file

@ -14,13 +14,13 @@ snippet mainn
return 0; return 0;
} }
## ##
## Preprocessor ## Preprocessor
# #include <...> # #include <...>
snippet inc snippet inc
#include <${1:stdio}.h>${2} #include <${1:stdio}.h>${2}
# #include "..." # #include "..."
snippet Inc snippet Inc
#include "${1:`Filename("$1.h")`}"${2} #include "${1:`vim_snippets#Filename("$1.h")`}"${2}
# ifndef...define...endif # ifndef...define...endif
snippet ndef snippet ndef
#ifndef $1 #ifndef $1
@ -41,7 +41,7 @@ snippet #if
#endif #endif
# header include guard # header include guard
snippet once snippet once
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} #ifndef ${1:`toupper(vim_snippets#Filename('$1_H', 'UNTITLED_H'))`}
#define $1 #define $1
@ -53,7 +53,7 @@ snippet once
# if # if
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:/* code */} ${2}
}${3} }${3}
# else # else
snippet el snippet el
@ -63,8 +63,11 @@ snippet el
# else if # else if
snippet elif snippet elif
else if (${1:/* condition */}) { else if (${1:/* condition */}) {
${2:/* code */} ${2}
}${3} }${3}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};${3}
# ternary # ternary
snippet t snippet t
${1:/* condition */} ? ${2:a} : ${3:b} ${1:/* condition */} ? ${2:a} : ${3:b}
@ -94,22 +97,22 @@ snippet case
# for # for
snippet for snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */} ${4}
}${5} }${5}
# for (custom) # for (custom)
snippet forr snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */} ${5}
}${6} }${6}
# while # while
snippet wh snippet wh
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:/* code */} ${2}
}${3} }${3}
# do... while # do... while
snippet do snippet do
do { do {
${2:/* code */} ${2}
} while (${1:/* condition */});${3} } while (${1:/* condition */});${3}
## ##
## Functions ## Functions
@ -117,7 +120,7 @@ snippet do
snippet fun snippet fun
${1:void} ${2:function_name}(${3}) ${1:void} ${2:function_name}(${3})
{ {
${4:/* code */} ${4}
}${5} }${5}
# function declaration # function declaration
snippet fund snippet fund
@ -129,14 +132,14 @@ snippet td
typedef ${1:int} ${2:MyCustomType};${3} typedef ${1:int} ${2:MyCustomType};${3}
# struct # struct
snippet st snippet st
struct ${1:`Filename('$1_t', 'name')`} { struct ${1:`vim_snippets#Filename('$1_t', 'name')`} {
${2:/* data */} ${2:/* data */}
}${3: /* optional variable list */};${4} }${3: /* optional variable list */};${4}
# typedef struct # typedef struct
snippet tds snippet tds
typedef struct ${2:_$1 }{ typedef struct ${2:_$1 }{
${3:/* data */} ${3:/* data */}
} ${1:`Filename('$1_t', 'name')`};${4} } ${1:`vim_snippets#Filename('$1_t', 'name')`};${4}
# typedef enum # typedef enum
snippet tde snippet tde
typedef enum { typedef enum {
@ -230,5 +233,5 @@ snippet gpl
* *
* Copyright (C) ${1:Author}, `strftime("%Y")` * Copyright (C) ${1:Author}, `strftime("%Y")`
*/ */
${2} ${2}

View file

@ -141,7 +141,7 @@ snippet svn
${12:#}svn_username ${13} # (Subversion only) Username for Subversion operations ${12:#}svn_username ${13} # (Subversion only) Username for Subversion operations
${14:#}svn_password ${15} # (Subversion only) Password for Subversion operations ${14:#}svn_password ${15} # (Subversion only) Password for Subversion operations
${16:#}svn_arguments ${17} # (Subversion only) Extra arguments passed to the subversion command ${16:#}svn_arguments ${17} # (Subversion only) Extra arguments passed to the subversion command
${18:#}${19:action :sync} # Update the source to the specified revision, or get a new checkout (Default) ${18:#}${19:action :sync} # Update the source to the specified revision, or get a new checkout (Default)
${20:#}${21:action :checkout} # Checkout the source. Does nothing if a checkout is available ${20:#}${21:action :checkout} # Checkout the source. Does nothing if a checkout is available
${22:#}${23:action :export} # Export the source, excluding or removing any version control artifacts ${22:#}${23:action :export} # Export the source, excluding or removing any version control artifacts
@ -159,7 +159,7 @@ snippet git
${14:#}enable_submodules ${15:"false"} # (Git only) performs a submodule init and submodule update ${14:#}enable_submodules ${15:"false"} # (Git only) performs a submodule init and submodule update
${16:#}remote ${17:"origin"} # (Git only) remote repository to use for syncing an existing clone ${16:#}remote ${17:"origin"} # (Git only) remote repository to use for syncing an existing clone
${18:#}ssh_wrapper ${19} # (Git only) path to a wrapper script for running SSH with git. GIT_SSH environment variable is set to this. ${18:#}ssh_wrapper ${19} # (Git only) path to a wrapper script for running SSH with git. GIT_SSH environment variable is set to this.
${20:#}${21:action :sync} # Update the source to the specified revision, or get a new clone (Default) ${20:#}${21:action :sync} # Update the source to the specified revision, or get a new clone (Default)
${22:#}${23:action :checkout} # Clone the source. Does nothing if a checkout is available ${22:#}${23:action :checkout} # Clone the source. Does nothing if a checkout is available
${24:#}${25:action :export} # Export the source, excluding or removing any version control artifacts ${24:#}${25:action :export} # Export the source, excluding or removing any version control artifacts
@ -197,7 +197,7 @@ snippet deploy
${54:#}before_symlink ${55:"deploy/before_symlink.rb"} # A block or path to a file containing chef code to run before symlinking ${54:#}before_symlink ${55:"deploy/before_symlink.rb"} # A block or path to a file containing chef code to run before symlinking
${56:#}before_restart ${57:"deploy/before_restart.rb"} # A block or path to a file containing chef code to run before restarting ${56:#}before_restart ${57:"deploy/before_restart.rb"} # A block or path to a file containing chef code to run before restarting
${58:#}after_restart ${59:"deploy/after_restart.rb"} # A block or path to a file containing chef code to run after restarting ${58:#}after_restart ${59:"deploy/after_restart.rb"} # A block or path to a file containing chef code to run after restarting
${60:#}${61::deploy} # Deploy the application (Default) ${60:#}${61::deploy} # Deploy the application (Default)
${62:#}${63::force_deploy} # For the revision deploy strategy, this removes any existing release of the same code version and re-deploys in its place ${62:#}${63::force_deploy} # For the revision deploy strategy, this removes any existing release of the same code version and re-deploys in its place
${64:#}${65::rollback} # Rollback the application to the previous release ${64:#}${65::rollback} # Rollback the application to the previous release

View file

@ -43,7 +43,7 @@ snippet if
(if ${1:test-expr} (if ${1:test-expr}
${2:then-expr} ${2:then-expr}
${3:else-expr}) ${3:else-expr})
snippet if-let snippet if-let
(if-let [${1:result} ${2:test-expr}] (if-let [${1:result} ${2:test-expr}]
(${3:then-expr} $1) (${3:then-expr} $1)
(${4:else-expr})) (${4:else-expr}))

View file

@ -39,7 +39,7 @@ snippet link
TARGET_LINK_LIBRARIES(${1:bin} TARGET_LINK_LIBRARIES(${1:bin}
${2:somelib} ${2:somelib}
) )
snippet bin snippet bin
ADD_EXECUTABLE(${1:bin}) ADD_EXECUTABLE(${1:bin})
@ -52,7 +52,7 @@ snippet dep
) )
snippet props snippet props
SET_TARGET_PROPERTIES(${1:target} SET_TARGET_PROPERTIES(${1:target}
${2:PROPERTIES} ${3:COMPILE_FLAGS} ${2:PROPERTIES} ${3:COMPILE_FLAGS}
${4:"-O3 -Wall -pedantic"} ${4:"-O3 -Wall -pedantic"}
) )

View file

@ -35,19 +35,19 @@ snippet bfun
${2:# body...} ${2:# body...}
# Class # Class
snippet cla class .. snippet cla class ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2} ${2}
snippet cla class .. constructor: .. snippet cla class .. constructor: ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
constructor: (${2:args}) -> constructor: (${2:args}) ->
${3} ${3}
${4} ${4}
snippet cla class .. extends .. snippet cla class .. extends ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
${3} ${3}
snippet cla class .. extends .. constructor: .. snippet cla class .. extends .. constructor: ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
constructor: (${3:args}) -> constructor: (${3:args}) ->
${4} ${4}
@ -63,7 +63,7 @@ snippet ife
else else
${3:# body...} ${3:# body...}
# Else if # Else if
snippet elif snippet eif
else if ${1:condition} else if ${1:condition}
${2:# body...} ${2:# body...}
# Ternary If # Ternary If

View file

@ -64,11 +64,11 @@ snippet fr
# mutable # mutable
snippet mu snippet mu
mutable mutable
## ##
## Class ## Class
# class # class
snippet cl snippet cl
class ${1:`Filename('$1', 'name')`} class ${1:`vim_snippets#Filename('$1', 'name')`}
{ {
public: public:
$1(${2}); $1(${2});
@ -79,12 +79,12 @@ snippet cl
}; };
# member function implementation # member function implementation
snippet mfun snippet mfun
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { ${4:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5:/* code */} ${5}
} }
# namespace # namespace
snippet ns snippet ns
namespace ${1:`Filename('', 'my')`} { namespace ${1:`vim_snippets#Filename('', 'my')`} {
${2} ${2}
} /* namespace $1 */ } /* namespace $1 */
## ##
@ -97,16 +97,16 @@ snippet cin
std::cin >> ${1};${2} std::cin >> ${1};${2}
## ##
## Iteration ## Iteration
# for i # for i
snippet fori snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */} ${4}
}${5} }${5}
# foreach # foreach
snippet fore snippet fore
for (${1:auto} ${2:i} : ${3:container}) { for (${1:auto} ${2:i} : ${3:container}) {
${4:/* code */} ${4}
}${5} }${5}
# iterator # iterator
snippet iter snippet iter
@ -123,9 +123,9 @@ snippet itera
## Lambdas ## Lambdas
# lamda (one line) # lamda (one line)
snippet ld snippet ld
[${1}](${2}){${3:/* code */}}${4} [${1}](${2}){${3}}${4}
# lambda (multi-line) # lambda (multi-line)
snippet lld snippet lld
[${1}](${2}){ [${1}](${2}){
${3:/* code */} ${3}
}${4} }${4}

View file

@ -1,12 +1,12 @@
# cs.snippets # cs.snippets
# =========== # ===========
# #
# Standard C-Sharp snippets for snipmate. # Standard C-Sharp snippets for snipmate.
# #
# Largely ported over from Visual Studio 2010 snippets plus # Largely ported over from Visual Studio 2010 snippets plus
# a few snippets from Resharper plus a few widely known snippets. # a few snippets from Resharper plus a few widely known snippets.
# #
# Most snippets on elements (i.e. classes, properties) # Most snippets on elements (i.e. classes, properties)
# follow suffix conventions. The order of suffixes to a snippet # follow suffix conventions. The order of suffixes to a snippet
# is fixed. # is fixed.
# #
@ -55,13 +55,13 @@
# * Events # * Events
# #
# Feedback is welcome! # Feedback is welcome!
# #
# entry point # entry point
snippet sim snippet sim
public static int Main(string[] args) { public static int Main(string[] args) {
${1} ${1}
return 0; return 0;
} }
snippet simc snippet simc
public class Application { public class Application {
public static int Main(string[] args) { public static int Main(string[] args) {
@ -73,13 +73,13 @@ snippet simc
snippet if snippet if
if (${1}) { if (${1}) {
${2} ${2}
} }
snippet el snippet el
else { else {
${1} ${1}
} }
snippet ifs snippet ifs
if (${1}) if (${1})
${2} ${2}
# ternary conditional # ternary conditional
snippet t snippet t
@ -116,49 +116,49 @@ snippet each
} }
# interfaces # interfaces
snippet interface snippet interface
public interface ${1:`Filename()`} { public interface ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet if+ snippet if+
public interface ${1:`Filename()`} { public interface ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
# class bodies # class bodies
snippet class snippet class
public class ${1:`Filename()`} { public class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls snippet cls
${2:public} class ${1:`Filename()`} { ${2:public} class ${1:`vim_snippets#Filename()`} {
${3} ${3}
} }
snippet cls+ snippet cls+
public class ${1:`Filename()`} { public class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls+^ snippet cls+^
public static class ${1:`Filename()`} { public static class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls& snippet cls&
internal class ${1:`Filename()`} { internal class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls&^ snippet cls&^
internal static class ${1:`Filename()`} { internal static class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls| snippet cls|
protected class ${1:`Filename()`} { protected class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
snippet cls|% snippet cls|%
protected abstract class ${1:`Filename()`} { protected abstract class ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
# constructor # constructor
snippet ctor snippet ctor
public ${1:`Filename()`}() { public ${1:`vim_snippets#Filename()`}() {
${2} ${2}
} }
# properties - auto properties by default. # properties - auto properties by default.
@ -342,7 +342,7 @@ snippet ms-
} }
# structure # structure
snippet struct snippet struct
public struct ${1:`Filename()`} { public struct ${1:`vim_snippets#Filename()`} {
${2} ${2}
} }
# enumeration # enumeration

View file

@ -9,7 +9,7 @@ snippet so
${2} ${2}
snippet main snippet main
static void main() { static void main() {
${1:/* code */} ${1}
} }
snippet st snippet st
static ${1} static ${1}
@ -22,9 +22,9 @@ snippet br
snippet th snippet th
throw ${1} throw ${1}
snippet cl snippet cl
class ${1:`Filename("", "untitled")`} ${2} class ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet in snippet in
interface ${1:`Filename("", "untitled")`} ${2} interface ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet imp snippet imp
implements ${1} implements ${1}
snippet ext snippet ext
@ -57,15 +57,15 @@ snippet for
} }
snippet fore snippet fore
for (final ${2:item} in ${1:itemList}) { for (final ${2:item} in ${1:itemList}) {
${3:/* code */} ${3}
} }
snippet wh snippet wh
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:/* code */} ${2}
} }
snippet dowh snippet dowh
do { do {
${2:/* code */} ${2}
} while (${1:/* condition */}); } while (${1:/* condition */});
snippet as snippet as
assert(${1:/* condition */}); assert(${1:/* condition */});

View file

@ -73,16 +73,16 @@ snippet model
class ${1:ModelName}(models.Model): class ${1:ModelName}(models.Model):
"""${2:docstring}""" """${2:docstring}"""
${3} ${3}
class Meta: class Meta:
${4} ${4}
def __unicode__(self): def __unicode__(self):
${5} ${5}
def save(self, force_insert=False, force_update=False): def save(self, force_insert=False, force_update=False):
${6} ${6}
@models.permalink @models.permalink
def get_absolute_url(self): def get_absolute_url(self):
return ('${7:view_or_url_name}' ${8}) return ('${7:view_or_url_name}' ${8})
@ -90,9 +90,9 @@ snippet model
snippet modeladmin snippet modeladmin
class ${1:ModelName}Admin(admin.ModelAdmin): class ${1:ModelName}Admin(admin.ModelAdmin):
${2} ${2}
admin.site.register($1, $1Admin) admin.site.register($1, $1Admin)
snippet tabularinline snippet tabularinline
class ${1:ModelName}Inline(admin.TabularInline): class ${1:ModelName}Inline(admin.TabularInline):
model = $1 model = $1

View file

@ -0,0 +1,122 @@
snippet do
do
${1}
end
snippet if if .. do .. end
if ${1} do
${2}
end
snippet if if .. do: ..
if ${1:condition}, do: ${2}
snippet ife if .. do .. else .. end
if ${1:condition} do
${2}
else
${3}
end
snippet ife if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${3}
snippet unless unless .. do .. end
unless ${1} do
${2}
end
snippet unless unless .. do: ..
unless ${1:condition}, do: ${2}
snippet unlesse unless .. do .. else .. end
unless ${1:condition} do
${2}
else
${3}
end
snippet unlesse unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${3}
snippet cond
cond do
${1} ->
${2}
end
snippet case
case ${1} do
${2} ->
${3}
end
snippet def
def ${1:name} do
${2}
end
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${3}
end
snippet defma
defmacro ${1:name} do
${2}
end
snippet defmo
defmodule ${1:module_name} do
${2}
end
snippet defp
defp ${1:name} do
${2}
end
snippet defpr
defprotocol ${1:name}, [${2:function}]
snippet defr
defrecord ${1:record_name}, ${2:fields}
snippet doc
@doc """
${1}
"""
snippet fn
fn(${1:args}) -> ${2} end
snippet mdoc
@moduledoc """
${1}
"""
snippet rec
receive do
${1} ->
${2}
end
snippet req
require ${1:module_name}
snippet imp
import ${1:module_name}
snippet ali
alias ${1:module_name}
snippet test
test "${1:test_name}" do
${2}
end
snippet try try .. rescue .. end
try do
${1}
rescue
${2} -> ${3}
end

View file

@ -1,12 +1,12 @@
# module and export all # module and export all
snippet mod snippet mod
-module(${1:`Filename('', 'my')`}). -module(${1:`vim_snippets#Filename('', 'my')`}).
-compile([export_all]). -compile([export_all]).
start() -> start() ->
${2} ${2}
stop() -> stop() ->
ok. ok.
# define directive # define directive
@ -66,7 +66,7 @@ snippet %p
%% @private %% @private
# OTP application # OTP application
snippet application snippet application
-module(${1:`Filename('', 'my')`}). -module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(application). -behaviour(application).
@ -81,10 +81,10 @@ snippet application
end. end.
stop(_State) -> stop(_State) ->
ok. ok.
# OTP supervisor # OTP supervisor
snippet supervisor snippet supervisor
-module(${1:`Filename('', 'my')`}). -module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(supervisor). -behaviour(supervisor).
@ -107,7 +107,7 @@ snippet supervisor
{ok, {RestartStrategy, Children}}. {ok, {RestartStrategy, Children}}.
# OTP gen_server # OTP gen_server
snippet gen_server snippet gen_server
-module(${1:`Filename('', 'my')`}). -module(${1:`vim_snippets#Filename('', 'my')`}).
-behaviour(gen_server). -behaviour(gen_server).
@ -157,4 +157,194 @@ snippet gen_server
%%%=================================================================== %%%===================================================================
%%% Internal functions %%% Internal functions
%%%=================================================================== %%%===================================================================
# common_test test_SUITE
snippet testsuite
-module(${1:`vim_snippets#Filename('', 'my')`}).
-include_lib("common_test/include/ct.hrl").
%% Test server callbacks
-export([suite/0, all/0, groups/0,
init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2]).
%% Test cases
-export([
]).
%%--------------------------------------------------------------------
%% COMMON TEST CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
%% Function: suite() -> Info
%%
%% Info = [tuple()]
%% List of key/value pairs.
%%
%% Description: Returns list of tuples to set default properties
%% for the suite.
%%
%% Note: The suite/0 function is only meant to be used to return
%% default data values, not perform any other operations.
%%--------------------------------------------------------------------
suite() ->
[{timetrap,{minutes,10}}].
%%--------------------------------------------------------------------
%% Function: init_per_suite(Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the suite.
%%
%% Description: Initialization before the suite.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_suite(Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%%
%% Description: Cleanup after the suite.
%%--------------------------------------------------------------------
end_per_suite(_Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: init_per_group(GroupName, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% GroupName = atom()
%% Name of the test case group that is about to run.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding configuration data for the group.
%% Reason = term()
%% The reason for skipping all test cases and subgroups in the group.
%%
%% Description: Initialization before each test case group.
%%--------------------------------------------------------------------
init_per_group(_GroupName, Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_group(GroupName, Config0) ->
%% void() | {save_config,Config1}
%%
%% GroupName = atom()
%% Name of the test case group that is finished.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding configuration data for the group.
%%
%% Description: Cleanup after each test case group.
%%--------------------------------------------------------------------
end_per_group(_GroupName, _Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: init_per_testcase(TestCase, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% TestCase = atom()
%% Name of the test case that is about to run.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the test case.
%%
%% Description: Initialization before each test case.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_testcase(_TestCase, Config) ->
Config.
%%--------------------------------------------------------------------
%% Function: end_per_testcase(TestCase, Config0) ->
%% void() | {save_config,Config1} | {fail,Reason}
%%
%% TestCase = atom()
%% Name of the test case that is finished.
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for failing the test case.
%%
%% Description: Cleanup after each test case.
%%--------------------------------------------------------------------
end_per_testcase(_TestCase, _Config) ->
ok.
%%--------------------------------------------------------------------
%% Function: groups() -> [Group]
%%
%% Group = {GroupName,Properties,GroupsAndTestCases}
%% GroupName = atom()
%% The name of the group.
%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
%% Group properties that may be combined.
%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
%% TestCase = atom()
%% The name of a test case.
%% Shuffle = shuffle | {shuffle,Seed}
%% To get cases executed in random order.
%% Seed = {integer(),integer(),integer()}
%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
%% repeat_until_any_ok | repeat_until_any_fail
%% To get execution of cases repeated.
%% N = integer() | forever
%%
%% Description: Returns a list of test case group definitions.
%%--------------------------------------------------------------------
groups() ->
[].
%%--------------------------------------------------------------------
%% Function: all() -> GroupsAndTestCases | {skip,Reason}
%%
%% GroupsAndTestCases = [{group,GroupName} | TestCase]
%% GroupName = atom()
%% Name of a test case group.
%% TestCase = atom()
%% Name of a test case.
%% Reason = term()
%% The reason for skipping all groups and test cases.
%%
%% Description: Returns the list of groups and test cases that
%% are to be executed.
%%--------------------------------------------------------------------
all() ->
[].
%%--------------------------------------------------------------------
%% TEST CASES
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
%% Function: TestCase(Config0) ->
%% ok | exit() | {skip,Reason} | {comment,Comment} |
%% {save_config,Config1} | {skip_and_save,Reason,Config1}
%%
%% Config0 = Config1 = [tuple()]
%% A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%% The reason for skipping the test case.
%% Comment = term()
%% A comment about the test case that will be printed in the html log.
%%
%% Description: Test case function. (The name of it must be specified in
%% the all/0 list or in a test case group for the test case
%% to be executed).
%%--------------------------------------------------------------------

View file

@ -53,6 +53,8 @@ snippet ff
<%= form_for @${1:model} do |f| %> <%= form_for @${1:model} do |f| %>
${2} ${2}
<% end %> <% end %>
snippet ffi
<%= ${1:f}.input :${2:attribute} %>
snippet ffcb snippet ffcb
<%= ${1:f}.check_box :${2:attribute} %> <%= ${1:f}.check_box :${2:attribute} %>
snippet ffe snippet ffe
@ -111,3 +113,13 @@ snippet slt
<%= stylesheet_link_tag ${1::all}, :cache => ${2:true} %> <%= stylesheet_link_tag ${1::all}, :cache => ${2:true} %>
snippet sslt snippet sslt
<%= stylesheet_link_tag "${1}" %> <%= stylesheet_link_tag "${1}" %>
snippet if
<% if ${1} %>
${2}
<% end %>
snippet ife
<% if ${1} %>
${2}
<% else %>
${3}
<% end %>

View file

@ -1,15 +1,15 @@
snippet #! snippet #!
#!/usr/bin/env falcon #!/usr/bin/env falcon
# Import # Import
snippet imp snippet imp
import ${1:module} import ${1:module}
# Function # Function
snippet fun snippet fun
function ${2:function_name}(${3}) function ${2:function_name}(${3})
${4:/* code */} ${4}
end end
# Class # Class
snippet class snippet class
@ -17,35 +17,35 @@ snippet class
${3:/* members/methods */} ${3:/* members/methods */}
end end
# If # If
snippet if snippet if
if ${1:condition} if ${1:condition}
${2:/* code */} ${2}
end end
# If else # If else
snippet ife snippet ife
if ${1:condition} if ${1:condition}
${2:/* code */} ${2}
else else
${1} ${1}
end end
# If else if # If else if
snippet elif snippet eif
elif ${1:condition} elif ${1:condition}
${2:/* code */} ${2}
# Switch case # Switch case
snippet switch snippet switch
switch ${1:expression} switch ${1:expression}
case ${2:item} case ${2:item}
case ${3:item} case ${3:item}
default default
end end
# Select # Select
snippet select snippet select
select ${1:variable} select ${1:variable}
case ${2:TypeSpec} case ${2:TypeSpec}
case ${3:TypeSpec} case ${3:TypeSpec}
@ -55,17 +55,17 @@ snippet select
# For/in Loop # For/in Loop
snippet forin snippet forin
for ${1:element} in ${2:container} for ${1:element} in ${2:container}
${3:/* code */} ${3}
end end
# For/to Loop # For/to Loop
snippet forto snippet forto
for ${1:lowerbound} to ${2:upperbound} for ${1:lowerbound} to ${2:upperbound}
${3:/* code */} ${3}
end end
# While Loop # While Loop
snippet while snippet while
while ${1:conidition} while ${1:conidition}
${2:/* code */} ${2}
end end

View file

@ -4,7 +4,7 @@ snippet ap
# bool # bool
snippet bl snippet bl
bool bool
# byte # byte
snippet bt snippet bt
byte byte
# break # break
@ -16,7 +16,7 @@ snippet ch
# case # case
snippet cs snippet cs
case ${1:value}: case ${1:value}:
${2:/* code */} ${2}
# const # const
snippet c snippet c
const ${1:NAME} = ${2:0} const ${1:NAME} = ${2:0}
@ -29,14 +29,14 @@ snippet co
# continue # continue
snippet cn snippet cn
continue continue
# defer # defer
snippet df snippet df
defer ${1:func}() defer ${1:func}()
# defer recover # defer recover
snippet dfr snippet dfr
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
${1:/* code */} ${1}
} }
}() }()
# gpl # gpl
@ -57,20 +57,20 @@ snippet gpl
* *
* Copyright (C) ${1:Author}, `strftime("%Y")` * Copyright (C) ${1:Author}, `strftime("%Y")`
*/ */
${2} ${2}
# int # int
snippet i snippet i
int int
# import # import
snippet im snippet im
import ( import (
"${1:package}" "${1:package}"
)${2} )${2}
# interface # interface
snippet in snippet in
interface{} interface{}
# full interface snippet # full interface snippet
snippet inf snippet inf
interface ${1:name} { interface ${1:name} {
${2:/* methods */} ${2:/* methods */}
@ -78,8 +78,8 @@ snippet inf
# if condition # if condition
snippet if snippet if
if ${1:/* condition */} { if ${1:/* condition */} {
${2:/* code */} ${2}
}${2} }${3}
# else snippet # else snippet
snippet el snippet el
else { else {
@ -109,7 +109,7 @@ snippet f6
# if else # if else
snippet ie snippet ie
if ${1:/* condition */} { if ${1:/* condition */} {
${2:/* code */} ${2}
} else { } else {
${3} ${3}
} }
@ -117,25 +117,25 @@ snippet ie
# for loop # for loop
snippet fo snippet fo
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} { for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${4:/* code */} ${4}
} }
${5} ${5}
# for range loop # for range loop
snippet fr snippet fr
for ${1:k}, ${2:v} := range ${3} { for ${1:k}, ${2:v} := range ${3} {
${4:/* code */} ${4}
} }
${5} ${5}
# function simple # function simple
snippet fun snippet fun
func ${1:funcName}(${2}) ${3:error} { func ${1:funcName}(${2}) ${3:error} {
${4:/* code */} ${4}
} }
${5} ${5}
# function on receiver # function on receiver
snippet fum snippet fum
func (self ${1:type}) ${2:funcName}(${3}) ${4:error} { func (self ${1:type}) ${2:funcName}(${3}) ${4:error} {
${5:/* code */} ${5}
} }
${6} ${6}
# log printf # log printf
@ -147,42 +147,42 @@ snippet lp
# make # make
snippet mk snippet mk
make(${1:[]string}, ${2:0}) make(${1:[]string}, ${2:0})
# map # map
snippet mp snippet mp
map[${1:string}]${2:int} map[${1:string}]${2:int}
# main() # main()
snippet main snippet main
func main() { func main() {
${1:/* code */} ${1}
} }
${2} ${2}
# new # new
snippet nw snippet nw
new(${1:type}) new(${1:type})
# panic # panic
snippet pn snippet pn
panic("${1:msg}") panic("${1:msg}")
# print # print
snippet pr snippet pr
fmt.Printf("%${1:s}\n", ${2:var})${3} fmt.Printf("%${1:s}\n", ${2:var})${3}
# range # range
snippet rn snippet rn
range ${1} range ${1}
# return # return
snippet rt snippet rt
return ${1} return ${1}
# result # result
snippet rs snippet rs
result result
# select # select
snippet sl snippet sl
select { select {
case ${1:v1} := <-${2:chan1} case ${1:v1} := <-${2:chan1}
${3:/* code */} ${3}
case ${4:v2} := <-${5:chan2} case ${4:v2} := <-${5:chan2}
${6:/* code */} ${6}
default: default:
${7:/* code */} ${7}
} }
# string # string
snippet sr snippet sr
@ -193,19 +193,19 @@ snippet st
${2:/* data */} ${2:/* data */}
} }
${3} ${3}
# switch # switch
snippet sw snippet sw
switch ${1:var} { switch ${1:var} {
case ${2:value1}: case ${2:value1}:
${3:/* code */} ${3}
case ${4:value2}: case ${4:value2}:
${5:/* code */} ${5}
default: default:
${6:/* code */} ${6}
} }
snippet sp snippet sp
fmt.Sprintf("%${1:s}", ${2:var})${3} fmt.Sprintf("%${1:s}", ${2:var})${3}
# true # true
snippet t snippet t
true true
# variable declaration # variable declaration

View file

@ -11,10 +11,20 @@ snippet ul
%li %li
${1:item} ${1:item}
%li %li
snippet =rp snippet rp
= render :partial => '${1:partial}' = render :partial => "${1:item}"
snippet =rpl snippet rpc
= render :partial => '${1:partial}', :locals => {} = render :partial => "${1:item}", :collection => ${2:@$1s}
snippet =rpc snippet rpl
= render :partial => '${1:partial}', :collection => @$1 = render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}
snippet rpo
= render :partial => "${1:item}", :object => ${2:@$1}
snippet ife
- if ${1:condition}
${2}
- else
${3}
snippet ifp
- if ${1:condition}.presence?
${2}

View file

@ -48,7 +48,7 @@ snippet ap
${1:map} ${2:fn} ${3:list} ${1:map} ${2:fn} ${3:list}
snippet do snippet do
do do
snippet λ snippet λ
\${1:x} -> ${2} \${1:x} -> ${2}
snippet \ snippet \

View file

@ -412,7 +412,7 @@ snippet head
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title> <title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2} ${2}
</head> </head>
snippet header snippet header
@ -450,7 +450,7 @@ snippet html5
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title> <title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2:meta} ${2:meta}
</head> </head>
<body> <body>
@ -730,6 +730,10 @@ snippet source
<source src="${1}" type="${2}" media="${3}" /> <source src="${1}" type="${2}" media="${3}" />
snippet span snippet span
<span>${1}</span> <span>${1}</span>
snippet span.
<span class="${1}">${2}</span>
snippet span#
<span id="${1}">${2}</span>
snippet strong snippet strong
<strong>${1}</strong> <strong>${1}</strong>
snippet style snippet style
@ -791,7 +795,7 @@ snippet thead
snippet time snippet time
<time datetime="${1}" pubdate="${2:$1}">${3:$1}</time> <time datetime="${1}" pubdate="${2:$1}">${3:$1}</time>
snippet title snippet title
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title> <title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
snippet tr snippet tr
<tr> <tr>
${1} ${1}

View file

@ -0,0 +1,74 @@
# file containing most useful mappings only
# when editing this file please be aware that there is ZenCoding and sparkup
# html 5 is recommended from now on
snippet html5
<!doctype html>
<html>
<head>
<title>$2</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
$3
</head>
<body>
$4
</body>
</html>
# ==== TAGS
# you always need these:
snippet .
class="${1}"${2}
snippet n
name="${1}"${2}
snippet r
rel="${1}"${2}
snippet t
title="${1}"${2}
# not using # because id is faster to type
snippet id
id="${1}"${2}
snippet idn
id="${1}" name="${2:$1}"
snippet label_and_input
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}" id="${5:$2}" value="${6}" />${7}
# FORMS
# use idn . or n to add id
snippet input
<input type="${1:text}" value="${2}" ${3}/>${7}
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
snippet textarea
<textarea $1>$2</textarea>
# if you need id or class use snippets above
snippet form
<form method="${1:post/get}" action="$2">
$3
</form>
# other tags
snippet br
<br/>
snippet a
<a href="#" $2>$3</a>
snippet img
<img src="$1" alt="$2"/>
# JS/CSS
snippet css_file
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />${3}
snippet css_block
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}">
</link>
snippet script_block
<script type="text/javascript" charset="utf-8">
</script>
snippet script_file
<script type="text/javascript" charset="utf-8">
</script>

View file

@ -47,10 +47,10 @@ snippet if
{% if ${1} %} {% if ${1} %}
${2} ${2}
{% endif %} {% endif %}
snippet else snippet el
{% else %} {% else %}
${1} ${1}
snippet elif snippet eif
{% elif ${1} %} {% elif ${1} %}
${2} ${2}
snippet ifchanged snippet ifchanged

View file

@ -27,9 +27,9 @@ snippet if
{% if ${1:condition} %} {% if ${1:condition} %}
${2} ${2}
{% end %} {% end %}
snippet elif snippet eif
{% elif ${1:condition} %} {% elif ${1:condition} %}
snippet else snippet el
{% else %} {% else %}
snippet import snippet import
{% import ${1:module} %} {% import ${1:module} %}

View file

@ -39,15 +39,15 @@ snippet j.u
## ##
## Class ## Class
snippet cl snippet cl
class ${1:`Filename("", "untitled")`} ${2} class ${1:`vim_snippets#Filename("", "untitled")`} ${2}
snippet in snippet in
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent}${3}
snippet tc snippet tc
public class ${1:`Filename()`} extends ${2:TestCase} public class ${1:`vim_snippets#Filename()`} extends ${2:TestCase}
## ##
## Class Enhancements ## Class Enhancements
snippet ext snippet ext
extends extends
snippet imp snippet imp
implements implements
## ##
@ -72,7 +72,7 @@ snippet def
${2} ${2}
snippet el snippet el
else else
snippet elif snippet eif
else if (${1}) ${2} else if (${1}) ${2}
snippet if snippet if
if (${1}) ${2} if (${1}) ${2}
@ -144,7 +144,7 @@ snippet @au
snippet @br snippet @br
@brief ${1:Description} @brief ${1:Description}
snippet @fi snippet @fi
@file ${1:`Filename()`}.java @file ${1:`vim_snippets#Filename()`}.java
snippet @pa snippet @pa
@param ${1:param} @param ${1:param}
snippet @re snippet @re
@ -171,7 +171,7 @@ snippet wh
## Main method ## Main method
snippet main snippet main
public static void main (String[] args) { public static void main (String[] args) {
${1:/* code */} ${1}
} }
## ##
## Print Methods ## Print Methods

View file

@ -260,7 +260,7 @@ snippet filter
${1:obj}.filter('${2:selector expression}')${3} ${1:obj}.filter('${2:selector expression}')${3}
snippet filtert snippet filtert
${1:obj}.filter(function (${2:index}) { ${1:obj}.filter(function (${2:index}) {
${3:// test code} ${3}
})${4} })${4}
snippet find snippet find
${1:obj}.find('${2:selector expression}')${3} ${1:obj}.find('${2:selector expression}')${3}
@ -291,7 +291,7 @@ snippet getscript
}); });
snippet grep snippet grep
$.grep(${1:array}, function (item, index) { $.grep(${1:array}, function (item, index) {
${2:// test code} ${2}
}${3:, true}); }${3:, true});
snippet hasc snippet hasc
${1:obj}.hasClass('${2:className}')${3} ${1:obj}.hasClass('${2:className}')${3}

View file

@ -17,7 +17,7 @@ snippet f
# Immediate function # Immediate function
snippet (f snippet (f
(function (${1}) { (function (${1}) {
${3:/* code */} ${3}
}(${2})); }(${2}));
# if # if
snippet if snippet if
@ -38,16 +38,16 @@ snippet ter
snippet switch snippet switch
switch (${1:expression}) { switch (${1:expression}) {
case '${3:case}': case '${3:case}':
${4:// code} ${4}
break; break;
${5} ${5}
default: default:
${2:// code} ${2}
} }
# case # case
snippet case snippet case
case '${1:case}': case '${1:case}':
${2:// code} ${2}
break; break;
${3} ${3}
# for (...) {...} # for (...) {...}
@ -63,19 +63,19 @@ snippet forr
# while (...) {...} # while (...) {...}
snippet wh snippet wh
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:/* code */} ${2}
} }
# try # try
snippet try snippet try
try { try {
${1:/* code */} ${1}
} catch (${2:e}) { } catch (${2:e}) {
${3:/* handle error */} ${3:/* handle error */}
} }
# do...while # do...while
snippet do snippet do
do { do {
${2:/* code */} ${2}
} while (${1:/* condition */}); } while (${1:/* condition */});
# Object Method # Object Method
snippet :f snippet :f
@ -124,10 +124,10 @@ snippet jsons
# self-defining function # self-defining function
snippet sdf snippet sdf
var ${1:function_name} = function (${2:argument}) { var ${1:function_name} = function (${2:argument}) {
${3:// initial code ...} ${3}
$1 = function ($2) { $1 = function ($2) {
${4:// main code} ${4}
}; };
}; };
# singleton # singleton
@ -140,7 +140,7 @@ snippet sing
$1 = function $1($2) { $1 = function $1($2) {
return instance; return instance;
}; };
// carry over the prototype properties // carry over the prototype properties
$1.prototype = this; $1.prototype = this;
@ -150,11 +150,11 @@ snippet sing
// reset the constructor pointer // reset the constructor pointer
instance.constructor = $1; instance.constructor = $1;
${3:// code ...} ${3}
return instance; return instance;
} }
# Crockford's object function # Crockford's object function
snippet obj snippet obj
function object(o) { function object(o) {
function F() {} function F() {}
@ -164,7 +164,7 @@ snippet obj
# Define multiple properties # Define multiple properties
snippet props snippet props
var ${1:my_object} = Object.defineProperties( var ${1:my_object} = Object.defineProperties(
${2:new Object()}, ${2:new Object()},
{ {
${3:property} : { ${3:property} : {
get : function $1_$3_getter() { get : function $1_$3_getter() {
@ -182,9 +182,9 @@ snippet props
); );
# Define single property # Define single property
snippet prop snippet prop
Object.defineProperty( Object.defineProperty(
${1:object}, ${1:object},
"${2:property}", "${2:property}",
{ {
get : function $1_$2_getter() { get : function $1_$2_getter() {
// getter code // getter code

View file

@ -1,4 +1,4 @@
snippet ifeq snippet ifeq
ifeq (${1:cond0},${2:cond1}) ifeq (${1:cond0},${2:cond1})
${3:code} ${3}
endif endif

View file

@ -22,7 +22,7 @@ snippet if if
% if ${1:condition}: % if ${1:condition}:
${2:} ${2:}
% endif % endif
snippet if if/else snippet ife if/else
% if ${1:condition}: % if ${1:condition}:
${2:} ${2:}
% else: % else:

View file

@ -24,11 +24,11 @@ snippet ![:*
snippet === snippet ===
`repeat('=', strlen(getline(line(".") - 1)))` `repeat('=', strlen(getline(line(".") - 1)))`
${1} ${1}
snippet --- snippet ---
`repeat('-', strlen(getline(line(".") - 1)))` `repeat('-', strlen(getline(line(".") - 1)))`
${1} ${1}
snippet blockquote snippet blockquote

View file

@ -3,7 +3,7 @@ snippet Imp
#import <${1:Cocoa/Cocoa.h}>${2} #import <${1:Cocoa/Cocoa.h}>${2}
# #import "..." # #import "..."
snippet imp snippet imp
#import "${1:`Filename()`.h}"${2} #import "${1:`vim_snippets#Filename()`.h}"${2}
# @selector(...) # @selector(...)
snippet sel snippet sel
@selector(${1:method}:)${3} @selector(${1:method}:)${3}
@ -18,7 +18,7 @@ snippet log
NSLog(@"${1:%@}"${2});${3} NSLog(@"${1:%@}"${2});${3}
# Class # Class
snippet objc snippet objc
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} @interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{ {
} }
@end @end
@ -28,33 +28,33 @@ snippet objc
@end @end
# Class Interface # Class Interface
snippet int snippet int
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} @interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3} {${3}
} }
${4} ${4}
@end @end
snippet @interface snippet @interface
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} @interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3} {${3}
} }
${4} ${4}
@end @end
# Class Implementation # Class Implementation
snippet impl snippet impl
@implementation ${1:`Filename('', 'someClass')`} @implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${2} ${2}
@end @end
snippet @implementation snippet @implementation
@implementation ${1:`Filename('', 'someClass')`} @implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${2} ${2}
@end @end
# Protocol # Protocol
snippet pro snippet pro
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>} @protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${3} ${3}
@end @end
snippet @protocol snippet @protocol
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>} @protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${3} ${3}
@end @end
# init Definition # init Definition
@ -87,7 +87,7 @@ snippet cat
@end @end
# Category Interface # Category Interface
snippet cath snippet cath
@interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory}) @interface ${1:`vim_snippets#Filename('$1', 'NSObject')`} (${2:MyCategory})
${3} ${3}
@end @end
# Method # Method
@ -207,7 +207,7 @@ snippet arel
# autorelease pool # autorelease pool
snippet pool snippet pool
NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
${2:/* code */} ${2}
[$1 drain]; [$1 drain];
# Throw an exception # Throw an exception
snippet except snippet except

View file

@ -8,31 +8,35 @@ snippet .
# Function # Function
snippet sub snippet sub
sub ${1:function_name} { sub ${1:function_name} {
${2:#body ...} ${2}
} }
# Conditional # Conditional
snippet if snippet if
if (${1}) { if (${1}) {
${2:# body...} ${2}
} }
# Conditional if..else # Conditional if..else
snippet ife snippet ife
if (${1}) { if (${1}) {
${2:# body...} ${2}
} }
else { else {
${3:# else...} ${3}
} }
# Conditional if..elsif..else # Conditional if..elsif..else
snippet ifee snippet ifee
if (${1}) { if (${1}) {
${2:# body...} ${2}
} }
elsif (${3}) { elsif (${3}) {
${4:# elsif...} ${4:# elsif...}
} }
else { else {
${5:# else...} ${5}
}
snippet eif
elsif (${1}) {
${2}
} }
# Conditional One-line # Conditional One-line
snippet xif snippet xif
@ -40,7 +44,7 @@ snippet xif
# Unless conditional # Unless conditional
snippet unless snippet unless
unless (${1}) { unless (${1}) {
${2:# body...} ${2}
} }
# Unless conditional One-line # Unless conditional One-line
snippet xunless snippet xunless
@ -57,7 +61,7 @@ snippet eval
# While Loop # While Loop
snippet wh snippet wh
while (${1}) { while (${1}) {
${2:# body...} ${2}
} }
# While Loop One-line # While Loop One-line
snippet xwh snippet xwh
@ -65,7 +69,7 @@ snippet xwh
# C-style For Loop # C-style For Loop
snippet cfor snippet cfor
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:# body...} ${4}
} }
# For loop one-line # For loop one-line
snippet xfor snippet xfor
@ -73,14 +77,14 @@ snippet xfor
# Foreach Loop # Foreach Loop
snippet for snippet for
foreach my $${1:x} (@${2:array}) { foreach my $${1:x} (@${2:array}) {
${3:# body...} ${3}
} }
# Foreach Loop One-line # Foreach Loop One-line
snippet fore snippet fore
${1:expression} foreach @${2:array};${3} ${1:expression} foreach @${2:array};${3}
# Package # Package
snippet package snippet package
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`};
${2} ${2}
@ -89,7 +93,7 @@ snippet package
__END__ __END__
# Package syntax perl >= 5.14 # Package syntax perl >= 5.14
snippet packagev514 snippet packagev514
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
${3} ${3}
@ -127,7 +131,7 @@ snippet switch
# Anonymous subroutine # Anonymous subroutine
snippet asub snippet asub
sub { sub {
${1:# body } ${1}
} }
@ -135,7 +139,7 @@ snippet asub
# Begin block # Begin block
snippet begin snippet begin
BEGIN { BEGIN {
${1:# begin body} ${1}
} }
# call package function with some parameter # call package function with some parameter
@ -174,7 +178,7 @@ snippet given
# switch-like case # switch-like case
snippet when snippet when
when (${1:case}) { when (${1:case}) {
${2:# body} ${2}
} }
# hash slice # hash slice
@ -237,7 +241,7 @@ snippet subpod
=cut =cut
sub ${1:subroutine_name} { sub ${1:subroutine_name} {
${2:# body...} ${2}
} }
# Subroutine signature # Subroutine signature
snippet parg snippet parg
@ -318,7 +322,7 @@ snippet trunner
snippet tsub snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) { sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift; my $self = shift;
${4:# body} ${4}
} }
@ -326,14 +330,14 @@ snippet tsub
snippet trsub snippet trsub
test ${1:test_name} => { description => '${2:Description of test.}'} => sub { test ${1:test_name} => { description => '${2:Description of test.}'} => sub {
my ($self) = @_; my ($self) = @_;
${3:# test code} ${3}
}; };
#prep test method #prep test method
snippet tprep snippet tprep
sub prep${1:number}_${2:test_case} :Test(startup) { sub prep${1:number}_${2:test_case} :Test(startup) {
my $self = shift; my $self = shift;
${4:# body} ${4}
} }
# cause failures to print stack trace # cause failures to print stack trace

View file

@ -28,12 +28,12 @@ snippet use
use ${1:Foo\Bar\Baz}; use ${1:Foo\Bar\Baz};
${2} ${2}
snippet c snippet c
class ${1:`Filename()`} class ${1:`vim_snippets#Filename()`}
{ {
${2} ${2}
} }
snippet i snippet i
interface ${1:`Filename()`} interface ${1:`vim_snippets#Filename()`}
{ {
${2} ${2}
} }
@ -57,7 +57,7 @@ snippet sm
* *
* @param ${2:$1} $$1 ${3:description} * @param ${2:$1} $$1 ${3:description}
* *
* @return ${4:`Filename()`} * @return ${4:`vim_snippets#Filename()`}
*/ */
${5:public} function set${6:$2}(${7:$2 }$$1) ${5:public} function set${6:$2}(${7:$2 }$$1)
{ {
@ -214,7 +214,7 @@ snippet interface
* @package ${3:default} * @package ${3:default}
* @author ${4:`g:snips_author`} * @author ${4:`g:snips_author`}
*/ */
interface ${1:`Filename()`} interface ${1:`vim_snippets#Filename()`}
{ {
${5} ${5}
} }
@ -223,7 +223,7 @@ snippet class
/** /**
* ${1} * ${1}
*/ */
class ${2:`Filename()`} class ${2:`vim_snippets#Filename()`}
{ {
${3} ${3}
/** /**
@ -231,13 +231,13 @@ snippet class
*/ */
${5:public} function ${6:__construct}(${7:argument}) ${5:public} function ${6:__construct}(${7:argument})
{ {
${8:// code...} ${8}
} }
} }
snippet nc snippet nc
namespace ${1:`substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`}; namespace ${1:`substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`};
${2:abstract }class ${3:`Filename()`} ${2:abstract }class ${3:`vim_snippets#Filename()`}
{ {
${4} ${4}
} }
@ -249,26 +249,26 @@ snippet def?
${1}defined('${2}')${3} ${1}defined('${2}')${3}
snippet wh snippet wh
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:// code...} ${2}
} }
# do ... while # do ... while
snippet do snippet do
do { do {
${2:// code... } ${2}
} while (${1:/* condition */}); } while (${1:/* condition */});
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:// code...} ${2}
} }
snippet ifil snippet ifil
<?php if (${1:/* condition */}): ?> <?php if (${1:/* condition */}): ?>
${2:<!-- code... -->} ${2}
<?php endif; ?> <?php endif; ?>
snippet ife snippet ife
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:// code...} ${2}
} else { } else {
${3:// code...} ${3}
} }
${4} ${4}
snippet ifeil snippet ifeil
@ -278,35 +278,35 @@ snippet ifeil
${3:<!-- html... -->} ${3:<!-- html... -->}
<?php endif; ?> <?php endif; ?>
${4} ${4}
snippet else snippet el
else { else {
${1:// code...} ${1}
} }
snippet elseif snippet eif
elseif (${1:/* condition */}) { elseif (${1:/* condition */}) {
${2:// code...} ${2}
} }
snippet switch snippet switch
switch ($${1:variable}) { switch ($${1:variable}) {
case '${2:value}': case '${2:value}':
${3:// code...} ${3}
break; break;
${5} ${5}
default: default:
${4:// code...} ${4}
break; break;
} }
snippet case snippet case
case '${1:value}': case '${1:value}':
${2:// code...} ${2}
break;${3} break;${3}
snippet for snippet for
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4: // code...} ${4}
} }
snippet foreach snippet foreach
foreach ($${1:variable} as $${2:value}) { foreach ($${1:variable} as $${2:value}) {
${3:// code...} ${3}
} }
snippet foreachil snippet foreachil
<?php foreach ($${1:variable} as $${2:value}): ?> <?php foreach ($${1:variable} as $${2:value}): ?>
@ -314,7 +314,7 @@ snippet foreachil
<?php endforeach; ?> <?php endforeach; ?>
snippet foreachk snippet foreachk
foreach ($${1:variable} as $${2:key} => $${3:value}) { foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...} ${4}
} }
snippet foreachkil snippet foreachkil
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?> <?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
@ -343,6 +343,8 @@ snippet vd
var_dump(${1}); var_dump(${1});
snippet vdd snippet vdd
var_dump(${1}); die(${2:}); var_dump(${1}); die(${2:});
snippet vdf
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');${3}
snippet http_redirect snippet http_redirect
header ("HTTP/1.1 301 Moved Permanently"); header ("HTTP/1.1 301 Moved Permanently");
header ("Location: ".URL); header ("Location: ".URL);
@ -364,7 +366,7 @@ snippet gs
* *
* @param $2 $$1 ${5:description} * @param $2 $$1 ${5:description}
* *
* @return ${6:`Filename()`} * @return ${6:`vim_snippets#Filename()`}
*/ */
public function set$3(${7:$2 }$$1) public function set$3(${7:$2 }$$1)
{ {

View file

@ -65,7 +65,7 @@ snippet for
#loop while #loop while
snippet while snippet while
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:/* code */} ${2}
} }
#break #break
snippet break snippet break
@ -84,11 +84,11 @@ snippet default
snippet switch snippet switch
switch(${1:expression}) { switch(${1:expression}) {
case '${3:case}': case '${3:case}':
${4:// code} ${4}
break; break;
${5} ${5}
default: default:
${2:// code} ${2}
} }
#try #try
snippet try snippet try

View file

@ -55,4 +55,4 @@ snippet log
snippet dec snippet dec
DECIMAL DECIMAL
snippet sep snippet sep
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */

View file

@ -1,15 +1,15 @@
# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540 # Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540
# #
# Please contact R.I.Pienaar <rip@devco.net> for additions and feedback, # Please contact R.I.Pienaar <rip@devco.net> for additions and feedback,
# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php # see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php
# Language Constructs # Language Constructs
snippet class snippet class
class ${1:`Filename('', 'name')`} { class ${1:`vim_snippets#Filename('', 'name')`} {
${2} ${2}
} }
snippet node snippet node
node "${1:`Filename('', 'fqdn')`}" { node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
${2} ${2}
} }
snippet case snippet case
@ -25,8 +25,8 @@ snippet ife
snippet if snippet if
if $${1:variable} { if $${1:variable} {
${2} ${2}
} }
snippet else snippet el
else { else {
${1} ${1}
} }
@ -34,7 +34,7 @@ snippet ?
? { ? {
'${1}' => ${2} '${1}' => ${2}
} }
# #
# blocks etc and general syntax sugar # blocks etc and general syntax sugar
snippet [ snippet [
[ ${1} ]${2} [ ${1} ]${2}
@ -54,7 +54,7 @@ snippet defined
defined(${1:Resource}["${2:name}"])${3} defined(${1:Resource}["${2:name}"])${3}
snippet emerg snippet emerg
emerg("${1:message}")${2} emerg("${1:message}")${2}
snippet extlookup Simple extlookup snippet extlookup Simple extlookup
extlookup("${1:variable}")${2} extlookup("${1:variable}")${2}
snippet extlookup Extlookup with defaults snippet extlookup Extlookup with defaults
extlookup("${1:variable}", "${2:default}")${3} extlookup("${1:variable}", "${2:default}")${3}

View file

@ -2,29 +2,33 @@ snippet #!
#!/usr/bin/env python #!/usr/bin/env python
snippet imp snippet imp
import ${1:module} import ${1:module}
snippet uni
def __unicode__(self):
${1:representation}
snippet from snippet from
from ${1:package} import ${2:module} from ${1:package} import ${2:module}
# Module Docstring # Module Docstring
snippet docs snippet docs
""" """
File: ${1:`Filename('$1.py', 'foo.py')`} File: ${1:`vim_snippets#Filename('$1.py', 'foo.py')`}
Author: `g:snips_author` Author: `g:snips_author`
Email: `g:snips_email` Email: `g:snips_email`
Github: `g:snips_github` Github: `g:snips_github`
Description: ${2} Description: ${2}
""" """
snippet wh snippet wh
while ${1:condition}: while ${1:condition}:
${2:# TODO: write code...} ${2}
# dowh - does the same as do...while in other languages # dowh - does the same as do...while in other languages
snippet dowh snippet dowh
while True: while True:
${1:# TODO: write code...} ${1}
if ${2:condition}: if ${2:condition}:
break break
snippet with snippet with
with ${1:expr} as ${2:var}: with ${1:expr} as ${2:var}:
${3:# TODO: write code...} ${3}
# New Class # New Class
snippet cl snippet cl
class ${1:ClassName}(${2:object}): class ${1:ClassName}(${2:object}):
@ -37,14 +41,14 @@ snippet cl
snippet def snippet def
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
"""${3:docstring for $1}""" """${3:docstring for $1}"""
${4:# TODO: write code...} ${4}
snippet deff snippet deff
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
${3:# TODO: write code...} ${3}
# New Method # New Method
snippet defs snippet defs
def ${1:mname}(self, ${2:arg}): def ${1:mname}(self, ${2:arg}):
${3:# TODO: write code...} ${3}
# New Property # New Property
snippet property snippet property
def ${1:foo}(): def ${1:foo}():
@ -60,17 +64,17 @@ snippet property
# Ifs # Ifs
snippet if snippet if
if ${1:condition}: if ${1:condition}:
${2:# TODO: write code...} ${2}
snippet el snippet el
else: else:
${1:# TODO: write code...} ${1}
snippet ei snippet ei
elif ${1:condition}: elif ${1:condition}:
${2:# TODO: write code...} ${2}
# For # For
snippet for snippet for
for ${1:item} in ${2:items}: for ${1:item} in ${2:items}:
${3:# TODO: write code...} ${3}
# Encodes # Encodes
snippet cutf8 snippet cutf8
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
@ -79,38 +83,38 @@ snippet clatin1
snippet cascii snippet cascii
# -*- coding: ascii -*- # -*- coding: ascii -*-
# Lambda # Lambda
snippet lda snippet ld
${1:var} = lambda ${2:vars} : ${3:action} ${1:var} = lambda ${2:vars} : ${3:action}
snippet . snippet .
self. self.
snippet try Try/Except snippet try Try/Except
try: try:
${1:# TODO: write code...} ${1}
except ${2:Exception}, ${3:e}: except ${2:Exception}, ${3:e}:
${4:raise $3} ${4:raise $3}
snippet try Try/Except/Else snippet try Try/Except/Else
try: try:
${1:# TODO: write code...} ${1}
except ${2:Exception}, ${3:e}: except ${2:Exception}, ${3:e}:
${4:raise $3} ${4:raise $3}
else: else:
${5:# TODO: write code...} ${5}
snippet try Try/Except/Finally snippet try Try/Except/Finally
try: try:
${1:# TODO: write code...} ${1}
except ${2:Exception}, ${3:e}: except ${2:Exception}, ${3:e}:
${4:raise $3} ${4:raise $3}
finally: finally:
${5:# TODO: write code...} ${5}
snippet try Try/Except/Else/Finally snippet try Try/Except/Else/Finally
try: try:
${1:# TODO: write code...} ${1}
except ${2:Exception}, ${3:e}: except ${2:Exception}, ${3:e}:
${4:raise $3} ${4:raise $3}
else: else:
${5:# TODO: write code...} ${5}
finally: finally:
${6:# TODO: write code...} ${6}
# if __name__ == '__main__': # if __name__ == '__main__':
snippet ifmain snippet ifmain
if __name__ == '__main__': if __name__ == '__main__':
@ -127,6 +131,9 @@ snippet ipdb
# ipython debugger (pdbbb) # ipython debugger (pdbbb)
snippet pdbbb snippet pdbbb
import pdbpp; pdbpp.set_trace() import pdbpp; pdbpp.set_trace()
# python console debugger (pudb)
snippet pudb
import pudb; pudb.set_trace()
snippet pprint snippet pprint
import pprint; pprint.pprint(${1})${2} import pprint; pprint.pprint(${1})${2}
snippet " snippet "
@ -136,13 +143,13 @@ snippet "
# test function/method # test function/method
snippet test snippet test
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}): def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
${3:# TODO: write code...} ${3}
# test case # test case
snippet testcase snippet testcase
class ${1:ExampleCase}(unittest.TestCase): class ${1:ExampleCase}(unittest.TestCase):
def test_${2:description}(self): def test_${2:description}(self):
${3:# TODO: write code...} ${3}
snippet fut snippet fut
from __future__ import ${1} from __future__ import ${1}
#getopt #getopt
@ -151,7 +158,7 @@ snippet getopt
# Short option syntax: "hv:" # Short option syntax: "hv:"
# Long option syntax: "help" or "verbose=" # Long option syntax: "help" or "verbose="
opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}]) opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])
except getopt.GetoptError, err: except getopt.GetoptError, err:
# Print debug info # Print debug info
print str(err) print str(err)
@ -169,7 +176,8 @@ snippet glog
logger = logging.getLogger(${1:__name__}) logger = logging.getLogger(${1:__name__})
snippet le snippet le
logger.error(${1:msg}) logger.error(${1:msg})
snippet ld # conflict with lambda=ld, therefor we change into Logger.debuG
snippet lg
logger.debug(${1:msg}) logger.debug(${1:msg})
snippet lw snippet lw
logger.warning(${1:msg}) logger.warning(${1:msg})

View file

@ -12,24 +12,24 @@ snippet source
# conditionals # conditionals
snippet if snippet if
if (${1:condition}) { if (${1:condition}) {
${2:code} ${2}
} }
snippet el snippet el
else { else {
${1:code} ${1}
} }
snippet ei snippet ei
else if (${1:condition}) { else if (${1:condition}) {
${2:code} ${2}
} }
# functions # functions
snippet fun snippet fun
${1:name} = function (${2:variables}) { ${1:name} = function (${2:variables}) {
${3:code} ${3}
} }
snippet ret snippet ret
return(${1:code}) return(${1})
# dataframes, lists, etc # dataframes, lists, etc
snippet df snippet df
@ -117,5 +117,5 @@ snippet cor
cor.test(${1:x}, ${2:y}) cor.test(${1:x}, ${2:y})
snippet fte snippet fte
var.test(${1:x}, ${2:y}) var.test(${1:x}, ${2:y})
snippet kvt snippet kvt
kv.test(${1:x}, ${2:y}) kv.test(${1:x}, ${2:y})

View file

@ -3,9 +3,9 @@
snippet : snippet :
:${1:field name}: ${2:field body} :${1:field name}: ${2:field body}
snippet * snippet *
*${1:Emphasis}* *${1:Emphasis}* ${2}
snippet ** snippet **
**${1:Strong emphasis}** **${1:Strong emphasis}** ${2}
snippet _ snippet _
\`${1:hyperlink-name}\`_ \`${1:hyperlink-name}\`_
.. _\`$1\`: ${2:link-block} .. _\`$1\`: ${2:link-block}
@ -17,6 +17,53 @@ snippet -
${1:Title} ${1:Title}
-----${2:-} -----${2:-}
${3} ${3}
#some directive
snippet img:
.. |${2:alias}| image:: ${1:img}
snippet fig:
.. figure:: ${1:img}
:alt: ${2:alter text}
$2
snippet cont: snippet cont:
.. contents:: .. contents::
${1:content}
snippet code:
.. code:: ${1:type}
${2:write some code}
snippet tip:
.. tip::
${1:my tips}
snippet not:
.. note::
${1:my notes}
snippet war:
.. warning::
${1:attention!}
snippet imp:
.. important::
${1:this is importatnt}
snippet att:
.. attention::
${1:hey!}
snippet dan:
.. danger::
${1:ah!}
snippet err:
.. error::
${1:Error occur}
snippet cau:
.. caution::
${1:Watch out!}
#Spinx only
snippet sid:
.. sidebar:: ${1:Title}
${2}
# CJK optimize, CJK has no space between charaters
snippet *c
\ *${1:Emphasis}*\ ${2}
snippet **c
\ **${1:Strong emphasis}**\ ${2}

View file

@ -16,6 +16,14 @@ snippet =b
=begin rdoc =begin rdoc
${1} ${1}
=end =end
snippet prot
protected
${1}
snippet priv
private
${1}
snippet y snippet y
:yields: ${1:arguments} :yields: ${1:arguments}
snippet rb snippet rb
@ -60,7 +68,7 @@ snippet ife
else else
${3} ${3}
end end
snippet elsif snippet eif
elsif ${1:condition} elsif ${1:condition}
${2} ${2}
snippet unless snippet unless
@ -80,23 +88,23 @@ snippet until
${2} ${2}
end end
snippet cla class .. end snippet cla class .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2} ${2}
end end
snippet cla class .. initialize .. end snippet cla class .. initialize .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
def initialize(${2:args}) def initialize(${2:args})
${3} ${3}
end end
end end
snippet cla class .. < ParentClass .. initialize .. end snippet cla class .. < ParentClass .. initialize .. end
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass} class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass}
def initialize(${3:args}) def initialize(${3:args})
${4} ${4}
end end
end end
snippet cla ClassName = Struct .. do .. end snippet cla ClassName = Struct .. do .. end
${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do
def ${3:method_name} def ${3:method_name}
${4} ${4}
end end
@ -111,7 +119,7 @@ snippet cla class << self .. end
end end
# class .. < DelegateClass .. initialize .. end # class .. < DelegateClass .. initialize .. end
snippet cla- snippet cla-
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < DelegateClass(${2:ParentClass}) class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < DelegateClass(${2:ParentClass})
def initialize(${3:args}) def initialize(${3:args})
super(${4:del_obj}) super(${4:del_obj})
@ -119,17 +127,17 @@ snippet cla-
end end
end end
snippet mod module .. end snippet mod module .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${2} ${2}
end end
snippet mod module .. module_function .. end snippet mod module .. module_function .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module_function module_function
${2} ${2}
end end
snippet mod module .. ClassMethods .. end snippet mod module .. ClassMethods .. end
module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module ClassMethods module ClassMethods
${2} ${2}
end end
@ -156,6 +164,11 @@ snippet atp
attr_protected :${1:attr_names} attr_protected :${1:attr_names}
snippet ata snippet ata
attr_accessible :${1:attr_names} attr_accessible :${1:attr_names}
snippet ana
accepts_nested_attributes_for :${1:association}
# ivc == instance variable cache
snippet ivc
@${1:variable_name} ||= ${2:chached_value}
# include Enumerable # include Enumerable
snippet Enum snippet Enum
include Enumerable include Enumerable
@ -178,6 +191,11 @@ snippet defs
def self.${1:class_method_name} def self.${1:class_method_name}
${2} ${2}
end end
# def initialize
snippet definit
def initialize(${1:args})
${2}
end
# def method_missing # def method_missing
snippet defmm snippet defmm
def method_missing(meth, *args, &blk) def method_missing(meth, *args, &blk)
@ -309,6 +327,12 @@ snippet injd
inject(${1:init}) do |${2:mem}, ${3:var}| inject(${1:init}) do |${2:mem}, ${3:var}|
${4} ${4}
end end
snippet red
reduce(${1:init}) { |${2:mem}, ${3:var}| ${4} }
snippet redd
reduce(${1:init}) do |${2:mem}, ${3:var}|
${4}
end
snippet map snippet map
map { |${1:e}| ${2} } map { |${1:e}| ${2} }
snippet mapd snippet mapd
@ -389,13 +413,17 @@ snippet seld
end end
snippet lam snippet lam
lambda { |${1:args}| ${2} } lambda { |${1:args}| ${2} }
snippet doo # I'm pretty sure that ruby users expect do to expand to do .. end
snippet do
do do
${1} ${1}
end end
# this is for one or more variables. typing a ", " is that cheap that it may
# not be worth adding another snippet. should 0/1 placeholders change order?
# its a good idea to think about the var name, so use it first
snippet dov snippet dov
do |${1:variable}| do |${0:v}|
${2} ${1}
end end
snippet : snippet :
:${1:key} => ${2:"value"}${3} :${1:key} => ${2:"value"}${3}
@ -529,7 +557,7 @@ snippet clafn
snippet sinc snippet sinc
class << self; self end class << self; self end
snippet nam snippet nam
namespace :${1:`Filename()`} do namespace :${1:`vim_snippets#Filename()`} do
${2} ${2}
end end
snippet tas snippet tas
@ -572,8 +600,8 @@ snippet artp
snippet artpp snippet artpp
assert_redirected_to ${1:model}s_path assert_redirected_to ${1:model}s_path
snippet asd snippet asd
assert_difference "${1:Model}.${2:count}", $1 do assert_difference "${1:Model}.${2:count}", ${3:1} do
${3} ${4}
end end
snippet asnd snippet asnd
assert_no_difference "${1:Model}.${2:count}" do assert_no_difference "${1:Model}.${2:count}" do
@ -597,14 +625,14 @@ snippet defcreate
def create def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1]) @${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
respond_to do |wants| respond_to do |format|
if @$1.save if @$1.save
flash[:notice] = '$2 was successfully created.' flash[:notice] = '$2 was successfully created.'
wants.html { redirect_to(@$1) } format.html { redirect_to(@$1) }
wants.xml { render :xml => @$1, :status => :created, :location => @$1 } format.xml { render :xml => @$1, :status => :created, :location => @$1 }
else else
wants.html { render :action => "new" } format.html { render :action => "new" }
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end end
end end
end${3} end${3}
@ -613,9 +641,9 @@ snippet defdestroy
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
@$1.destroy @$1.destroy
respond_to do |wants| respond_to do |format|
wants.html { redirect_to($1s_url) } format.html { redirect_to($1s_url) }
wants.xml { head :ok } format.xml { head :ok }
end end
end${3} end${3}
snippet defedit snippet defedit
@ -626,41 +654,41 @@ snippet defindex
def index def index
@${1:model_class_name} = ${2:ModelClassName}.all @${1:model_class_name} = ${2:ModelClassName}.all
respond_to do |wants| respond_to do |format|
wants.html # index.html.erb format.html # index.html.erb
wants.xml { render :xml => @$1s } format.xml { render :xml => @$1s }
end end
end${3} end${3}
snippet defnew snippet defnew
def new def new
@${1:model_class_name} = ${2:ModelClassName}.new @${1:model_class_name} = ${2:ModelClassName}.new
respond_to do |wants| respond_to do |format|
wants.html # new.html.erb format.html # new.html.erb
wants.xml { render :xml => @$1 } format.xml { render :xml => @$1 }
end end
end${3} end${3}
snippet defshow snippet defshow
def show def show
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |wants| respond_to do |format|
wants.html # show.html.erb format.html # show.html.erb
wants.xml { render :xml => @$1 } format.xml { render :xml => @$1 }
end end
end${3} end${3}
snippet defupdate snippet defupdate
def update def update
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |wants| respond_to do |format|
if @$1.update_attributes(params[:$1]) if @$1.update_attributes(params[:$1])
flash[:notice] = '$2 was successfully updated.' flash[:notice] = '$2 was successfully updated.'
wants.html { redirect_to(@$1) } format.html { redirect_to(@$1) }
wants.xml { head :ok } format.xml { head :ok }
else else
wants.html { render :action => "edit" } format.html { render :action => "edit" }
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end end
end end
end${3} end${3}
@ -733,8 +761,8 @@ snippet ra
snippet ral snippet ral
render :action => "${1:action}", :layout => "${2:layoutname}" render :action => "${1:action}", :layout => "${2:layoutname}"
snippet rest snippet rest
respond_to do |wants| respond_to do |format|
wants.${1:html} { ${2} } format.${1:html} { ${2} }
end end
snippet rf snippet rf
render :file => "${1:filepath}" render :file => "${1:filepath}"
@ -779,7 +807,7 @@ snippet ru
snippet rxml snippet rxml
render :xml => ${1:text to render} render :xml => ${1:text to render}
snippet sc snippet sc
scope :${1:name}, :where(:@${2:field} => ${3:value}) scope :${1:name}, -> { where(${2:field}: ${3:value}) }
snippet sl snippet sl
scope :${1:name}, lambda do |${2:value}| scope :${1:name}, lambda do |${2:value}|
where("${3:field = ?}", ${4:bind var}) where("${3:field = ?}", ${4:bind var})
@ -802,6 +830,85 @@ snippet sweeper
expire_page expire_page
end end
end end
snippet va validates_associated
validates_associated :${1:attribute}
snippet va validates .., :acceptance => true
validates :${1:terms}, :acceptance => true
snippet vc
validates :${1:attribute}, :confirmation => true
snippet ve
validates :${1:attribute}, :exclusion => { :in => ${2:%w( mov avi )} }
snippet vf
validates :${1:attribute}, :format => { :with => /${2:regex}/ }
snippet vi
validates :${1:attribute}, :inclusion => { :in => %w(${2: mov avi }) }
snippet vl
validates :${1:attribute}, :length => { :in => ${2:3}..${3:20} }
snippet vn
validates :${1:attribute}, :numericality => true
snippet vp
validates :${1:attribute}, :presence => true
snippet vu
validates :${1:attribute}, :uniqueness => true
snippet format
format.${1:js|xml|html} { ${2} }
snippet wc
where(${1:"conditions"}${2:, bind_var})
snippet wh
where(${1:field} => ${2:value})
snippet xdelete
xhr :delete, :${1:destroy}, :id => ${2:1}${3}
snippet xget
xhr :get, :${1:show}, :id => ${2:1}${3}
snippet xpost
xhr :post, :${1:create}, :${2:object} => { ${3} }
snippet xput
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5}
snippet test
test "should ${1:do something}" do
${2}
end
###########################
# migrations snippets #
###########################
snippet mac
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
snippet mai
add_index :${1:table_name}, :${2:column_name}
snippet mrc
remove_column :${1:table_name}, :${2:column_name}
snippet mrnc
rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name}
snippet mcc
change_column :${1:table}, :${2:column}, :${3:type}
snippet mnc
t.${1:string} :${2:title}${3:, null: false}${4}
snippet mct
create_table :${1:table_name} do |t|
${2}
end
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
class ${1:class_name} < ActiveRecord::Migration
def up
${2}
end
def down
end
end
snippet migration class .. < ActiveRecord::Migration .. def change .. end
class ${1:class_name} < ActiveRecord::Migration
def change
${2}
end
end
snippet trc
t.remove :${1:column}
snippet tre
t.rename :${1:old_column_name}, :${2:new_column_name}
${3}
snippet tref
t.references :${1:model}
snippet tcb snippet tcb
t.boolean :${1:title} t.boolean :${1:title}
${2} ${2}
@ -847,98 +954,17 @@ snippet tcts
snippet tctss snippet tctss
t.timestamps t.timestamps
${1} ${1}
snippet va ##########################
validates_associated :${1:attribute} # Rspec snippets #
snippet vao ##########################
validates_acceptance_of :${1:terms}
snippet vc
validates_confirmation_of :${1:attribute}
snippet ve
validates_exclusion_of :${1:attribute}, :in => ${2:%w( mov avi )}
snippet vf
validates_format_of :${1:attribute}, :with => /${2:regex}/
snippet vi
validates_inclusion_of :${1:attribute}, :in => %w(${2: mov avi })
snippet vl
validates_length_of :${1:attribute}, :within => ${2:3}..${3:20}
snippet vn
validates_numericality_of :${1:attribute}
snippet vpo
validates_presence_of :${1:attribute}
snippet vu
validates_uniqueness_of :${1:attribute}
snippet wants
wants.${1:js|xml|html} { ${2} }
snippet wc
where(${1:"conditions"}${2:, bind_var})
snippet wh
where(${1:field} => ${2:value})
snippet xdelete
xhr :delete, :${1:destroy}, :id => ${2:1}${3}
snippet xget
xhr :get, :${1:show}, :id => ${2:1}${3}
snippet xpost
xhr :post, :${1:create}, :${2:object} => { ${3} }
snippet xput
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5}
snippet test
test "should ${1:do something}" do
${2}
end
#migrations
snippet mac
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
snippet mrc
remove_column :${1:table_name}, :${2:column_name}
snippet mrnc
rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name}
snippet mcc
change_column :${1:table}, :${2:column}, :${3:type}
snippet mnc
t.${1:string} :${2:title}${3:, null: false}${4}
snippet mct
create_table :${1:table_name} do |t|
${2}
end
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
class ${1:class_name} < ActiveRecord::Migration
def up
${2}
end
def down
end
end
snippet migration class .. < ActiveRecord::Migration .. def change .. end
class ${1:class_name} < ActiveRecord::Migration
def change
${2}
end
end
snippet trc
t.remove :${1:column}
snippet tre
t.rename :${1:old_column_name}, :${2:new_column_name}
${3}
snippet tref
t.references :${1:model}
#rspec
snippet it
it "${1:spec_name}" do
${2}
end
snippet itp
it "${1:spec_name}"
${2}
snippet its
its(:${1:method}) { should ${2} }
snippet itsn
its(:${1:method}) { should_not ${2} }
snippet desc snippet desc
describe ${1:class_name} do describe ${1:class_name} do
${2} ${2}
end end
snippet descm
describe "${1:#method}" do
${2:pending "Not implemented"}
end
snippet cont snippet cont
context "${1:message}" do context "${1:message}" do
${2} ${2}
@ -952,22 +978,101 @@ snippet aft
${2} ${2}
end end
snippet let snippet let
let(:${1:object}) ${2:block} let(:${1:object}) ${2}
snippet let! snippet let!
let!(:${1:object}) ${2:block} let!(:${1:object}) ${2}
snippet subj snippet subj
subject { ${1} } subject { ${1} }
snippet s.
subject.${1:method}
snippet spec snippet spec
specify { subject.${1} } specify { subject.${1} }
snippet exp snippet exp
expect(${1:object}).to ${2} expect { ${1:object} }.to ${2}
snippet btr snippet raise
be_true expect { ${1:object} }.to raise_error ${2:StandardError}, /${3:message_regex}/
snippet bfa
be_false
snippet shared snippet shared
shared_examples "${1:shared examples name}" ${2} shared_examples ${1:"shared examples name"}
snippet itb snippet ibl
it_behaves_like "${1:shared examples name}"${2} it_behaves_like ${1:"shared examples name"}
snippet ana snippet it
accepts_nested_attributes_for :${1:association} it "${1:spec_name}" do
${2}
end
snippet its
its(:${1:method}) { should ${2} }
snippet is
it { should ${1} }
snippet isn
it { should_not ${1} }
#ShouldaMatchers#ActionController
snippet isfp
it { should filter_param :${1:key} }
snippet isrt
it { should redirect_to ${1:url} }
snippet isrtp
it { should render_template ${1} }
snippet isrwl
it { should render_with_layout ${1} }
snippet isrf
it { should rescue_from ${1:exception} }
snippet isrw
it { should respond_with ${1:status} }
snippet isr
it { should route(:${1:method}, '${2:path}') }
snippet isss
it { should set_session :${1:key} }
snippet issf
it { should set_the_flash('${1}') }
#ShouldaMatchers#ActiveModel
snippet isama
it { should allow_mass_assignment_of :${1} }
snippet isav
it { should allow_value(${1}).for :${2} }
snippet isee
it { should ensure_exclusion_of :${1} }
snippet isei
it { should ensure_inclusion_of :${1} }
snippet isel
it { should ensure_length_of :${1} }
snippet isva
it { should validate_acceptance_of :${1} }
snippet isvc
it { should validate_confirmation_of :${1} }
snippet isvn
it { should validate_numericality_of :${1} }
snippet isvp
it { should validate_presence_of :${1} }
snippet isvu
it { should validate_uniqueness_of :${1} }
#ShouldaMatchers#ActiveRecord
snippet isana
it { should accept_nested_attributes_for :${1} }
snippet isbt
it { should belong_to :${1} }
snippet isbtcc
it { should belong_to(:${1}).counter_cache ${2:true} }
snippet ishbtm
it { should have_and_belong_to_many :${1} }
snippet isbv
it { should be_valid }${1}
snippet ishc
it { should have_db_column :${1} }
snippet ishi
it { should have_db_index :${1} }
snippet ishm
it { should have_many :${1} }
snippet ishmt
it { should have_many(:${1}).through :${2} }
snippet isho
it { should have_one :${1} }
snippet ishro
it { should have_readonly_attribute :${1} }
snippet iss
it { should serialize :${1} }
snippet isres
it { should respond_to :${1} }
snippet isresw
it { should respond_to(:${1}).with(${2}).arguments }
snippet super_call
${1:super_class}.instance_method(:${2:method}).bind(self).call

View file

@ -7,61 +7,65 @@
#if #if
snippet if snippet if
if(${1:obj}) { if(${1:obj}) {
${2:/* code */} ${2}
} }
#if not #if not
snippet ifn snippet ifn
if(!${1:obj}) { if(!${1:obj}) {
${2:/* code */} ${2}
} }
#if-else #if-else
snippet ifel snippet ife
if(${1:obj}) { if(${1:obj}) {
${2:/* code */} ${2}
} else { } else {
${3:/* code */} ${3}
} }
#if-else-if #if-else-if
snippet ifelif snippet ifelif
if(${1:obj}) { if(${1:obj}) {
${2:/* code */} ${2}
} else if(${3:obj}) { } else if(${3:obj}) {
${4:/* code */} ${4}
}
snippet eif
else if(${3:obj}) {
${4}
} }
#while loop #while loop
snippet while snippet while
while (${1:obj}) { while (${1:obj}) {
${2:/* code */} ${2}
} }
#for loop(classic) #for loop(classic)
snippet for snippet for
for (${1:item} <- ${2:obj}) { for (${1:item} <- ${2:obj}) {
${3:/* code */} ${3}
} }
#for loop(indexed) #for loop(indexed)
snippet fori snippet fori
for (${1:i} <- ${2:0} to ${3:obj}.length) { for (${1:i} <- ${2:0} to ${3:obj}.length) {
${4:/* code */} ${4}
} }
#exceptions #exceptions
snippet try snippet try
try { try {
${1:/* code */} ${1}
} catch { } catch {
case e: FileNotFoundException => ${2:/* code */} case e: FileNotFoundException => ${2}
case e: IOException => ${3:/* code */} case e: IOException => ${3}
} finally { } finally {
${4:/* code */} ${4}
} }
#match #match
snippet match snippet match
${1: obj} match { ${1: obj} match {
case ${2:e} => ${3:/* code */} case ${2:e} => ${3}
case _ => ${4:/* code */} case _ => ${4}
} }
#case #case
snippet case snippet case
case ${1:value} => ${2:/* code */} case ${1:value} => ${2}
############################ ############################
# methods and arguments # methods and arguments
# #
@ -82,9 +86,9 @@ snippet ovdef
override def ${1:name}(${2:arg}) = ${3:} override def ${1:name}(${2:arg}) = ${3:}
#first class function(see scalabook p 188) #first class function(see scalabook p 188)
snippet fcf snippet fcf
(${1:a}: ${2:T}) => $1 ${3:/* code */} (${1:a}: ${2:T}) => $1 ${3}
snippet => snippet =>
${1:name} => ${2:/* code */} ${1:name} => ${2}
#recursion #recursion
snippet rec snippet rec
def ${1:name}(${2:arg}) = def ${1:name}(${2:arg}) =
@ -196,11 +200,11 @@ snippet as
#scope() with one arg #scope() with one arg
snippet (a snippet (a
(${1:a} => ${2:/* code */}) (${1:a} => ${2})
#scope() with two args #scope() with two args
snippet {( snippet {(
{(${1:a},${2:b}) => {(${1:a},${2:b}) =>
${3:/* code */} ${3}
} }
#filter #filter
snippet filter snippet filter
@ -220,10 +224,10 @@ snippet fldr
#fold left operator(if u wanna reduce readability of ur code) #fold left operator(if u wanna reduce readability of ur code)
#use wildcard symbols #use wildcard symbols
snippet /: snippet /:
(${1:first}/:${2:name})(${3:/* code */}) (${1:first}/:${2:name})(${3})
#fold right operator #fold right operator
snippet :\ snippet :\
(${1:first}:\${2:name})(${3:/* code */}) (${1:first}:\${2:name})(${3})
#reduce left #reduce left
snippet redl snippet redl
${1:name}.reduceLeft[${2:T}] {( ${1:name}.reduceLeft[${2:T}] {(
@ -258,13 +262,13 @@ snippet athis
snippet abstract snippet abstract
abstract class ${1:name}${2:(arg)}${3: extends }${4: with} { abstract class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"} ${5:override def toString = "$1"}
${6:/* code */} ${6}
} }
#class #class
snippet class snippet class
class ${1:name}${2:(arg)}${3: extends }${4: with} { class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"} ${5:override def toString = "$1"}
${6:/* code */} ${6}
} }
#object #object
snippet object snippet object
@ -279,7 +283,7 @@ snippet ordered
class ${1:name}${2:(arg)} extends Ordered[$1] ${3: with} { class ${1:name}${2:(arg)} extends Ordered[$1] ${3: with} {
${4:override def toString = "$1"} ${4:override def toString = "$1"}
def compare(that: $1) = ${5:this - that} def compare(that: $1) = ${5:this - that}
${6:/* code */} ${6}
} }
#case class #case class
snippet casecl snippet casecl

View file

@ -1,7 +1,7 @@
# Shebang. Executing bash via /usr/bin/env makes scripts more portable. # Shebang. Executing bash via /usr/bin/env makes scripts more portable.
snippet #! snippet #!
#!/usr/bin/env bash #!/usr/bin/env bash
snippet if snippet if
if [[ ${1:condition} ]]; then if [[ ${1:condition} ]]; then
${2:#statements} ${2:#statements}
@ -30,9 +30,9 @@ snippet case
${2:pattern}) ${2:pattern})
${3};; ${3};;
esac esac
snippet go snippet go
while getopts '${1:o}' ${2:opts} while getopts '${1:o}' ${2:opts}
do do
case $$2 in case $$2 in
${3:o0}) ${3:o0})
${4:#staments};; ${4:#staments};;
@ -53,9 +53,9 @@ snippet getopt
{ {
cat <<- EOT cat <<- EOT
Usage : $${0:0} [options] [--] Usage : $${0:0} [options] [--]
Options: Options:
-h|help Display this message -h|help Display this message
-v|version Display script version -v|version Display script version
@ -80,7 +80,5 @@ snippet getopt
esac # --- end of case --- esac # --- end of case ---
done done
shift $(($OPTIND-1)) shift $(($OPTIND-1))
snippet root snippet root
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi if [ $(id -u) -ne 0 ]; then exec sudo $0; fi

View file

@ -1,11 +1,11 @@
# #!/usr/bin/env tclsh # #!/usr/bin/env tclsh
snippet #! snippet #!
#!/usr/bin/env tclsh #!/usr/bin/env tclsh
# Process # Process
snippet pro snippet pro
proc ${1:function_name} {${2:args}} { proc ${1:function_name} {${2:args}} {
${3:#body ...} ${3}
} }
#xif #xif
snippet xif snippet xif
@ -13,19 +13,23 @@ snippet xif
# Conditional # Conditional
snippet if snippet if
if {${1}} { if {${1}} {
${2:# body...} ${2}
} }
# Conditional if..else # Conditional if..else
snippet ife snippet ife
if {${1}} { if {${1}} {
${2:# body...} ${2}
} else { } else {
${3:# else...} ${3:# else...}
} }
snippet eif
elseif {${1}} {
${2}
}
# Conditional if..elsif..else # Conditional if..elsif..else
snippet ifee snippet ifee
if {${1}} { if {${1}} {
${2:# body...} ${2}
} elseif {${3}} { } elseif {${3}} {
${4:# elsif...} ${4:# elsif...}
} else { } else {
@ -42,17 +46,17 @@ snippet catch
# While Loop # While Loop
snippet wh snippet wh
while {${1}} { while {${1}} {
${2:# body...} ${2}
} }
# For Loop # For Loop
snippet for snippet for
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
${4:# body...} ${4}
} }
# Foreach Loop # Foreach Loop
snippet fore snippet fore
foreach ${1:x} {${2:#list}} { foreach ${1:x} {${2:#list}} {
${3:# body...} ${3}
} }
# after ms script... # after ms script...
snippet af snippet af

View file

@ -1,16 +1,16 @@
#PREAMBLE #PREAMBLE
#newcommand #newcommand
snippet nc snippet nc
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}}${4} \newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}} ${4}
#usepackage #usepackage
snippet up snippet up
\usepackage[${1:[options}]{${2:package}} \usepackage[${1:options}]{${2:package}} ${3}
#newunicodechar #newunicodechar
snippet nuc snippet nuc
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} \newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${4}
#DeclareMathOperator #DeclareMathOperator
snippet dmo snippet dmo
\DeclareMathOperator{${1}}{${2}} \DeclareMathOperator{${1}}{${2}} ${3}
#DOCUMENT #DOCUMENT
# \begin{}...\end{} # \begin{}...\end{}
@ -26,7 +26,7 @@ snippet tab
snippet thm snippet thm
\begin[${1:author}]{${2:thm}} \begin[${1:author}]{${2:thm}}
${3} ${3}
\end{$1} \end{$2}
snippet center snippet center
\begin{center} \begin{center}
${1} ${1}
@ -56,6 +56,11 @@ snippet \
\[ \[
${1} ${1}
\] \]
# Equation array
snippet eqnarray
\begin{eqnarray}
${1}
\end{eqnarray}
# Enumerate # Enumerate
snippet enum snippet enum
\begin{enumerate} \begin{enumerate}
@ -66,11 +71,17 @@ snippet itemize
\begin{itemize} \begin{itemize}
\item ${1} \item ${1}
\end{itemize} \end{itemize}
snippet item
\item ${1}
# Description # Description
snippet desc snippet desc
\begin{description} \begin{description}
\item[${1}] ${2} \item[${1}] ${2}
\end{description} \end{description}
# Endless new item
snippet ]i
\item ${1}
${2:]i}
# Matrix # Matrix
snippet mat snippet mat
\begin{${1:p/b/v/V/B/small}matrix} \begin{${1:p/b/v/V/B/small}matrix}
@ -103,16 +114,31 @@ snippet sec
\section{${1:section name}} \section{${1:section name}}
\label{sec:${2:$1}} \label{sec:${2:$1}}
${3} ${3}
# Section without number
snippet sec*
\section*{${1:section name}}
\label{sec:${2:$1}}
${3}
# Sub Section # Sub Section
snippet sub snippet sub
\subsection{${1:subsection name}} \subsection{${1:subsection name}}
\label{sub:${2:$1}} \label{sub:${2:$1}}
${3} ${3}
# Sub Section without number
snippet sub*
\subsection*{${1:subsection name}}
\label{sub:${2:$1}}
${3}
# Sub Sub Section # Sub Sub Section
snippet subs snippet subs
\subsubsection{${1:subsubsection name}} \subsubsection{${1:subsubsection name}}
\label{ssub:${2:$1}} \label{ssub:${2:$1}}
${3} ${3}
# Sub Sub Section without number
snippet subs*
\subsubsection*{${1:subsubsection name}}
\label{ssub:${2:$1}}
${3}
# Paragraph # Paragraph
snippet par snippet par
\paragraph{${1:paragraph name}} \paragraph{${1:paragraph name}}
@ -123,6 +149,9 @@ snippet subp
\subparagraph{${1:subparagraph name}} \subparagraph{${1:subparagraph name}}
\label{subp:${2:$1}} \label{subp:${2:$1}}
${3} ${3}
snippet ni
\noindent
${1}
#References #References
snippet itd snippet itd
\item[${1:description}] ${2:item} \item[${1:description}] ${2:item}
@ -133,14 +162,21 @@ snippet table
snippet listing snippet listing
${1:Listing}~\ref{${2:list}}${3} ${1:Listing}~\ref{${2:list}}${3}
snippet section snippet section
${1:Section}~\ref{${2:sec:}}${3} ${1:Section}~\ref{sec:${2}} ${3}
snippet page snippet page
${1:page}~\pageref{${2}}${3} ${1:page}~\pageref{${2}} ${3}
snippet index snippet index
\index{${1:index}}${2} \index{${1:index}} ${2}
#Citations #Citations
snippet citen
\cite{$1} ${2}
# bibtex commands
snippet citep
\citep{$1} ${2}
snippet citet
\citet{$1} ${2}
snippet cite snippet cite
\cite[${1}]{${2}}${3} \cite[${1}]{${2}} ${3}
snippet fcite snippet fcite
\footcite[${1}]{${2}}${3} \footcite[${1}]{${2}}${3}
#Formating text: italic, bold, underline, small capital, emphase .. #Formating text: italic, bold, underline, small capital, emphase ..
@ -172,6 +208,7 @@ snippet fig
\caption{${3}} \caption{${3}}
\label{fig:${4}} \label{fig:${4}}
\end{figure} \end{figure}
${5}
snippet tikz snippet tikz
\begin{figure} \begin{figure}
\begin{center} \begin{center}
@ -182,10 +219,40 @@ snippet tikz
\caption{${3}} \caption{${3}}
\label{fig:${4}} \label{fig:${4}}
\end{figure} \end{figure}
${5}
#math #math
snippet stackrel snippet stackrel
\stackrel{${1:above}}{${2:below}} ${3} \stackrel{${1:above}}{${2:below}} ${3}
snippet frac snippet frac
\frac{${1:num}}{${2:denom}} \frac{${1:num}}{${2:denom}} ${3}
snippet sum snippet sum
\sum^{${1:n}}_{${2:i=1}}{${3}} \sum^{${1:n}}_{${2:i=1}} ${3}
snippet lim
\lim_{${1:x \to +\infty}} ${2}
snippet frame
\begin{frame}[<+->]
\frametitle{${1:title}}
${2}
\end{frame}
snippet block
\begin{block}{${1:title}}
${2}
\end{block}
snippet alert
\begin{alertblock}{${1:title}}
${2}
\end{alertblock}
snippet example
\begin{exampleblock}{${1:title}}
${2}
\end{exampleblock}
snippet col2
\begin{columns}
\begin{column}{0.5\textwidth}
${1}
\end{column}
\begin{column}{0.5\textwidth}
${2}
\end{column}
\end{columns}

View file

@ -27,4 +27,4 @@ snippet fn
[${1:ref number}] ${3} [${1:ref number}] ${3}
fn$1. ${2:footnote} fn$1. ${2:footnote}

View file

@ -4,13 +4,13 @@ snippet header
" Description: ${3} " Description: ${3}
${4:" Last Modified: `strftime("%B %d, %Y")`} ${4:" Last Modified: `strftime("%B %d, %Y")`}
snippet guard snippet guard
if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
finish finish
endif endif
let $1 = 1${3} let $1 = 1${3}
snippet f snippet f
fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3}) fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3})
${4:" code} ${4}
endf endf
snippet t snippet t
try try
@ -19,19 +19,25 @@ snippet t
${3} ${3}
endtry endtry
snippet for snippet for
for ${1:needle} in ${2:haystack} for ${1} in ${2}
${3:" code} ${3}
endfor endfor
snippet forkv
for [${1},${2}] in items(${3})
${4}
unlet $1 $2
endfor
snippet wh snippet wh
while ${1:condition} while ${1}
${2:" code} ${2}
endw endw
snippet if snippet if
if ${1:condition} if ${1}
${2:" code} ${2}
endif endif
snippet ife snippet ife
if ${1:condition} if ${1}
${2} ${2}
else else
${3} ${3}

View file

@ -50,7 +50,7 @@ snippet import
snippet include snippet include
<xsl:include href="${1:stylesheet}" />${2} <xsl:include href="${1:stylesheet}" />${2}
snippet otherwise snippet otherwise
<xsl:otherwise>${1} <xsl:otherwise>${1}
</xsl:otherwise> </xsl:otherwise>
@ -64,7 +64,7 @@ snippet stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${1} xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${1}
</xsl:stylesheet> </xsl:stylesheet>
snippet template snippet template
<xsl:template match="${1:*}">${3} <xsl:template match="${1:*}">${3}
</xsl:template> </xsl:template>
@ -91,7 +91,7 @@ snippet when
snippet with-param snippet with-param
<xsl:with-param name="${1:name}">${2}</xsl:with-param> <xsl:with-param name="${1:name}">${2}</xsl:with-param>
snippet with-param select snippet with-param select
<xsl:with-param name="${1:name}" select="${2:*}" /> <xsl:with-param name="${1:name}" select="${2:*}" />

View file

@ -1,59 +1,59 @@
#--------------------Yii CHtml--------------------------------- #--------------------Yii CHtml---------------------------------
#Yii CHtml::radioButton #Yii CHtml::radioButton
snippet yhrb snippet yhrb
echo CHtml::radioButton('${1:name}', ${2:false},array(${3:optionName}=>${4:optionValue} ); echo CHtml::radioButton('${1:name}', ${2:false},array(${3:optionName}=>${4:optionValue} );
#Yii CHtml::asset #Yii CHtml::asset
snippet yhass snippet yhass
echo CHtml::asset('${1:path}'); echo CHtml::asset('${1:path}');
#Yii CHtml::activeLabelEx #Yii CHtml::activeLabelEx
snippet yhale snippet yhale
echo CHtml::activeLabelEx(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeLabelEx(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::encodeArray #Yii CHtml::encodeArray
snippet yheca snippet yheca
echo CHtml::encodeArray(array(${1})); echo CHtml::encodeArray(array(${1}));
#Yii CHtml::normalizeUrl #Yii CHtml::normalizeUrl
snippet yhnurl snippet yhnurl
echo CHtml::normalizeUrl(array('${1}')); echo CHtml::normalizeUrl(array('${1}'));
#Yii CHtml::resetButton #Yii CHtml::resetButton
snippet yhsb snippet yhsb
echo CHtml::submitButton('${1:label}',array('${2:optionName}'=>${3:optionValue})); echo CHtml::submitButton('${1:label}',array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::linkButton #Yii CHtml::linkButton
snippet yhlinkb snippet yhlinkb
echo CHtml::linkButton('${1:lable}',array('${2:optionName}'=>${3:optionValue})); echo CHtml::linkButton('${1:lable}',array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::activeTextArea #Yii CHtml::activeTextArea
snippet yhata snippet yhata
echo CHtml::activeTextArea(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeTextArea(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::ajaxButton #Yii CHtml::ajaxButton
snippet yhajb snippet yhajb
echo CHtml::ajaxButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); echo CHtml::ajaxButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
#Yii CHtml::activeId #Yii CHtml::activeId
snippet yhai snippet yhai
echo CHtml::activeId(${1:model}, '${2:attribute}'); echo CHtml::activeId(${1:model}, '${2:attribute}');
#Yii CHtml::activeCheckBox #Yii CHtml::activeCheckBox
snippet yhacb snippet yhacb
echo CHtml::activeCheckBox(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeCheckBox(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeHiddenField #Yii CHtml::activeHiddenField
snippet yhahf snippet yhahf
echo CHtml::activeHiddenField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeHiddenField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::encode #Yii CHtml::encode
snippet yhec snippet yhec
echo CHtml::encode(${1:text}); echo CHtml::encode(${1:text});
#Yii CHtml::metaTag #Yii CHtml::metaTag
snippet yhmtag snippet yhmtag
echo CHtml::metaTag('${1:content}', '${2:name}', '${3:httpEquiv}',array('${4:optionName}'=>${5:optionValue})); echo CHtml::metaTag('${1:content}', '${2:name}', '${3:httpEquiv}',array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::dropDownList #Yii CHtml::dropDownList
snippet yhddl snippet yhddl
@ -61,167 +61,167 @@ snippet yhddl
#Yii CHtml::listBox #Yii CHtml::listBox
snippet yhlb snippet yhlb
echo CHtml::listBox('${1:name}', '${2:select}',array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::listBox('${1:name}', '${2:select}',array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::script #Yii CHtml::script
snippet yhjs snippet yhjs
echo CHtml::script('${1:test}'); echo CHtml::script('${1:test}');
#Yii CHtml::ajax #Yii CHtml::ajax
snippet yhaj snippet yhaj
echo CHtml::ajax(array(${1})); echo CHtml::ajax(array(${1}));
#Yii CHtml::textField #Yii CHtml::textField
snippet yhtf snippet yhtf
echo CHtml::textField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::textField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activePasswordField #Yii CHtml::activePasswordField
snippet yhapf snippet yhapf
echo CHtml::activePasswordField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activePasswordField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::listData #Yii CHtml::listData
snippet yhld snippet yhld
echo CHtml::listData(array(${1}),'${2:valueField}', '${3:textField}','${4:groupField}'); echo CHtml::listData(array(${1}),'${2:valueField}', '${3:textField}','${4:groupField}');
#Yii CHtml::mailto #Yii CHtml::mailto
snippet yhmt snippet yhmt
echo CHtml::mailto('${1:text}', '${2:email}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::mailto('${1:text}', '${2:email}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::image #Yii CHtml::image
snippet yhimg snippet yhimg
echo CHtml::image('${1:src}', '${2:alt}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::image('${1:src}', '${2:alt}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeListBox #Yii CHtml::activeListBox
snippet yhalb snippet yhalb
echo CHtml::activeListBox(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::activeListBox(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::activeFileField #Yii CHtml::activeFileField
snippet yhaff snippet yhaff
echo CHtml::activeFileField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeFileField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::closeTag #Yii CHtml::closeTag
snippet yhct snippet yhct
echo CHtml::closeTag('${1:tag}'); echo CHtml::closeTag('${1:tag}');
#Yii CHtml::activeInputField #Yii CHtml::activeInputField
snippet yhaif snippet yhaif
echo CHtml::activeInputField('${1:type}', ${2:model}, '${3:attribute}',array('${4:optionName}'=>${5:optionValue})); echo CHtml::activeInputField('${1:type}', ${2:model}, '${3:attribute}',array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::scriptFile #Yii CHtml::scriptFile
snippet yhjsf snippet yhjsf
echo CHtml::scriptFile('${1:url}'); echo CHtml::scriptFile('${1:url}');
#Yii CHtml::radioButtonList #Yii CHtml::radioButtonList
snippet yhrbl snippet yhrbl
echo CHtml::radioButtonList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::radioButtonList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::cssFile #Yii CHtml::cssFile
snippet yhcssf snippet yhcssf
echo CHtml::cssFile('${1:url}','${2:media}'); echo CHtml::cssFile('${1:url}','${2:media}');
#Yii CHtml::error #Yii CHtml::error
snippet yherr snippet yherr
echo CHtml::error(${1:model}, '${2:attribute}'); echo CHtml::error(${1:model}, '${2:attribute}');
#Yii CHtml::passwordField #Yii CHtml::passwordField
snippet yhpf snippet yhpf
echo CHtml::passwordField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::passwordField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::hiddenField #Yii CHtml::hiddenField
snippet yhhf snippet yhhf
echo CHtml::hiddenField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::hiddenField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::cdata #Yii CHtml::cdata
snippet yhc snippet yhc
echo CHtml::cdata(${1:text}); echo CHtml::cdata(${1:text});
#Yii CHtml::link #Yii CHtml::link
snippet yhlink snippet yhlink
echo CHtml::link('${1:text}',array(${2}),array('${3:optionName}'=>${4:optionValue})); echo CHtml::link('${1:text}',array(${2}),array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::errorSummary #Yii CHtml::errorSummary
snippet yherrs snippet yherrs
echo CHtml::errorSummary(${1:model},'${2:headerHtml}','${3:footerHtml}'); echo CHtml::errorSummary(${1:model},'${2:headerHtml}','${3:footerHtml}');
#Yii CHtml::tag #Yii CHtml::tag
snippet yht snippet yht
echo CHtml::tag('${1:tag}',array('${2:optionName}'=>${3:optionValue}),${4:false},${5:true}); echo CHtml::tag('${1:tag}',array('${2:optionName}'=>${3:optionValue}),${4:false},${5:true});
#Yii CHtml::ajaxLink #Yii CHtml::ajaxLink
snippet yhajl snippet yhajl
echo CHtml::ajaxLink('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); echo CHtml::ajaxLink('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
#Yii CHtml::label #Yii CHtml::label
snippet yhlabel snippet yhlabel
echo CHtml::label('${1:label}', '${2:for}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::label('${1:label}', '${2:for}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeName #Yii CHtml::activeName
snippet yhan snippet yhan
echo CHtml::activeName(${1:model}, '${2:attribute}'); echo CHtml::activeName(${1:model}, '${2:attribute}');
#Yii CHtml::statefulForm #Yii CHtml::statefulForm
snippet yhsform snippet yhsform
echo CHtml::statefulForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::statefulForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::fileField #Yii CHtml::fileField
snippet yhff snippet yhff
echo CHtml::fileField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::fileField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeTextField #Yii CHtml::activeTextField
snippet yhatf snippet yhatf
echo CHtml::activeTextField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeTextField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::css #Yii CHtml::css
snippet yhcss snippet yhcss
echo CHtml::css('${1:test}','${2:media}'); echo CHtml::css('${1:test}','${2:media}');
#Yii CHtml::imageButton #Yii CHtml::imageButton
snippet yhimgb snippet yhimgb
echo CHtml::imageButton('${1:src}',array('${2:optionName}'=>${3:optionValue})); echo CHtml::imageButton('${1:src}',array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::ajaxSubmitButton #Yii CHtml::ajaxSubmitButton
snippet yhajsb snippet yhajsb
echo CHtml::ajaxSubmitButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); echo CHtml::ajaxSubmitButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
#Yii CHtml::button #Yii CHtml::button
snippet yhb snippet yhb
echo CHtml::button('${1:label}',array('${2:optionName}'=>${3:optionValue})); echo CHtml::button('${1:label}',array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::listOptions #Yii CHtml::listOptions
snippet yhlo snippet yhlo
echo CHtml::listOptions('${1:selection}', array(${2}), array('${3:optionName}'=>${4:optionValue})); echo CHtml::listOptions('${1:selection}', array(${2}), array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeCheckBoxList #Yii CHtml::activeCheckBoxList
snippet yhacbl snippet yhacbl
echo CHtml::activeCheckBoxList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::activeCheckBoxList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::openTag #Yii CHtml::openTag
snippet yhot snippet yhot
echo CHtml::openTag('${1:tag}', array('${2:optionName}'=>${3:optionValue})); echo CHtml::openTag('${1:tag}', array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::checkBox #Yii CHtml::checkBox
snippet yhcb snippet yhcb
echo CHtml::checkBox('${1:name}', ${2:false}, array('${3:optionName}'=>${4:optionValue})); echo CHtml::checkBox('${1:name}', ${2:false}, array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::textArea #Yii CHtml::textArea
snippet yhta snippet yhta
echo CHtml::textArea('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::textArea('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::linkTag #Yii CHtml::linkTag
snippet yhlinkt snippet yhlinkt
echo CHtml::linkTag('${1:relation}', '${2:type}', '${3:href}', '${4:media}',array('${5:optionName}'=>${6:optionValue})); echo CHtml::linkTag('${1:relation}', '${2:type}', '${3:href}', '${4:media}',array('${5:optionName}'=>${6:optionValue}));
#Yii CHtml::resetButton #Yii CHtml::resetButton
snippet yhrsb snippet yhrsb
echo CHtml::resetButton('${1:label}',array('${2:optionName}'=>${3:optionValue})); echo CHtml::resetButton('${1:label}',array('${2:optionName}'=>${3:optionValue}));
#Yii CHtml::activeRadioButtonList #Yii CHtml::activeRadioButtonList
snippet yharbl snippet yharbl
echo CHtml::activeRadioButtonList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::activeRadioButtonList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::checkBoxList #Yii CHtml::checkBoxList
snippet yhcbl snippet yhcbl
echo CHtml::checkBoxList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::checkBoxList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::form #Yii CHtml::form
snippet yhform snippet yhform
@ -231,18 +231,18 @@ snippet yhform
snippet yhbeform snippet yhbeform
echo CHtml::beginForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::beginForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue}));
${5} ${5}
echo CHtml::endForm(); echo CHtml::endForm();
#Yii CHtml::activeDropDownList #Yii CHtml::activeDropDownList
snippet yhaddl snippet yhaddl
echo CHtml::activeDropDownList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); echo CHtml::activeDropDownList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
#Yii CHtml::activeRadioButton #Yii CHtml::activeRadioButton
snippet yharb snippet yharb
echo CHtml::activeRadioButton(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeRadioButton(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
#Yii CHtml::activeLabel #Yii CHtml::activeLabel
snippet yhal snippet yhal
echo CHtml::activeLabel(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); echo CHtml::activeLabel(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));

View file

@ -1,58 +1,58 @@
#Yii session offset #Yii session offset
snippet yse snippet yse
Yii::app()->session['${1}']; Yii::app()->session['${1}'];
#Yii renderDynamic #Yii renderDynamic
snippet yrd snippet yrd
$this->renderDynamic('${1:callback}'); $this->renderDynamic('${1:callback}');
#Yii set cache #Yii set cache
snippet ycas snippet ycas
Yii::app()->cache->set('${1:key}', ${2:value}, ${3:expire}, new C${4:}CacheDependency(${5})); Yii::app()->cache->set('${1:key}', ${2:value}, ${3:expire}, new C${4:}CacheDependency(${5}));
#Yii Add cache #Yii Add cache
snippet ycad snippet ycad
Yii::app()->cache->add('${1:key}', ${2:value}, ${3:expire}, new C${4}CacheDependency(${5})); Yii::app()->cache->add('${1:key}', ${2:value}, ${3:expire}, new C${4}CacheDependency(${5}));
#Yii register CSS file #Yii register CSS file
snippet yregcf snippet yregcf
Yii::app()->clientScript->registerCssFile('${1:file}'); Yii::app()->clientScript->registerCssFile('${1:file}');
#Yii requestType #Yii requestType
snippet yreqtype snippet yreqtype
Yii::app()->request->requestType Yii::app()->request->requestType
#Yii isAjaxRequest #Yii isAjaxRequest
snippet yisajax snippet yisajax
Yii::app()->request->isAjaxRequest Yii::app()->request->isAjaxRequest
#Yii translate #Yii translate
snippet yt snippet yt
Yii::t('${1:category}', '${2:message}',array(${3})); Yii::t('${1:category}', '${2:message}',array(${3}));
#Yii register CSS #Yii register CSS
snippet yregc snippet yregc
Yii::app()->clientScript->registerCss('${1:id}', '${2}'); Yii::app()->clientScript->registerCss('${1:id}', '${2}');
#Yii log #Yii log
snippet ylog snippet ylog
Yii::log('${1:msg}', '${2:info}'); Yii::log('${1:msg}', '${2:info}');
#Yii userHostAddress #Yii userHostAddress
snippet yuserip snippet yuserip
YYii::app()->request->userHostAddress YYii::app()->request->userHostAddress
#Yii register script file #Yii register script file
snippet yregsf snippet yregsf
Yii::app()->clientScript->registerScriptFile('${1:scriptUrl}', CClientScript::POS_${2:END}); Yii::app()->clientScript->registerScriptFile('${1:scriptUrl}', CClientScript::POS_${2:END});
#Yii CLinkPager #Yii CLinkPager
snippet ylinkpager snippet ylinkpager
$this->widget('CLinkPager', array('pages'=>$pages,'header'=>'${1}'})) $this->widget('CLinkPager', array('pages'=>$pages,'header'=>'${1}'}))
#Yii CJSON::encode #Yii CJSON::encode
snippet yjec snippet yjec
CJSON::encode(${1:text}); CJSON::encode(${1:text});
#CActiveDataProvider #CActiveDataProvider
snippet yadp snippet yadp
@ -68,23 +68,23 @@ snippet yadp
), ),
)); ));
${6} ${6}
// $dataProvider->getData() will return a list of Post objects // $dataProvider->getData() will return a list of Post objects
#Yii renderDynamic internal #Yii renderDynamic internal
snippet yrdi snippet yrdi
$this->renderDynamic('${1:callback}', array('${2:key}'=>${3:value})); $this->renderDynamic('${1:callback}', array('${2:key}'=>${3:value}));
#Yii register script #Yii register script
snippet yregs snippet yregs
Yii::app()->clientScript->registerScript('${1:id}', '${2}', CClientScript::POS_${3:READY}); Yii::app()->clientScript->registerScript('${1:id}', '${2}', CClientScript::POS_${3:READY});
#Yii Flush cache #Yii Flush cache
snippet ycaf snippet ycaf
Yii::app()->cache->flush(); Yii::app()->cache->flush();
#Yii Yii::app()->request->cookies #Yii Yii::app()->request->cookies
snippet yco snippet yco
Yii::app()->request->cookies['${1}'] Yii::app()->request->cookies['${1}']
#Yii user-> #Yii user->
snippet yuser snippet yuser
@ -92,54 +92,54 @@ snippet yuser
#Yii refresh #Yii refresh
snippet yrf snippet yrf
$this->refresh(); $this->refresh();
#Yii import #Yii import
snippet yimp snippet yimp
Yii::import('${1}'); Yii::import('${1}');
#Yii trace #Yii trace
snippet ytrace snippet ytrace
Yii::trace('${1:msg}'); Yii::trace('${1:msg}');
#Yii params #Yii params
snippet ypar snippet ypar
Yii::app()->params['${1}'] Yii::app()->params['${1}']
#Yii isPostRequest #Yii isPostRequest
snippet yispost snippet yispost
Yii::app()->request->isPostRequest Yii::app()->request->isPostRequest
#Yii IF isAjaxRequest #Yii IF isAjaxRequest
snippet yifisajax snippet yifisajax
if(Yii::app()->request->isAjaxRequest == TRUE) if(Yii::app()->request->isAjaxRequest == TRUE)
{ {
${1} ${1}
} }
#Yii Yii::app()->cache->delete #Yii Yii::app()->cache->delete
snippet ydelcache snippet ydelcache
Yii::app()->cache->delete('${1:key}'); Yii::app()->cache->delete('${1:key}');
#Yii render view #Yii render view
snippet yr snippet yr
$this->render('${1:view}',array('${2:key}'=>${3:value})); $this->render('${1:view}',array('${2:key}'=>${3:value}));
#Yii redirect #Yii redirect
snippet yre snippet yre
$this->redirect(array('${1:controller}/${2:action}')); $this->redirect(array('${1:controller}/${2:action}'));
#Yii Get cache #Yii Get cache
snippet ycag snippet ycag
Yii::app()->cache->get('${1:key}'); Yii::app()->cache->get('${1:key}');
#Yii render text #Yii render text
snippet yrt snippet yrt
$this->renderText('${1}'); $this->renderText('${1}');
#Yii render partial #Yii render partial
snippet yrp snippet yrp
$this->renderPartial('${1:view}',array('${2:key}'=>${3:value})); $this->renderPartial('${1:view}',array('${2:key}'=>${3:value}));
#----------------Yii Model----------------------------- #----------------Yii Model-----------------------------
#Yii Model count #Yii Model count
@ -152,7 +152,7 @@ snippet ycountbs
#Yii Model updateAll #Yii Model updateAll
snippet yupdatea snippet yupdatea
${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${5:value})); ${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${5:value}));
#Yii Model updateByPk #Yii Model updateByPk
snippet yupdatebp snippet yupdatebp
@ -164,35 +164,35 @@ snippet ydela
#Yii Model deleteByPk #Yii Model deleteByPk
snippet ydelbp snippet ydelbp
${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value})); ${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value}));
#Yii Model find #Yii Model find
snippet yfind snippet yfind
${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${4:value})); ${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${4:value}));
#Yii Model findAll #Yii Model findAll
snippet yfinda snippet yfinda
${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${4:value})); ${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${4:value}));
#Yii Model findByPk #Yii Model findByPk
snippet yfindbp snippet yfindbp
${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value})); ${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value}));
#Yii Model findAllByPk #Yii Model findAllByPk
snippet yfindabp snippet yfindabp
${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${5:value})); ${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${5:value}));
#Yii Model findBySql #Yii Model findBySql
snippet yfindbs snippet yfindbs
${1:ModelName}::model()->findBySql(${2:sql}, array('${3:key}'=>${4:value})); ${1:ModelName}::model()->findBySql(${2:sql}, array('${3:key}'=>${4:value}));
#Yii Model findAllByAttributes #Yii Model findAllByAttributes
snippet yfindaba snippet yfindaba
${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${6:value})); ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${6:value}));
#Yii Model exists #Yii Model exists
snippet yexists snippet yexists
${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${4:value})); ${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${4:value}));
#Yii Create model class #Yii Create model class
snippet ymodel snippet ymodel
@ -245,7 +245,7 @@ snippet ymodel
} }
} }
#------------Yii Controller------------------------------------ #------------Yii Controller------------------------------------
#Yii Create controller class #Yii Create controller class
snippet ycontroller snippet ycontroller

View file

@ -12,7 +12,7 @@ snippet ife
else else
${3:# statements} ${3:# statements}
fi fi
snippet elif snippet eif
elif ${1:condition} ; then elif ${1:condition} ; then
${2:# statements} ${2:# statements}
snippet for snippet for