mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-22 14:08:01 +01:00
Completely replaced command-based snippets with a new, easier to read/maintain syntax. Also added a python script to make it easier to migrate.
This commit is contained in:
@@ -1,46 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_c_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_c_snips = 1
|
|
||||||
let snippet_filetype = 'c'
|
|
||||||
|
|
||||||
" main()
|
|
||||||
exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
|
|
||||||
" #include <...>
|
|
||||||
exe 'Snipp inc #include <${1:stdio}.h>${2}'
|
|
||||||
" #include "..."
|
|
||||||
exe 'Snipp Inc #include "${1:`Filename("$1.h")`}"${2}'
|
|
||||||
" #ifndef ... #define ... #endif
|
|
||||||
exe "Snipp def #ifndef $1\n#define ${1:SYMBOL} ${2:value}\n#endif${3}"
|
|
||||||
" Header Include-Guard
|
|
||||||
" (the randomizer code is taken directly from TextMate; it could probably be
|
|
||||||
" cleaner, I don't know how to do it in vim script)
|
|
||||||
exe "Snipp once #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system(\"/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'\"))`}\n"
|
|
||||||
\ ."#define $1\n\n${2}\n\n#endif /* end of include guard: $1 */"
|
|
||||||
" If Condition
|
|
||||||
exe "Snipp if if (${1:/* condition */}) {\n\t${2:/* code */}\n}"
|
|
||||||
exe "Snipp el else {\n\t${1}\n}"
|
|
||||||
" Tertiary conditional
|
|
||||||
exe 'Snipp t ${1:/* condition */} ? ${2:a} : ${3:b}'
|
|
||||||
" Do While Loop
|
|
||||||
exe "Snipp do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
|
|
||||||
" While Loop
|
|
||||||
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
|
|
||||||
" For Loop
|
|
||||||
exe "Snipp for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\t${4:/* code */}\n}${5}"
|
|
||||||
" Custom For Loop
|
|
||||||
exe "Snipp forr for (${1:i} = 0; ${2:$1 < 5}; $1${3:++}) {\n\t${4:/* code */}\n}"
|
|
||||||
" Function
|
|
||||||
exe "Snipp fun ${1:void} ${2:function_name} (${3})\n{\n\t${4:/* code */}\n}"
|
|
||||||
" Typedef
|
|
||||||
exe 'Snipp td typedef ${1:int} ${2:MyCustomType};'
|
|
||||||
" Struct
|
|
||||||
exe "Snipp st struct ${1:`Filename('$1_t', 'name')`} {\n\t${2:/* data */}\n}${3: /* optional variable list */};${4}"
|
|
||||||
" Typedef struct
|
|
||||||
exe "Snipp tds typedef struct ${2:$1 }{\n\t${3:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
|
|
||||||
" printf
|
|
||||||
" unfortunately version this isn't as nice as TextMates's, given the lack of a
|
|
||||||
" dynamic `...`
|
|
||||||
exe 'Snipp pr printf("${1:%s}\n"${2});${3}'
|
|
||||||
" fprintf (again, this isn't as nice as TextMate's version, but it works)
|
|
||||||
exe 'Snipp fpr fprintf(${1:stderr}, "${2:%s}\n"${3});${4}'
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
if !exists('g:loaded_snips') || exists('s:did_cpp_snips')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:did_cpp_snips = 1
|
|
||||||
|
|
||||||
" Read File Into Vector
|
|
||||||
exe "Snipp readfile std::vector<char> v;\nif (FILE *${2:fp} = fopen(${1:\"filename\"}, \"r\")) {\n\tchar buf[1024];\n\twhile (size_t len = "
|
|
||||||
\ ."fread(buf, 1, sizeof(buf), $2))\n\t\tv.insert(v.end(), buf, buf + len);\n\tfclose($2);\n}${3}"
|
|
||||||
" std::map
|
|
||||||
exe "Snipp map std::map<${1:key}, ${2:value}> map${3};"
|
|
||||||
" std::vector
|
|
||||||
exe "Snipp vector std::vector<${1:char}> v${2};"
|
|
||||||
" Namespace
|
|
||||||
exe "Snipp ns namespace ${1:`Filename('', 'my')`} {\n\t${2}\n} /* $1 */"
|
|
||||||
" Class
|
|
||||||
exe "Snipp cl class ${1:`Filename('$1_t', 'name')`} {\npublic:\n\t$1 (${2:arguments});\n\tvirtual ~$1 ();\n\nprivate:\n\t${3:/* data */}\n};"
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
let snippet_filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html'
|
|
||||||
if !exists('g:loaded_snips') || exists('s:did_'.snippet_filetype.'_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_{snippet_filetype}_snips = 1
|
|
||||||
|
|
||||||
" automatically add a closing '/' to the end of xhtml tags
|
|
||||||
let c = snippet_filetype == 'xhtml' ? ' /' : ''
|
|
||||||
|
|
||||||
" Some useful Unicode entities
|
|
||||||
" Non-Breaking Space
|
|
||||||
exe 'Snipp nbs '
|
|
||||||
" ←
|
|
||||||
exe 'Snipp left ←'
|
|
||||||
" →
|
|
||||||
exe 'Snipp right →'
|
|
||||||
" ↑
|
|
||||||
exe 'Snipp up ↑'
|
|
||||||
" ↓
|
|
||||||
exe 'Snipp down ↓'
|
|
||||||
" ↩
|
|
||||||
exe 'Snipp return ↩'
|
|
||||||
" ⇤
|
|
||||||
exe 'Snipp backtab ⇤'
|
|
||||||
" ⇥
|
|
||||||
exe 'Snipp tab ⇥'
|
|
||||||
" ⇧
|
|
||||||
exe 'Snipp shift ⇧'
|
|
||||||
" ⌃
|
|
||||||
exe 'Snipp control ⌃'
|
|
||||||
" ⌅
|
|
||||||
exe 'Snipp enter ⌅'
|
|
||||||
" ⌘
|
|
||||||
exe 'Snipp command ⌘'
|
|
||||||
" ⌥
|
|
||||||
exe 'Snipp option ⌥'
|
|
||||||
" ⌦
|
|
||||||
exe 'Snipp delete ⌦'
|
|
||||||
" ⌫
|
|
||||||
exe 'Snipp backspace ⌫'
|
|
||||||
" ⎋
|
|
||||||
exe 'Snipp escape ⎋'
|
|
||||||
" Generic Doctype
|
|
||||||
exe "Snipp! doctype \"HTML 4.01 Strict\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
|
|
||||||
exe "Snipp! doctype \"HTML 4.01 Transitional\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
|
|
||||||
exe "Snipp! doctype \"HTML 5\" <!DOCTYPE HTML>"
|
|
||||||
exe "Snipp! doctype \"XHTML 1.0 Frameset\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
|
||||||
exe "Snipp! doctype \"XHTML 1.0 Strict\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
|
||||||
exe "Snipp! doctype \"XHTML 1.0 Transitional\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
|
||||||
exe "Snipp! doctype \"XHTML 1.1\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
|
|
||||||
" HTML Doctype 4.01 Strict
|
|
||||||
exe "Snipp docts <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
|
|
||||||
" HTML Doctype 4.01 Transitional
|
|
||||||
exe "Snipp doct <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
|
|
||||||
" HTML Doctype 5
|
|
||||||
exe 'Snipp doct5 <!DOCTYPE HTML>'
|
|
||||||
" XHTML Doctype 1.0 Frameset
|
|
||||||
exe "Snipp docxf <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"
|
|
||||||
" XHTML Doctype 1.0 Strict
|
|
||||||
exe "Snipp docxs <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
|
||||||
" XHTML Doctype 1.0 Transitional
|
|
||||||
exe "Snipp docxt <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
|
||||||
" XHTML Doctype 1.1
|
|
||||||
exe "Snipp docx <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
|
|
||||||
exe "Snipp html <html>\n${1}\n</html>"
|
|
||||||
exe "Snipp xhtml <html xmlns=\"http://www.w3.org/1999/xhtml\">\n${1}\n</html>"
|
|
||||||
exe "Snipp body <body>\n\t${1}\n</body>"
|
|
||||||
exe "Snipp head <head>\n\t<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"".c.">\n\t"
|
|
||||||
\. "<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`}</title>\n\t${2}\n</head>"
|
|
||||||
exe 'Snipp title <title>${1:`substitute(Filename("", "Page Title"), "^.", "\\u&", "")`}</title>${2}'
|
|
||||||
exe "Snipp script <script type=\"text/javascript\" charset=\"utf-8\">\n\t${1}\n</script>${2}"
|
|
||||||
exe "Snipp scriptsrc <script src=\"${1}.js\" type=\"text/javascript\" charset=\"utf-8\"></script>${2}"
|
|
||||||
exe "Snipp style <style type=\"text/css\" media=\"${1:screen}\">\n\t${2}\n</style>${3}"
|
|
||||||
exe 'Snipp base <base href="${1}" target="${2}"'.c.'>'
|
|
||||||
exe 'Snipp r <br'.c[1:].'>'
|
|
||||||
exe "Snipp div <div id=\"${1:name}\">\n\t${2}\n</div>"
|
|
||||||
" Embed QT Movie
|
|
||||||
exe "Snipp movie <object width=\"$2\" height=\"$3\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\""
|
|
||||||
\ ." codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">\n\t<param name=\"src\" value=\"$1\"".c.">\n\t<param name=\"controller\" value=\"$4\"".c
|
|
||||||
\ .">\n\t<param name=\"autoplay\" value=\"$5\"".c.">\n\t<embed src=\"${1:movie.mov}\"\n\t\twidth=\"${2:320}\" height=\"${3:240}\"\n\t\t"
|
|
||||||
\ ."controller=\"${4:true}\" autoplay=\"${5:true}\"\n\t\tscale=\"tofit\" cache=\"true\"\n\t\tpluginspage=\"http://www.apple.com/quicktime/download/\"\n\t".c[1:].">\n</object>${6}"
|
|
||||||
exe "Snipp fieldset <fieldset id=\"$1\">\n\t<legend>${1:name}</legend>\n\n\t${3}\n</fieldset>"
|
|
||||||
exe "Snipp form <form action=\"${1:`Filename('$1_submit')`}\" method=\"${2:get}\" accept-charset=\"utf-8\">\n\t${3}\n\n\t"
|
|
||||||
\."<p><input type=\"submit\" value=\"Continue →\"".c."></p>\n</form>"
|
|
||||||
exe 'Snipp h1 <h1 id="${1:heading}">${2:$1}</h1>'
|
|
||||||
exe 'Snipp input <input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"'.c.'>${4}'
|
|
||||||
exe 'Snipp label <label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"'.c.'>${7}'
|
|
||||||
exe 'Snipp link <link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"'.c.'>${4}'
|
|
||||||
exe 'Snipp mailto <a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>'
|
|
||||||
exe 'Snipp meta <meta name="${1:name}" content="${2:content}"'.c.'>${3}'
|
|
||||||
exe 'Snipp opt <option value="${1:option}">${2:$1}</option>${3}'
|
|
||||||
exe 'Snipp optt <option>${1:option}</option>${2}'
|
|
||||||
exe "Snipp select <select name=\"${1:some_name}\" id=\"${2:$1}\">\n\t<option value=\"${3:option}\">${4:$3}</option>\n</select>${5}"
|
|
||||||
exe "Snipp table <table border=\"${1:0}\">\n\t<tr><th>${2:Header}</th></tr>\n\t<tr><th>${3:Data}</th></tr>\n</table>${4}"
|
|
||||||
exe 'Snipp textarea <textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}'
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_java_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_java_snips = 1
|
|
||||||
let snippet_filetype = 'java'
|
|
||||||
|
|
||||||
exe "Snipp main public static void main (String [] args)\n{\n\t${1:/* code */}\n}"
|
|
||||||
exe 'Snipp pu public'
|
|
||||||
exe 'Snipp po protected'
|
|
||||||
exe 'Snipp pr private'
|
|
||||||
exe 'Snipp st static'
|
|
||||||
exe 'Snipp fi final'
|
|
||||||
exe 'Snipp ab abstract'
|
|
||||||
exe 'Snipp re return'
|
|
||||||
exe 'Snipp br break;'
|
|
||||||
exe "Snipp de default:\n\t${1}"
|
|
||||||
exe 'Snipp ca catch(${1:Exception} ${2:e}) ${3}'
|
|
||||||
exe 'Snipp th throw '
|
|
||||||
exe 'Snipp sy synchronized'
|
|
||||||
exe 'Snipp im import'
|
|
||||||
exe 'Snipp j.u java.util'
|
|
||||||
exe 'Snipp j.i java.io.'
|
|
||||||
exe 'Snipp j.b java.beans.'
|
|
||||||
exe 'Snipp j.n java.net.'
|
|
||||||
exe 'Snipp j.m java.math.'
|
|
||||||
exe 'Snipp if if (${1}) ${2}'
|
|
||||||
exe 'Snipp el else '
|
|
||||||
exe 'Snipp elif else if (${1}) ${2}'
|
|
||||||
exe 'Snipp wh while (${1}) ${2}'
|
|
||||||
exe 'Snipp for for (${1}; ${2}; ${3}) ${4}'
|
|
||||||
exe 'Snipp fore for (${1} : ${2}) ${3}'
|
|
||||||
exe 'Snipp sw switch (${1}) ${2}'
|
|
||||||
exe "Snipp cs case ${1}:\n\t${2}\n${3}"
|
|
||||||
exe 'Snipp tc public class ${1:`Filename()`} extends ${2:TestCase}'
|
|
||||||
exe 'Snipp t public void test${1:Name}() throws Exception ${2}'
|
|
||||||
exe 'Snipp cl class ${1:`Filename("", "untitled")`} ${2}'
|
|
||||||
exe 'Snipp in interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}'
|
|
||||||
exe 'Snipp m ${1:void} ${2:method}(${3}) ${4:throws }${5}'
|
|
||||||
exe 'Snipp v ${1:String} ${2:var}${3: = null}${4};${5}'
|
|
||||||
exe 'Snipp co static public final ${1:String} ${2:var} = ${3};${4}'
|
|
||||||
exe 'Snipp cos static public final String ${1:var} = "${2}";${3}'
|
|
||||||
exe 'Snipp as assert ${1:test} : "${2:Failure message}";${3}'
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_js_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_js_snips = 1
|
|
||||||
let snippet_filetype = 'javascript'
|
|
||||||
|
|
||||||
" Prototype
|
|
||||||
exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"
|
|
||||||
" Function
|
|
||||||
exe "Snipp fun function ${1:function_name} (${2:argument}) {\n\t${3:// body...}\n}"
|
|
||||||
" Anonymous Function
|
|
||||||
exe 'Snipp f function(${1}) {${2}};'
|
|
||||||
" if
|
|
||||||
exe 'Snipp if if (${1:true}) {${2}};'
|
|
||||||
" if ... else
|
|
||||||
exe "Snipp ife if (${1:true}) {${2}}\nelse{${3}};"
|
|
||||||
" tertiary conditional
|
|
||||||
exe 'Snipp t ${1:/* condition */} ? ${2:a} : ${3:b}'
|
|
||||||
" switch
|
|
||||||
exe "Snipp switch switch(${1:expression}) {\n\tcase '${3:case}':\n\t\t${4:// code}\n\t\tbreak;\n\t${5}\n\tdefault:\n\t\t${2:// code}\n}"
|
|
||||||
" case
|
|
||||||
exe "Snipp case case '${1:case}':\n\t${2:// code}\n\tbreak;\n${3}"
|
|
||||||
" for (...) {...}
|
|
||||||
exe "Snipp for for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {\n\t${4:$1[$2]}\n};"
|
|
||||||
" for (...) {...} (Improved Native For-Loop)
|
|
||||||
exe "Snipp forr for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {\n\t${4:$1[$2]}\n};"
|
|
||||||
" while (...) {...}
|
|
||||||
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
|
|
||||||
" do...while
|
|
||||||
exe "Snipp do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
|
|
||||||
" Object Method
|
|
||||||
exe "Snipp :f ${1:method_name}: function(${2:attribute}) {\n\t${4}\n}${3:,}"
|
|
||||||
" setTimeout function
|
|
||||||
exe 'Snipp timeout setTimeout(function() {${3}}${2}, ${1:10};'
|
|
||||||
" Get Elements
|
|
||||||
exe "Snipp get getElementsBy${1:TagName}('${2}')${3}"
|
|
||||||
" Get Element
|
|
||||||
exe "Snipp gett getElementBy${1:Id}('${2}')${3}"
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_objc_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_objc_snips = 1
|
|
||||||
let snippet_filetype = 'objc'
|
|
||||||
|
|
||||||
" #import <...>
|
|
||||||
exe 'Snipp imp #import <${1:Cocoa/Cocoa.h}>${2}'
|
|
||||||
" #import "..."
|
|
||||||
exe 'Snipp Imp #import "${1:`Filename()`.h}"${2}'
|
|
||||||
" @selector(...)
|
|
||||||
exe 'Snipp sel @selector(${1:method}:)${3}'
|
|
||||||
" NSLog(...)
|
|
||||||
exe 'Snipp log NSLog(@"${1}"${2});${3}'
|
|
||||||
" Class
|
|
||||||
exe "Snipp objc @interface ${1:`Filename('', 'object')`} : ${2:NSObject}\n{\n}\n@end\n\n@implementation $1\n- (id) init\n{\n\tif (self = [super init])"
|
|
||||||
\."\n\t{${3}\n\t}\n\treturn self\n}\n@end"
|
|
||||||
" Class Interface
|
|
||||||
exe "Snipp clh @interface ${1:ClassName} : ${2:NSObject}\n{${3}\n}\n${4}\n@end"
|
|
||||||
exe 'Snipp ibo IBOutlet ${1:NSSomeClass} *${2:$1};'
|
|
||||||
" Category
|
|
||||||
exe "Snipp cat @interface ${1:NSObject} (${2:Category})\n@end\n\n@implementation $1 ($2)\n${3}\n@end"
|
|
||||||
" Category Interface
|
|
||||||
exe "Snipp cath @interface ${1:NSObject} (${2:Category})\n${3}\n@end"
|
|
||||||
" NSArray
|
|
||||||
exe 'Snipp array NSMutableArray *${1:array} = [NSMutable array];${2}'
|
|
||||||
" NSDictionary
|
|
||||||
exe 'Snipp dict NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}'
|
|
||||||
" NSBezierPath
|
|
||||||
exe 'Snipp bez NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}'
|
|
||||||
" Method
|
|
||||||
exe "Snipp m - (${1:id})${2:method}\n{\n\t${3:return self;}\n}"
|
|
||||||
" Method declaration
|
|
||||||
exe "Snipp md - (${1:id})${2:method};${3}"
|
|
||||||
" Class Method
|
|
||||||
exe "Snipp M + (${1:id})${2:method}\n{${3}\n\treturn nil;\n}"
|
|
||||||
" Sub-method (Call super)
|
|
||||||
exe "Snipp sm - (${1:id})${2:method}\n{\n\t[super $2];${3}\n\treturn self;\n}"
|
|
||||||
" Method: Initialize
|
|
||||||
exe "Snipp I + (void) initialize\n{\n\t[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:\n\t\t${1}@\"value\", @\"key\",\n\t\tnil]];\n}"
|
|
||||||
" Accessor Methods For:
|
|
||||||
" Object
|
|
||||||
exe "Snipp objacc - (${1:id})${2:thing}\n{\n\treturn $2;\n}\n\n- (void) set$2:($1)\n{\n\t$1 old$2 = $2;\n\t$2 = [aValue retain];\n\t[old$2 release];\n}"
|
|
||||||
exe "Snipp forarray unsigned int\t${1:object}Count = [${2:array} count];\n\nfor (unsigned int index = 0; index < $1Count; index++)\n{\n\t${3:id}\t$1 = [$2 $1AtIndex:index];\n\t${4}\n}"
|
|
||||||
" IBOutlet
|
|
||||||
" @property (Objective-C 2.0)
|
|
||||||
exe "Snipp prop @property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4}"
|
|
||||||
" @synthesize (Objective-C 2.0)
|
|
||||||
exe "Snipp syn @synthesize ${1:NSSomeClass};${2}"
|
|
||||||
" [[ alloc] init]
|
|
||||||
exe 'Snipp alloc [[${1:foo} alloc] init]${2};${3}'
|
|
||||||
" retain
|
|
||||||
exe 'Snipp ret [${1:foo} retain];${2}'
|
|
||||||
" release
|
|
||||||
exe 'Snipp rel [${1:foo} release];${2}'
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_perl_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_perl_snips = 1
|
|
||||||
let snippet_filetype = 'perl'
|
|
||||||
|
|
||||||
" Hash Pointer
|
|
||||||
exe 'Snipp . =>'
|
|
||||||
" Function
|
|
||||||
exe "Snipp sub sub ${1:function_name} {\n\t${2:#body ...}\n}"
|
|
||||||
" Conditional
|
|
||||||
exe "Snipp if if (${1}) {\n\t${2:# body...}\n}"
|
|
||||||
" Conditional if..else
|
|
||||||
exe "Snipp ife if (${1}) {\n\t${2:# body...}\n} else {\n\t${3:# else...}\n}"
|
|
||||||
" Conditional if..elsif..else
|
|
||||||
exe "Snipp ifee if (${1}) {\n\t${2:# body...}\n} elsif (${3}) {\n\t${4:# elsif...}\n} else {\n\t${5:# else...}\n}"
|
|
||||||
" Conditional One-line
|
|
||||||
exe 'Snipp xif ${1:expression} if ${2:condition};${3}'
|
|
||||||
" Unless conditional
|
|
||||||
exe "Snipp unless unless (${1}) {\n\t${2:# body...}\n}"
|
|
||||||
" Unless conditional One-line
|
|
||||||
exe 'Snipp xunless ${1:expression} unless ${2:condition};${3}'
|
|
||||||
" Try/Except
|
|
||||||
exe "Snipp eval eval {\n\t${1:# do something risky...}\n};\nif ($@) {\n\t${2:# handle failure...}\n}"
|
|
||||||
" While Loop
|
|
||||||
exe "Snipp wh while (${1}) {\n\t${2:# body...}\n}"
|
|
||||||
" While Loop One-line
|
|
||||||
exe "Snipp xwh ${1:expression} while ${2:condition};${3}"
|
|
||||||
" For Loop
|
|
||||||
exe "Snipp for for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\t${4:# body...}\n}"
|
|
||||||
" Foreach Loop
|
|
||||||
exe "Snipp fore foreach my $${1:x} (@${2:array}) {\n\t${3:# body...}\n}"
|
|
||||||
" Foreach Loop One-line
|
|
||||||
exe 'Snipp xfore ${1:expression} foreach @${2:array};${3}'
|
|
||||||
" Package
|
|
||||||
exe "Snipp cl package ${1:ClassName};\n\nuse base qw(${2:ParentClass});\n\nsub new {\n\tmy $class = shift;\n\t$class = ref $class if ref $class;\n\tmy $self = bless {}, $class;\n\t$self;\n}\n\n1;${3}"
|
|
||||||
" Read File
|
|
||||||
exe "Snipp slurp my $${1:var};\n{ local $/ = undef; local *FILE; open FILE, \"<${2:file}\"; $$1 = <FILE>; close FILE }${2}"
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_php_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_php_snips = 1
|
|
||||||
let snippet_filetype = 'php'
|
|
||||||
|
|
||||||
exe "Snipp php <?php\n${1}\n?>"
|
|
||||||
exe 'Snipp ec echo "${1:string}"${2};'
|
|
||||||
exe "Snipp inc include '${1:file}';${2}"
|
|
||||||
exe "Snipp inc1 include_once '${1:file}';${2}"
|
|
||||||
exe "Snipp req require '${1:file}';${2}"
|
|
||||||
exe "Snipp req1 require_once '${1:file}';${2}"
|
|
||||||
" $GLOBALS['...']
|
|
||||||
exe "Snipp globals $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}"
|
|
||||||
exe "Snipp! $_ \"COOKIE['...']\" $_COOKIE['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"ENV['...']\" $_ENV['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"FILES['...']\" $_FILES['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"Get['...']\" $_GET['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"POST['...']\" $_POST['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"REQUEST['...']\" $_REQUEST['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"SERVER['...']\" $_SERVER['${1:variable}']${2}"
|
|
||||||
exe "Snipp! $_ \"SESSION['...']\" $_SESSION['${1:variable}']${2}"
|
|
||||||
" Start Docblock
|
|
||||||
exe "Snipp /* /**\n * ${1}\n **/"
|
|
||||||
" Class - post doc
|
|
||||||
exe "Snipp doc_cp /**\n * ${1:undocumented class}\n *\n * @package ${2:default}\n * @author ${3:`g:snips_author`}\n**/${4}"
|
|
||||||
" Class Variable - post doc
|
|
||||||
exe "Snipp doc_vp /**\n * ${1:undocumented class variable}\n *\n * @var ${2:string}\n **/${3}"
|
|
||||||
" Class Variable
|
|
||||||
exe "Snipp doc_v /**\n * ${3:undocumented class variable}\n *\n * @var ${4:string}\n **/\n${1:var} $${2};${5}"
|
|
||||||
" Class
|
|
||||||
exe "Snipp doc_c /**\n * ${3:undocumented class}\n *\n * @packaged ${4:default}\n * @author ${5:`g:snips_author`}\n **/\n${1:}class ${2:}\n{${6}\n} // END $1class $2"
|
|
||||||
" Constant Definition - post doc
|
|
||||||
exe "Snipp doc_dp /**\n * ${1:undocumented constant}\n **/${2}"
|
|
||||||
" Constant Definition
|
|
||||||
exe "Snipp doc_d /**\n * ${3:undocumented constant}\n **/\ndefine(${1}, ${2});${4}"
|
|
||||||
" Function - post doc
|
|
||||||
exe "Snipp doc_fp /**\n * ${1:undocumented function}\n *\n * @return ${2:void}\n * @author ${3:`g:snips_author`}\n **/${4}"
|
|
||||||
" Function signature
|
|
||||||
exe "Snipp doc_s /**\n * ${4:undocumented function}\n *\n * @return ${5:void}\n * @author ${6:`g:snips_author`}\n **/\n${1}function ${2}(${3});${7}"
|
|
||||||
" Function
|
|
||||||
exe "Snipp doc_f /**\n * ${4:undocumented function}\n *\n * @return ${5:void}\n * @author ${6:`g:snips_author`}\n **/\n${1}function ${2}(${3})\n{${7}\n}"
|
|
||||||
" Header
|
|
||||||
exe "Snipp doc_h /**\n * ${1}\n *\n * @author ${2:`g:snips_author`}\n * @version ${3:$Id$}\n * @copyright ${4:$2}, `strftime('%d %B, %Y')`\n * @package ${5:default}\n **/\n\n/**\n * Define DocBlock\n *//"
|
|
||||||
" Interface
|
|
||||||
exe "Snipp doc_i /**\n * ${2:undocumented class}\n *\n * @package ${3:default}\n * @author ${4:`g:snips_author`}\n **/\ninterface ${1:}\n{${5}\n} // END interface $1"
|
|
||||||
" class ...
|
|
||||||
exe "Snipp class /**\n * ${1}\n **/\nclass ${2:ClassName}\n{\n\t${3}\n\tfunction ${4:__construct}(${5:argument})\n\t{\n\t\t${6:// code...}\n\t}\n}"
|
|
||||||
" define(...)
|
|
||||||
exe "Snipp def define('${1}'${2});${3}"
|
|
||||||
" defined(...)
|
|
||||||
exe "Snipp def? ${1}defined('${2}')${3}"
|
|
||||||
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:// code...}\n}"
|
|
||||||
" do ... while
|
|
||||||
exe "Snipp do do {\n\t${2:// code... }\n} while (${1:/* condition */});"
|
|
||||||
exe "Snipp if if (${1:/* condition */}) {\n\t${2:// code...}\n}"
|
|
||||||
exe "Snipp ife if (${1:/* condition */}) {\n\t${2:// code...}\n} else {\n\t${3:// code...}\n}\n${4}"
|
|
||||||
exe "Snipp else else {\n\t${1:// code...}\n}"
|
|
||||||
exe "Snipp elseif elseif (${1:/* condition */}) {\n\t${2:// code...}\n}"
|
|
||||||
" Tertiary conditional
|
|
||||||
exe "Snipp t $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}"
|
|
||||||
exe "Snipp switch switch ($${1:variable}) {\n\tcase '${2:value}':\n\t\t${3:// code...}\n\t\tbreak;\n\t${5}\n\tdefault:\n\t\t${4:// code...}\n\t\tbreak;\n}"
|
|
||||||
exe "Snipp case case '${1:value}':\n\t${2:// code...}\n\tbreak;${3}"
|
|
||||||
exe "Snipp for for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\t${4: // code...}\n}"
|
|
||||||
exe "Snipp foreach foreach ($${1:variable} as $${2:key}) {\n\t${3:// code...}\n}"
|
|
||||||
exe "Snipp fun ${1:public }function ${2:FunctionName}(${3})\n{\n\t${4:// code...}\n}"
|
|
||||||
" $... = array (...)
|
|
||||||
exe "Snipp array $${1:arrayName} = array('${2}' => ${3});${4}"
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_python_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_python_snips = 1
|
|
||||||
let snippet_filetype = 'python'
|
|
||||||
|
|
||||||
" New Class
|
|
||||||
exe "Snipp cl class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.$4 = $4\n\t\t${6}"
|
|
||||||
" New Function
|
|
||||||
exe "Snipp def def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\t\"\"\"${3:docstring for $1}\"\"\"\n\t${4:pass}"
|
|
||||||
" New Method
|
|
||||||
exe "Snipp defs def ${1:mname}(self, ${2:arg})):\n\t${3:pass}"
|
|
||||||
" New Property
|
|
||||||
exe "Snipp property def ${1:foo}():\n\tdoc = \"${2:The $1 property.}\"\n\tdef fget(self):\n\t\t\t${3:return self._$1}\n\tdef fset(self, value):\n\t\t"
|
|
||||||
\."${4:self._$1 = value}\n\tdef fdel(self):\n\t\t\t${5:del self._$1}\n\treturn locals()\n$1 = property(**$1())${6}"
|
|
||||||
" Self
|
|
||||||
exe 'Snipp . self.'
|
|
||||||
" Try/Except
|
|
||||||
exe "Snipp try try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}"
|
|
||||||
" Try/Except/Else
|
|
||||||
exe "Snipp trye try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}"
|
|
||||||
" Try/Except/Finally
|
|
||||||
exe "Snipp tryf try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}"
|
|
||||||
" Try/Except/Else/Finally
|
|
||||||
exe "Snipp tryef try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}\nfinally:\n\t${6:pass}"
|
|
||||||
" if __name__ == '__main__':
|
|
||||||
exe "Snipp ifmain if __name__ == '__main__':\n\t${1:main()}"
|
|
||||||
" __magic__
|
|
||||||
exe 'Snipp _ __${1:init}__${2}'
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_ruby_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_ruby_snips = 1
|
|
||||||
let snippet_filetype = 'ruby'
|
|
||||||
|
|
||||||
" New Block
|
|
||||||
exe "Snipp =b =begin rdoc\n\t${1}\n=end"
|
|
||||||
exe "Snipp y :yields: ${1:arguments}"
|
|
||||||
exe "Snipp rb #!/usr/bin/env ruby -wKU\n"
|
|
||||||
exe 'Snipp req require "${1}"${2}'
|
|
||||||
exe 'Snipp # # =>'
|
|
||||||
exe 'Snipp end __END__'
|
|
||||||
exe "Snipp case case ${1:object}\nwhen ${2:condition}\n\t${3}\nend"
|
|
||||||
exe "Snipp when when ${1:condition}\n\t${2}"
|
|
||||||
exe "Snipp def def ${1:method_name}\n\t${2}\nend"
|
|
||||||
exe "Snipp deft def test_${1:case_name}\n\t${2}\nend"
|
|
||||||
exe "Snipp if if ${1:condition}\n\t${2}\nend"
|
|
||||||
exe "Snipp ife if ${1:condition}\n\t${2}\nelse\n\t${3}\nend"
|
|
||||||
exe "Snipp elsif elsif ${1:condition}\n\t${2}"
|
|
||||||
exe "Snipp unless unless ${1:condition}\n\t${2}\nend"
|
|
||||||
exe "Snipp while while ${1:condition}\n\t${2}\nend"
|
|
||||||
exe "Snipp until until ${1:condition}\n\t${2}\nend"
|
|
||||||
exe "Snipp! cla \"class .. end\" class ${1:`substitute(Filename(), '^.', '\\u&', '')`}\n\t${2}\nend"
|
|
||||||
exe "Snipp! cla \"class .. initialize .. end\" class ${1:`substitute(Filename(), '^.', '\\u&', '')`}\n\tdef initialize(${2:args})\n\t\t${3}\n\tend\n\n\nend"
|
|
||||||
exe "Snipp! cla \"class .. < ParentClass .. initialize .. end\" class ${1:`substitute(Filename(), '^.', '\\u&', '')`} < ${2:ParentClass}\n\tdef initialize(${3:args})\n\t\t${4}\n\tend\n\n\nend"
|
|
||||||
exe "Snipp! cla \"ClassName = Struct .. do .. end\" ${1:`substitute(Filename(), '^.', '\\u&', '')`} = Struct.new(:${2:attr_names}) do\n\tdef ${3:method_name}\n\t\t${4}\n\tend\n\n\nend"
|
|
||||||
exe "Snipp! cla \"class BlankSlate .. initialize .. end\" class ${1:BlankSlate}\n\tinstance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }"
|
|
||||||
\ ."\n\n\tdef initialize(${2:args})\n\t\t@${3:delegate} = ${4:$3_object}\n\n\t\t${5}\n\tend\n\n\tdef method_missing(meth, *args, &block)\n\t\t@$3.send(meth, *args, &block)\n\tend\n\n\nend"
|
|
||||||
exe "Snipp! cla \"class << self .. end\" class << ${1:self}\n\t${2}\nend"
|
|
||||||
" class .. < DelegateClass .. initialize .. end
|
|
||||||
exe "Snipp cla- class ${1:`substitute(Filename(), '^.', '\\u&', '')`} < DelegateClass(${2:ParentClass})\n\tdef initialize(${3:args})\n\t\tsuper(${4:del_obj})\n\n\t\t${5}\n\tend\n\n\nend"
|
|
||||||
exe "Snipp! mod \"module .. end\" module ${1:`substitute(Filename(), '^.', '\\u&', '')`}\n\t${2}\nend"
|
|
||||||
exe "Snipp! mod \"module .. module_function .. end\" module ${1:`substitute(Filename(), '^.', '\\u&', '')`}\n\tmodule_function\n\n\t${2}\nend"
|
|
||||||
exe "Snipp! mod \"module .. ClassMethods .. end\" module ${1:`substitute(Filename(), '^.', '\\u&', '')`}\n\tmodule ClassMethods\n\t\t${2}\n\tend\n\n\t"
|
|
||||||
\."module InstanceMethods\n\n\tend\n\n\tdef self.included(receiver)\n\t\treceiver.extend ClassMethods\n\t\treseiver.send :include, InstanceMethods\n\tend\nend"
|
|
||||||
" attr_reader
|
|
||||||
exe 'Snipp r attr_reader :${1:attr_names}'
|
|
||||||
" attr_writer
|
|
||||||
exe 'Snipp w attr_writer :${1:attr_names}'
|
|
||||||
" attr_accessor
|
|
||||||
exe 'Snipp rw attr_accessor :${1:attr_names}'
|
|
||||||
" include Enumerable
|
|
||||||
exe "Snipp Enum include Enumerable\n\ndef each(&block)\n\t${1}\nend"
|
|
||||||
" include Comparable
|
|
||||||
exe "Snipp Comp include Comparable\n\ndef <=>(other)\n\t${1}\nend"
|
|
||||||
" extend Forwardable
|
|
||||||
exe 'Snipp Forw- extend Forwardable'
|
|
||||||
" def self
|
|
||||||
exe "Snipp defs def self.${1:class_method_name}\n\t${2}\nend"
|
|
||||||
" def method_missing
|
|
||||||
exe "Snipp defmm def method_missing(meth, *args, &blk)\n\t${1}\nend"
|
|
||||||
exe 'Snipp defd def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}'
|
|
||||||
exe 'Snipp defds def_delegators :${1:@del_obj}, :${2:del_methods}'
|
|
||||||
exe 'Snipp am alias_method :${1:new_name}, :${2:old_name}'
|
|
||||||
exe "Snipp app if __FILE__ == $PROGRAM_NAME\n\t${1}\nend"
|
|
||||||
" usage_if()
|
|
||||||
exe "Snipp usai if ARGV.${1}\n\tabort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}\nend"
|
|
||||||
" usage_unless()
|
|
||||||
exe "Snipp usau unless ARGV.${1}\n\tabort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}\nend"
|
|
||||||
exe 'Snipp array Array.new(${1:10}) { |${2:i}| ${3} }'
|
|
||||||
exe 'Snipp hash Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }'
|
|
||||||
exe 'Snipp! file "File.foreach() { |line| .. }" File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }'
|
|
||||||
exe 'Snipp! file "File.read()" File.read(${1:"path/to/file"})${2}'
|
|
||||||
exe 'Snipp! Dir "Dir.global() { |file| .. }" Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }'
|
|
||||||
exe 'Snipp! Dir "Dir[''..'']" Dir[${1:"glob/**/*.rb"}]${2}'
|
|
||||||
exe 'Snipp dir Filename.dirname(__FILE__)'
|
|
||||||
exe 'Snipp deli delete_if { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp fil fill(${1:range}) { |${2:i}| ${3} }'
|
|
||||||
" flatten_once()
|
|
||||||
exe 'Snipp flao inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}'
|
|
||||||
exe 'Snipp zip zip(${1:enums}) { |${2:row}| ${3} }'
|
|
||||||
" downto(0) { |n| .. }
|
|
||||||
exe 'Snipp dow downto(${1:0}) { |${2:n}| ${3} }'
|
|
||||||
exe 'Snipp ste step(${1:2}) { |${2:n}| ${3} }'
|
|
||||||
exe 'Snipp tim times { |${1:n}| ${2} }'
|
|
||||||
exe 'Snipp upt upto(${1:1.0/0.0}) { |${2:n}| ${3} }'
|
|
||||||
exe 'Snipp loo loop { ${1} }'
|
|
||||||
exe 'Snipp ea each { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp eab each_byte { |${1:byte}| ${2} }'
|
|
||||||
exe 'Snipp! eac- "each_char { |chr| .. }" each_char { |${1:chr}| ${2} }'
|
|
||||||
exe 'Snipp! eac- "each_cons(..) { |group| .. }" each_cons(${1:2}) { |${2:group}| ${3} }'
|
|
||||||
exe 'Snipp eai each_index { |${1:i}| ${2} }'
|
|
||||||
exe 'Snipp eak each_key { |${1:key}| ${2} }'
|
|
||||||
exe 'Snipp eal each_line { |${1:line}| ${2} }'
|
|
||||||
exe 'Snipp eap each_pair { |${1:name}, ${2:val}| ${3} }'
|
|
||||||
exe 'Snipp eas- each_slice(${1:2}) { |${2:group}| ${3} }'
|
|
||||||
exe 'Snipp eav each_value { |${1:val}| ${2} }'
|
|
||||||
exe 'Snipp eawi each_with_index { |${1:e}, ${2:i}| ${3} }'
|
|
||||||
exe 'Snipp reve reverse_each { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp inj inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }'
|
|
||||||
exe 'Snipp map map { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp mapwi- enum_with_index.map { |${1:e}, ${2:i}| ${3} }'
|
|
||||||
exe 'Snipp sor sort { |a, b| ${1} }'
|
|
||||||
exe 'Snipp sorb sort_by { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp ran sort_by { rand }'
|
|
||||||
exe 'Snipp all all? { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp any any? { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp cl classify { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp col collect { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp det detect { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp fet fetch(${1:name}) { |${2:key}| ${3} }'
|
|
||||||
exe 'Snipp fin find { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp fina find_all { |${1:e}| ${2} }'
|
|
||||||
exe 'Snipp gre grep(${1:/pattern/}) { |${2:match}| ${3} }'
|
|
||||||
exe 'Snipp sub ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }'
|
|
||||||
exe 'Snipp sca scan(${1:/pattern/}) { |${2:match}| ${3} }'
|
|
||||||
exe 'Snipp max max { |a, b|, ${1} }'
|
|
||||||
exe 'Snipp min min { |a, b|, ${1} }'
|
|
||||||
exe 'Snipp par partition { |${1:e}|, ${2} }'
|
|
||||||
exe 'Snipp rej reject { |${1:e}|, ${2} }'
|
|
||||||
exe 'Snipp sel select { |${1:e}|, ${2} }'
|
|
||||||
exe 'Snipp lam lambda { |${1:args}| ${2} }'
|
|
||||||
exe "Snipp do do |${1:variable}|\n\t${2}\nend"
|
|
||||||
exe 'Snipp : :${1:key} => ${2:"value"}${3}'
|
|
||||||
exe 'Snipp ope open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }'
|
|
||||||
" path_from_here()
|
|
||||||
exe 'Snipp patfh File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}'
|
|
||||||
" unix_filter {}
|
|
||||||
exe "Snipp unif ARGF.each_line${1} do |${2:line}|\n\t${3}\nend"
|
|
||||||
" option_parse {}
|
|
||||||
exe "Snipp optp require \"optparse\"\n\noptions = {${1:default => \"args\"}}\n\nARGV.options do |opts|\n\topts.banner = \"Usage: #{File.basename($PROGRAM_NAME)}"
|
|
||||||
\."[OPTIONS] ${2:OTHER_ARGS}\"\n\n\topts.separator \"\"\n\topts.separator \"Specific Options:\"\n\n\t${3}\n\n\topts.separator \"Common Options:\"\n\n\t"
|
|
||||||
\."opts.on( \"-h\", \"--help\",\n \"Show this message.\" ) do\n\t\tputs opts\n\t\texit\n\tend\n\n\tbegin\n\t\topts.parse!\n\trescue\n\t\tputs opts\n\t\texit\n\tend\nend"
|
|
||||||
exe "Snipp opt opts.on( \"-${1:o}\", \"--${2:long-option-name}\", ${3:String},\n \"${4:Option description.}\") do |${5:opt}|\n\t${6}\nend"
|
|
||||||
exe "Snipp tc require \"test/unit\"\n\nrequire \"${1:library_file_name}\"\n\nclass Test${2:$1} < Test::Unit::TestCase\n\tdef test_${3:case_name}\n\t\t${4}\n\tend\nend"
|
|
||||||
exe "Snipp ts require \"test/unit\"\n\nrequire \"tc_${1:test_case_file}\"\nrequire \"tc_${2:test_case_file}\"${3}"
|
|
||||||
exe 'Snipp as assert(${1:test}, \"${2:Failure message.}\")${3}'
|
|
||||||
exe 'Snipp ase assert_equal(${1:expected}, ${2:actual})${3}'
|
|
||||||
exe 'Snipp asne assert_not_equal(${1:unexpected}, ${2:actual})${3}'
|
|
||||||
exe 'Snipp asid assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}'
|
|
||||||
exe 'Snipp asio assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}'
|
|
||||||
exe 'Snipp asko assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}'
|
|
||||||
exe 'Snipp asn assert_nil(${1:instance})${2}'
|
|
||||||
exe 'Snipp asnn assert_not_nil(${1:instance})${2}'
|
|
||||||
exe 'Snipp asm assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}'
|
|
||||||
exe 'Snipp asnm assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}'
|
|
||||||
exe 'Snipp aso assert_operator(${1:left}, :${2:operator}, ${3:right})${4}'
|
|
||||||
exe 'Snipp asr assert_raise(${1:Exception}) { ${2} }'
|
|
||||||
exe 'Snipp asnr assert_nothing_raised(${1:Exception}) { ${2} }'
|
|
||||||
exe 'Snipp asrt assert_respond_to(${1:object}, :${2:method})${3}'
|
|
||||||
exe 'Snipp! ass "assert_same(..)" assert_same(${1:expected}, ${2:actual})${3}'
|
|
||||||
exe 'Snipp! ass "assert_send(..)" assert_send([${1:object}, :${2:message}, ${3:args}])${4}'
|
|
||||||
exe 'Snipp asns assert_not_same(${1:unexpected}, ${2:actual})${3}'
|
|
||||||
exe 'Snipp ast assert_throws(:${1:expected}) { ${2} }'
|
|
||||||
exe 'Snipp asnt assert_nothing_thrown { ${1} }'
|
|
||||||
exe 'Snipp fl flunk("${1:Failure message.}")${2}'
|
|
||||||
" Benchmark.bmbm do .. end
|
|
||||||
exe "Snipp bm- TESTS = ${1:10_000}\nBenchmark.bmbm do |results|\n\t${2}\nend"
|
|
||||||
exe 'Snipp rep results.report("${1:name}:") { TESTS.times { ${2} }}'
|
|
||||||
" Marshal.dump(.., file)
|
|
||||||
exe 'Snipp Md File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}'
|
|
||||||
" Mashal.load(obj)
|
|
||||||
exe 'Snipp Ml File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}'
|
|
||||||
" deep_copy(..)
|
|
||||||
exe 'Snipp deec Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}'
|
|
||||||
exe 'Snipp Pn- PStore.new(${1:"file_name.pstore"})${2}'
|
|
||||||
exe 'Snipp tra transaction(${1:true}) { ${2} }'
|
|
||||||
" xmlread(..)
|
|
||||||
exe 'Snipp xml- REXML::Document.new(File.read(${1:"path/to/file"}))${2}'
|
|
||||||
" xpath(..) { .. }
|
|
||||||
exe "Snipp xpa elements.each(${1:\"//Xpath\"}) do |${2:node}|\n\t${3}\nend"
|
|
||||||
" class_from_name()
|
|
||||||
exe 'Snipp clafn split("::").inject(Object) { |par, const| par.const_get(const) }'
|
|
||||||
" singleton_class()
|
|
||||||
exe 'Snipp sinc class << self; self end'
|
|
||||||
exe "Snipp nam namespace :${1:`Filename()`} do\n\t${2}\nend"
|
|
||||||
exe "Snipp tas desc \"${1:Task description\}\"\ntask :${2:task_name => [:dependent, :tasks]} do\n\t${3}\nend"
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_sh_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_sh_snips = 1
|
|
||||||
let snippet_filetype = 'sh'
|
|
||||||
|
|
||||||
exe "Snipp if if [[ ${1:condition} ]]; then\n\t${2:#statements}\nfi"
|
|
||||||
exe "Snipp elif elif [[ ${1:condition} ]]; then\n\t${2:#statements}"
|
|
||||||
exe "Snipp for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\t${3:#statements}\ndone"
|
|
||||||
exe "Snipp wh while [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
|
|
||||||
exe "Snipp until [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
|
|
||||||
exe "Snipp case case ${1:word} in\n\t${2:pattern})\n\t\t${3};;\nesac"
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
if !exists('loaded_snips') || exists('s:did_tex_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_tex_snips = 1
|
|
||||||
let snippet_filetype = 'tex'
|
|
||||||
|
|
||||||
" \begin{}...\end{}
|
|
||||||
exe "Snipp begin \\begin{${1:env}}\n\t${2}\n\\end{$1}"
|
|
||||||
" Tabular
|
|
||||||
exe "Snipp tab \\begin{${1:tabular}}{${2:c}}\n${3}\n\\end{$1}"
|
|
||||||
" Align(ed)
|
|
||||||
exe "Snipp ali \\begin{align${1:ed}}\n\t${2}\n\\end{align$1}"
|
|
||||||
" Gather(ed)
|
|
||||||
exe "Snipp gat \\begin{gather${1:ed}}\n\t${2}\n\\end{gather$1}"
|
|
||||||
" Equation
|
|
||||||
exe "Snipp eq \\begin{equation}\n\t${1}\n\\end{equation}"
|
|
||||||
" Unnumbered Equation
|
|
||||||
exe "Snipp \\ \\\\[\n\t${1}\n\\\\]"
|
|
||||||
" Enumerate
|
|
||||||
exe "Snipp enum \\begin{enumerate}\n\t\\item ${1}\n\\end{enumerate}"
|
|
||||||
" Itemize
|
|
||||||
exe "Snipp item \\begin{itemize}\n\t\\item ${1}\n\\end{itemize}"
|
|
||||||
" Description
|
|
||||||
exe "Snipp desc \\begin{description}\n\t\\item[${1}] ${2}\n\\end{description}"
|
|
||||||
" Matrix
|
|
||||||
exe "Snipp mat \\begin{${1:p/b/v/V/B/small}matrix}\n\t${2}\n\\end{$1matrix}"
|
|
||||||
" Cases
|
|
||||||
exe "Snipp cas \\begin{cases}\n\t${1:equation}, &\\text{ if }${2:case}\\\\\n\t${3}\n\\end{cases}"
|
|
||||||
" Split
|
|
||||||
exe "Snipp spl \\begin{split}\n\t${1}\n\\end{split}"
|
|
||||||
" Part
|
|
||||||
exe "Snipp part \\part{${1:part name}} % (fold)\n\\label{prt:${2:$1}}\n${3}\n% part $2 (end)"
|
|
||||||
" Chapter
|
|
||||||
exe "Snipp cha \\chapter{${1:chapter name}} % (fold)\n\\label{cha:${2:$1}}\n${3}\n% chapter $2 (end)"
|
|
||||||
" Section
|
|
||||||
exe "Snipp sec \\section{${1:section name}} % (fold)\n\\label{sec:${2:$1}}\n${3}\n% section $2 (end)"
|
|
||||||
" Sub Section
|
|
||||||
exe "Snipp sub \\subsection{${1:subsection name}} % (fold)\n\\label{sub:${2:$1}}\n${3}\n% subsection $2 (end)"
|
|
||||||
" Sub Sub Section
|
|
||||||
exe "Snipp subs \\subsubsection{${1:subsubsection name}} % (fold)\n\\label{ssub:${2:$1}}\n${3}\n% subsubsection $2 (end)"
|
|
||||||
" Paragraph
|
|
||||||
exe "Snipp par \\paragraph{${1:paragraph name}} % (fold)\n\\label{par:${2:$1}}\n${3}\n% paragraph $2 (end)"
|
|
||||||
" Sub Paragraph
|
|
||||||
exe "Snipp subp \\subparagraph{${1:subparagraph name}} % (fold)\n\\label{subp:${2:$1}}\n${3}\n% subparagraph $2 (end)"
|
|
||||||
exe 'Snipp itd \item[${1:description}] ${2:item}'
|
|
||||||
exe 'Snipp figure ${1:Figure}~\ref{${2:fig:}}${3}'
|
|
||||||
exe 'Snipp table ${1:Table}~\ref{${2:tab:}}${3}'
|
|
||||||
exe 'Snipp listing ${1:Listing}~\ref{${2:list}}${3}'
|
|
||||||
exe 'Snipp section ${1:Section}~\ref{${2:sec:}}${3}'
|
|
||||||
exe 'Snipp page ${1:page}~\pageref{${2}}${3}'
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
if !exists('g:loaded_snips') || exists('s:did_vim_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_vim_snips = 1
|
|
||||||
let snippet_filetype = 'vim'
|
|
||||||
|
|
||||||
" snippets for making snippets :)
|
|
||||||
exe 'Snipp snip exe "Snipp ${1:trigger}"${2}'
|
|
||||||
exe "Snipp snipp exe 'Snipp ${1:trigger}'${2}"
|
|
||||||
exe 'Snipp bsnip exe "BufferSnip ${1:trigger}"${2}'
|
|
||||||
exe "Snipp bsnipp exe 'BufferSnip ${1:trigger}'${2}"
|
|
||||||
exe 'Snipp gsnip exe "GlobalSnip ${1:trigger}"${2}'
|
|
||||||
exe "Snipp gsnipp exe 'GlobalSnip ${1:trigger}'${2}"
|
|
||||||
exe "Snipp guard if !exists('g:loaded_snips') || exists('s:did_".
|
|
||||||
\ "${1:`substitute(expand(\"%:t:r\"), \"_snips\", \"\", \"\")`}_snips')\n\t"
|
|
||||||
\ "finish\nendif\nlet s:did_$1_snips = 1\nlet snippet_filetype = '$1'${2}"
|
|
||||||
|
|
||||||
exe "Snipp f fun ${1:function_name}()\n\t${2:\" code}\nendfun"
|
|
||||||
exe "Snipp for for ${1:needle} in ${2:haystack}\n\t${3:\" code}\nendfor"
|
|
||||||
exe "Snipp wh wh ${1:condition}\n\t${2:\" code}\nendw"
|
|
||||||
exe "Snipp if if ${1:condition}\n\t${2:\" code}\nendif"
|
|
||||||
exe "Snipp ife if ${1:condition}\n\t${2}\nelse\n\t${3}\nendif"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
if !exists('g:loaded_snips') || exists('s:did_snips')
|
|
||||||
fini
|
|
||||||
en
|
|
||||||
let s:did_snips = 1
|
|
||||||
|
|
||||||
" (c) holds no legal value ;)
|
|
||||||
exe 'GlobalSnip c) '.(&enc[:2] == 'utf' ? '©' : '(c)').' Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}'
|
|
||||||
exe 'GlobalSnip date `strftime("%Y-%m-%d")`'
|
|
||||||
@@ -12,8 +12,6 @@ snor ' b<bs>'
|
|||||||
snor <right> <esc>a
|
snor <right> <esc>a
|
||||||
snor <left> <esc>bi
|
snor <left> <esc>bi
|
||||||
|
|
||||||
au FileType objc,cpp,cs let &ft = expand('<amatch>').'.c'
|
|
||||||
|
|
||||||
" By default load snippets in ~/.vim/snippets/<filetype>
|
" By default load snippets in ~/.vim/snippets/<filetype>
|
||||||
if !exists('snippets_dir')
|
if !exists('snippets_dir')
|
||||||
let snippets_dir = $HOME.'/'.finddir('snippets', &rtp).'/'
|
let snippets_dir = $HOME.'/'.finddir('snippets', &rtp).'/'
|
||||||
@@ -23,12 +21,22 @@ if empty(snippets_dir) | finish | endif
|
|||||||
if isdirectory(snippets_dir.'_')
|
if isdirectory(snippets_dir.'_')
|
||||||
call ExtractSnips(snippets_dir.'_', '_')
|
call ExtractSnips(snippets_dir.'_', '_')
|
||||||
endif
|
endif
|
||||||
|
if filereadable(snippets_dir.'_.snippets')
|
||||||
|
call ExtractSnipsFile(snippets_dir.'_.snippets')
|
||||||
|
endif
|
||||||
|
|
||||||
au FileType * call GetSnippets(g:snippets_dir)
|
au FileType * call GetSnippets(g:snippets_dir)
|
||||||
fun GetSnippets(dir)
|
fun GetSnippets(dir)
|
||||||
for ft in split(&ft, '\.')
|
for ft in split(&ft, '\.')
|
||||||
if !exists('g:did_ft_'.ft) && isdirectory(a:dir.ft)
|
if !exists('g:did_ft_'.ft)
|
||||||
call ExtractSnips(a:dir.ft, ft)
|
if isdirectory(a:dir.ft)
|
||||||
|
call ExtractSnips(a:dir.ft, ft)
|
||||||
|
endif
|
||||||
|
if filereadable(a:dir.ft.'.snippets')
|
||||||
|
call ExtractSnipsFile(a:dir.ft.'.snippets')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
let g:did_ft_{ft} = 1
|
||||||
endfor
|
endfor
|
||||||
endf
|
endf
|
||||||
" vim:noet:sw=4:ts=4:ft=vim
|
" vim:noet:sw=4:ts=4:ft=vim
|
||||||
|
|||||||
98
convertSnip.py
Executable file
98
convertSnip.py
Executable file
@@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Converts command-based snippets to new file-based snippet syntax
|
||||||
|
# NOTE: This is only meant to help, it is not perfect! Check the file
|
||||||
|
# afterwards to make sure it's correct.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
def Usage():
|
||||||
|
print """\
|
||||||
|
Usage: convertSnips.py -h or --help Print this help and exit
|
||||||
|
or: convertSnips.py inputfile Print .snippets file
|
||||||
|
or: convertSnips.py inputfile outputfile Output to file"""
|
||||||
|
|
||||||
|
def FindSnippet(line):
|
||||||
|
"""\
|
||||||
|
Try to find a snippet in the given line. If it is found, return the
|
||||||
|
converted snippet; otherwise, return -1.\
|
||||||
|
"""
|
||||||
|
snippet = re.search("exe ['\"](GlobalSnip|Snipp)(!)? (\S+) (.*)['\"]", line)
|
||||||
|
if not snippet: return -1
|
||||||
|
trigger = snippet.group(3)
|
||||||
|
text = "\t" + snippet.group(4)
|
||||||
|
|
||||||
|
if snippet.group(2): # Process multi-snippet
|
||||||
|
endSnip = re.search('\s*\\\\"(.*?)\\\\"\s*(.*)', text)
|
||||||
|
|
||||||
|
if not endSnip:
|
||||||
|
endSnip = re.search('\s*"(.*?)"\s*(.*)', text)
|
||||||
|
if not endSnip: return -1
|
||||||
|
|
||||||
|
trigger += ' ' + endSnip.group(1) # Add name to snippet declaration
|
||||||
|
text = "\t" + endSnip.group(2)
|
||||||
|
|
||||||
|
return trigger + "\n" + text
|
||||||
|
|
||||||
|
newLines = []
|
||||||
|
|
||||||
|
def ProcessLine(line):
|
||||||
|
"""\
|
||||||
|
Search the line for a snippet or comment, and append it to newLines[]
|
||||||
|
if it is found.\
|
||||||
|
"""
|
||||||
|
|
||||||
|
snippet = FindSnippet(line)
|
||||||
|
if snippet == -1:
|
||||||
|
comment = re.match('^"(.*)', line)
|
||||||
|
if comment: newLines.append('#' + comment.group(1))
|
||||||
|
else:
|
||||||
|
newLines.append('snippet ' + snippet)
|
||||||
|
return snippet
|
||||||
|
|
||||||
|
def Output(lines, file = None):
|
||||||
|
outputLines = ''
|
||||||
|
for snippet in lines:
|
||||||
|
for line in snippet.split("\\n"):
|
||||||
|
line = re.sub('\\\\t', "\t", line)
|
||||||
|
line = re.sub('\\\\\\\\', '\\\\', line)
|
||||||
|
if not re.match('^(\#|snippet)', line):
|
||||||
|
line = "\t" + line
|
||||||
|
outputLines += line + "\n"
|
||||||
|
if file:
|
||||||
|
try:
|
||||||
|
output = open(file, 'w')
|
||||||
|
except IOError, error:
|
||||||
|
raise SystemExit('convertSnips.py: %s' % error)
|
||||||
|
output.write(outputLines)
|
||||||
|
else:
|
||||||
|
print outputLines,
|
||||||
|
|
||||||
|
def main(argv = None):
|
||||||
|
if argv is None: argv = sys.argv[1:]
|
||||||
|
if not argv or '-h' in argv or '--help' in argv:
|
||||||
|
Usage()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
input = open(argv[0], 'r')
|
||||||
|
except IOError, error:
|
||||||
|
raise SystemExit('convertSnips.py: %s' % error)
|
||||||
|
|
||||||
|
snippet = -1
|
||||||
|
for line in input.readlines():
|
||||||
|
if snippet == -1:
|
||||||
|
snippet = ProcessLine(line)
|
||||||
|
else:
|
||||||
|
concat = re.search("^\s+(\\\\\s*)?(\.\s*)?['\"](.*)['\"]", line)
|
||||||
|
if concat:
|
||||||
|
newLines[-1] += "\\n" + concat.group(3) # Add concatenated lines
|
||||||
|
else:
|
||||||
|
snippet = ProcessLine(line)
|
||||||
|
|
||||||
|
if len(argv) == 1: Output(newLines)
|
||||||
|
else: Output(newLines, argv[1])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
183
doc/snipMate.txt
183
doc/snipMate.txt
@@ -1,7 +1,7 @@
|
|||||||
*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: March 15, 2009
|
Last Change: March 22, 2009
|
||||||
|
|
||||||
|snipMate-description| Description
|
|snipMate-description| Description
|
||||||
|snipMate-usage| Usage
|
|snipMate-usage| Usage
|
||||||
@@ -37,122 +37,26 @@ highlighted and all the matches specified in the snippet will
|
|||||||
be updated.
|
be updated.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
USAGE *snipMate-usage*
|
SYNTAX *snippet-syntax*
|
||||||
|
|
||||||
There are currently two ways to make snippets: file-based and command-based.
|
Snippets can be defined in two ways. They can be in their own file, named
|
||||||
File-based snippets are simply *.snippet files named after the trigger of
|
after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be
|
||||||
the snippet placed in the directory of the filetype
|
defined together in a 'snippets/<filetype>.snippets' file.
|
||||||
(<filetype>/<trigger>.snippet); command-based snippets are snippets defined
|
|
||||||
using the |Snipp| , |BufferSnip|, and |GlobalSnip| commands. File-based
|
|
||||||
snippets have the advantage of being easier to read, but do not support
|
|
||||||
special characters in snippet triggers, while command-based snippets are
|
|
||||||
obviously convenient for short snippets but can quickly get unreadable.
|
|
||||||
|
|
||||||
*command-snippets*
|
The syntax for snippets in *.snippets files is the following: >
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Command Snippets~
|
|
||||||
|
|
||||||
Command-based snippets should be installed in the 'after' directory, typically
|
snippet trigger
|
||||||
located in '~/.vim/after' (see |vimfiles|). Filetype specific snippets should
|
expanded text
|
||||||
be installed in 'after/ftplugin', such as 'after/ftplugin/<filetype>_snips.vim'.
|
more expanded text
|
||||||
See |ftplugins|. Global snippets should be installed in 'after/plugin'.
|
|
||||||
To ensure user snippets are not lost when upgrading the plugin, name them
|
|
||||||
using an ending other than "snips" such as "<filetype>_mysnips.vim"
|
|
||||||
|
|
||||||
*g:snippet_filetype* *snippet_filetype*
|
Note that the first hard tab after the snippet trigger is required, and not
|
||||||
Partly due to the addition of file-based snippets, it is now necessary to
|
expanded in the actual snippet. The syntax for *.snippet files is the same,
|
||||||
define the current filetype for snippets at the top of command-based snippet
|
only without the trigger declaration and starting indentation.
|
||||||
files. For instance, at the top of the 'c_snips.vim' file included with
|
|
||||||
snipMate: >
|
|
||||||
|
|
||||||
let snippet_filetype = 'c'
|
Also note that snippets must be defined using hard tabs. They can be expanded
|
||||||
|
to spaces later if desired (see |snipMate-indenting|).
|
||||||
This ensures dotted filetypes (see 'filetype') are dealt with correctly.
|
|
||||||
|
|
||||||
*Snipp* *BufferSnip* *GlobalSnip*
|
|
||||||
Snipp, BufferSnip, and GlobalSnip Commands~
|
|
||||||
|
|
||||||
Snippets are added via the "Snipp" and "GlobalSnip" commands. The syntax for
|
|
||||||
these are "Snipp <trigger> <text>"; e.g.: >
|
|
||||||
|
|
||||||
exe "Snipp trigger The cursor will be placed at the end of this sentence."
|
|
||||||
exe "GlobalSnip another_trigger foo"
|
|
||||||
exe "BufferSnip bar This snippet only works for the current buffer."
|
|
||||||
|
|
||||||
"Snipp" creates snippets for the current filetype, "GlobalSnip" creates global
|
|
||||||
snippets, and "BufferSnip" creates snippets for the current buffer. "Snipp"
|
|
||||||
is used instead of "Snip" to avoid conflicts with the imaps.vim vim script
|
|
||||||
that uses that command name.
|
|
||||||
|
|
||||||
These commands are conveniently bound to snippets themselves; "snip", "bsnip",
|
|
||||||
and "gsnip", respectively (in vim files). So to expand a Snipp command with
|
|
||||||
double quotes, just type snip<tab>. Single quote Snipp and GlobalSnip
|
|
||||||
commands are bound to the snippets "snipp", "bsnipp" and "gsnipp". See
|
|
||||||
|literal-string| for the difference between single and double quotes.
|
|
||||||
|
|
||||||
*multi_snip* *Snipp!* *BufferSnip!* *GlobalSnip!*
|
|
||||||
To specify that a snippet can have multiple matches, use the Snipp,
|
|
||||||
BufferSnip, or GlobalSnip command followed by a bang (!). The syntax for these
|
|
||||||
are 'Snipp! <trigger> "<name>" <text>'. (Note that the name must be enclosed
|
|
||||||
in double quotes). E.g.: >
|
|
||||||
|
|
||||||
exe 'Snipp! trigger "Snippet name #1" expand_this_text'
|
|
||||||
exe 'Snipp! trigger "Snippet name #2" expand_THIS_text!'
|
|
||||||
|
|
||||||
In this example, when "trigger<tab>" is typed, a numbered menu containing all
|
|
||||||
of the names for the "trigger" will be shown; when the user presses the
|
|
||||||
corresponding number, that snippet will then be expanded.
|
|
||||||
|
|
||||||
To create a create a snippet with multiple matches using file-based snippets,
|
|
||||||
simply place all the snippets in a subdirectory with the trigger name, i.e.
|
|
||||||
'snippets/<filetype>/<trigger>/<name>.snippet'.
|
|
||||||
|
|
||||||
To ensure snipMate.vim is loaded, 'compatible' is not set, and your snippet
|
|
||||||
file is only loaded once make sure to add: >
|
|
||||||
|
|
||||||
if !exists('g:loaded_snips') || exists('s:did_my_snips')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:did_my_snips = 1
|
|
||||||
|
|
||||||
to the top of your snippets files. The snippet "guard" comes with snipMate to
|
|
||||||
automate this if you'd rather not type it all out.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
*file-snippets*
|
|
||||||
File Snippets ~
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
*'snippets'* *g:snippets_dir*
|
|
||||||
File-based snippets are by default looked for in the 'snippets' directory
|
|
||||||
inside your home '.vim' directory, typically located in
|
|
||||||
'~/.vim/snippets/<filetype>' on *nix or '$HOME\vimfiles\snippets\<filetype>'
|
|
||||||
on Windows. To change that location or add another one, change the
|
|
||||||
g:snippets_dir variable in your |.vimrc| to your preferred directory, or use
|
|
||||||
the |ExtractSnips()|function. NOTE: g:snippets_dir must end in a backslash or
|
|
||||||
forward slash.
|
|
||||||
|
|
||||||
File-based snippets have the same syntax as command-based snippets; just make
|
|
||||||
sure to use hard tabs instead of spaces in the files for indenting. They can
|
|
||||||
be automatically converted later if desired (see |snipMate-indenting|).
|
|
||||||
|
|
||||||
ExtractSnips({directory}, {filetype}) *ExtractSnips()*
|
|
||||||
|
|
||||||
ExtractSnips() extracts *.snippet files from the specified directory and
|
|
||||||
defines them as snippets for the given filetype; to define a global snippet,
|
|
||||||
use '_' for the {filetype} argument.
|
|
||||||
|
|
||||||
*ResetSnips()*
|
|
||||||
The ResetSnips() function removes all snippets from memory. This is useful to
|
|
||||||
put at the top of a snippet setup file for file-based snippets if you would
|
|
||||||
like to |:source| it multiple times.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
SYNTAX *snipMate-syntax* *snipMate-${#}*
|
|
||||||
|
|
||||||
|
*snipMate-${#}*
|
||||||
Tab stops ~
|
Tab stops ~
|
||||||
|
|
||||||
By default, the cursor is placed at the end of a snippet. To specify where the
|
By default, the cursor is placed at the end of a snippet. To specify where the
|
||||||
@@ -224,18 +128,65 @@ empty string if it hasn't. The second returns the filename if it's been named,
|
|||||||
and "name" if it hasn't. The third returns the filename followed by "_foo" if
|
and "name" if it hasn't. The third returns the filename followed by "_foo" if
|
||||||
it has been named, and an empty string if it hasn't.
|
it has been named, and an empty string if it hasn't.
|
||||||
|
|
||||||
*snipMate-settings* *g:snips_author*
|
*multi_snip*
|
||||||
|
To specify that a snippet can have multiple matches in a *.snippets file, use
|
||||||
|
this syntax: >
|
||||||
|
|
||||||
|
snippet trigger A description of snippet #1
|
||||||
|
expand this text
|
||||||
|
snippet trigger A description of snippet #2
|
||||||
|
expand THIS text!
|
||||||
|
|
||||||
|
In this example, when "trigger<tab>" is typed, a numbered menu containing all
|
||||||
|
of the descriptions of the "trigger" will be shown; when the user presses the
|
||||||
|
corresponding number, that snippet will then be expanded.
|
||||||
|
|
||||||
|
To create a create a snippet with multiple matches using *.snippet files,
|
||||||
|
simply place all the snippets in a subdirectory with the trigger name:
|
||||||
|
'snippets/<filetype>/<trigger>/<name>.snippet'.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
USAGE *snipMate-usage*
|
||||||
|
|
||||||
|
*'snippets'* *g:snippets_dir*
|
||||||
|
Snippets are by default looked for in the 'snippets' directory inside your
|
||||||
|
home '.vim' directory, typically located at '~/.vim/snippets/' on *nix or
|
||||||
|
'$HOME\vimfiles\snippets\' on Windows. To change that location or add another
|
||||||
|
one, change the g:snippets_dir variable in your |.vimrc| to your preferred
|
||||||
|
directory, or use the |ExtractSnips()|function. NOTE: g:snippets_dir must
|
||||||
|
end in a slash.
|
||||||
|
|
||||||
|
ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets*
|
||||||
|
|
||||||
|
ExtractSnipsFile() extracts the specified *.snippets file for the given
|
||||||
|
filetype. A .snippets file contains multiple snippet declarations for the
|
||||||
|
filetype. It is further explained above, in |snippet-syntax|.
|
||||||
|
|
||||||
|
ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet*
|
||||||
|
|
||||||
|
ExtractSnips() extracts *.snippet files from the specified directory and
|
||||||
|
defines them as snippets for the given filetype. The directory tree should
|
||||||
|
look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
|
||||||
|
multiple matches, it should look like this:
|
||||||
|
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||||
|
|
||||||
|
*ResetSnips()*
|
||||||
|
The ResetSnips() function removes all snippets from memory. This is useful to
|
||||||
|
put at the top of a snippet setup file for if you would like to |:source| it
|
||||||
|
multiple times.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
SETTINGS *snipMate-settings* *g:snips_author*
|
||||||
The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
|
The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
|
||||||
to your name; it can then be used in snippets to automatically add it. E.g.: >
|
to your name; it can then be used in snippets to automatically add it. E.g.: >
|
||||||
|
|
||||||
let g:snips_author = 'Hubert Farnsworth'
|
let g:snips_author = 'Hubert Farnsworth'
|
||||||
exe 'Snipp name `g:snips_author`'
|
exe 'Snipp name `g:snips_author`'
|
||||||
<
|
<
|
||||||
|
|
||||||
*snipMate-expandtab* *snipMate-indenting*
|
*snipMate-expandtab* *snipMate-indenting*
|
||||||
If you would like your snippets to use spaces instead of tabs, just enable
|
If you would like your snippets to be expanded using spaces instead of tabs,
|
||||||
'expandtab' and set 'softtabstop' to your preferred amount of spaces. If
|
just enable 'expandtab' and set 'softtabstop' to your preferred amount of
|
||||||
'softtabstop' is not set, 'shiftwidth' is used instead.
|
spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
|
||||||
|
|
||||||
*snipMate-remap*
|
*snipMate-remap*
|
||||||
snipMate does not come with a setting to customize the trigger key, but you
|
snipMate does not come with a setting to customize the trigger key, but you
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ endif
|
|||||||
let loaded_snips = 1
|
let loaded_snips = 1
|
||||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||||
|
|
||||||
com! -nargs=+ -bang Snipp call s:MakeSnippet(<q-args>, snippet_filetype, <bang>0)
|
au FileType objc,cpp,cs let &ft = expand('<amatch>').'.c'
|
||||||
com! -nargs=+ -bang BufferSnip call s:MakeSnippet(<q-args>, bufnr('%'), <bang>0)
|
au FileType xhtml let &ft = expand('<amatch>').'.html'
|
||||||
com! -nargs=+ -bang GlobalSnip call s:MakeSnippet(<q-args>, '_', <bang>0)
|
au BufRead,BufNewFile *.snippets\= set ft=snippet
|
||||||
|
au FileType snippet setl noet fdm=indent
|
||||||
|
|
||||||
|
" These are just here to avoid errors, for now
|
||||||
|
com! -nargs=+ -bang Snipp
|
||||||
|
com! -nargs=+ -bang GlobalSnip
|
||||||
|
com! -nargs=+ -bang BufferSnip
|
||||||
|
|
||||||
let s:snippets = {} | let s:multi_snips = {}
|
let s:snippets = {} | let s:multi_snips = {}
|
||||||
|
|
||||||
@@ -27,30 +33,16 @@ fun! Filename(...)
|
|||||||
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
|
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun s:MakeSnippet(text, scope, multisnip)
|
fun! MakeSnip(scope, trigger, content, ...)
|
||||||
let space = stridx(a:text, ' ')
|
let multisnip = a:0 && a:1 != ''
|
||||||
let trigger = strpart(a:text, 0, space)
|
let var = multisnip ? 's:multi_snips' : 's:snippets'
|
||||||
if a:multisnip
|
|
||||||
let space += 2
|
|
||||||
let quote = stridx(a:text, '"', space)
|
|
||||||
let name = strpart(a:text, space, quote-space)
|
|
||||||
let space = stridx(a:text, ' ', quote)
|
|
||||||
let var = 's:multi_snips'
|
|
||||||
else
|
|
||||||
let var = 's:snippets'
|
|
||||||
endif
|
|
||||||
if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
|
if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
|
||||||
let end = strpart(a:text, space + 1)
|
if !has_key({var}[a:scope], a:trigger)
|
||||||
|
let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content
|
||||||
if end == '' || space == '' || (a:multisnip && name == '')
|
elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]]
|
||||||
echom 'Error in snipMate.vim: Snippet '.a:text.' is undefined.'
|
|
||||||
elseif !has_key({var}[a:scope], trigger)
|
|
||||||
let {var}[a:scope][trigger] = a:multisnip ? [[name, end]] : end
|
|
||||||
elseif a:multisnip | let {var}[a:scope][trigger] += [[name, end]]
|
|
||||||
else
|
else
|
||||||
echom 'Warning in snipMate.vim: Snippet '.strpart(a:text, 0, stridx(a:text, ' '))
|
echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.'
|
||||||
\ .' is already defined. See :h multi_snip for help on snippets'
|
\ .' See :h multi_snip for help on snippets with multiple matches.'
|
||||||
\ .' with multiple matches.'
|
|
||||||
endif
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@@ -65,11 +57,10 @@ fun! ExtractSnips(dir, ft)
|
|||||||
call s:ProcessFile(path, a:ft)
|
call s:ProcessFile(path, a:ft)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let g:did_ft_{a:ft} = 1
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" Processes a snippet file; optionally add the name of the parent directory
|
" Processes a single-snippet file; optionally add the name of the parent
|
||||||
" for a snippet with multiple matches.
|
" directory for a snippet with multiple matches.
|
||||||
fun s:ProcessFile(file, ft, ...)
|
fun s:ProcessFile(file, ft, ...)
|
||||||
let keyword = fnamemodify(a:file, ':t:r')
|
let keyword = fnamemodify(a:file, ':t:r')
|
||||||
if keyword == '' | return | endif
|
if keyword == '' | return | endif
|
||||||
@@ -78,8 +69,38 @@ fun s:ProcessFile(file, ft, ...)
|
|||||||
catch /E484/
|
catch /E484/
|
||||||
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||||
endtry
|
endtry
|
||||||
return a:0 ? s:MakeSnippet(a:1.' "'.keyword.'" '.text, a:ft, 1)
|
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
|
||||||
\ : s:MakeSnippet(keyword.' '.text, a:ft, 0)
|
\ : MakeSnip(a:ft, keyword, text)
|
||||||
|
endf
|
||||||
|
|
||||||
|
fun! ExtractSnipsFile(file)
|
||||||
|
if !filereadable(a:file)
|
||||||
|
return echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||||
|
endif
|
||||||
|
let text = readfile(a:file)
|
||||||
|
let ft = fnamemodify(a:file, ':t:r')
|
||||||
|
let inSnip = 0
|
||||||
|
for line in text + ["\n"]
|
||||||
|
if inSnip && (line == '' || strpart(line, 0, 1) == "\t")
|
||||||
|
let content .= strpart(line, 1)."\n"
|
||||||
|
continue
|
||||||
|
elseif inSnip
|
||||||
|
call MakeSnip(ft, trigger, content[:-2], name)
|
||||||
|
let inSnip = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
if stridx(line, 'snippet') == 0
|
||||||
|
let inSnip = 1
|
||||||
|
let trigger = strpart(line, 8)
|
||||||
|
let name = ''
|
||||||
|
let space = stridx(trigger, ' ') + 1
|
||||||
|
if space " Process multi snip
|
||||||
|
let name = strpart(trigger, space)
|
||||||
|
let trigger = strpart(trigger, 0, space - 1)
|
||||||
|
endif
|
||||||
|
let content = ''
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! ResetSnippets()
|
fun! ResetSnippets()
|
||||||
@@ -105,7 +126,8 @@ endf
|
|||||||
fun! TriggerSnippet()
|
fun! TriggerSnippet()
|
||||||
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
||||||
if exists('s:sid') | return "\<c-n>" | endif
|
if exists('s:sid') | return "\<c-n>" | endif
|
||||||
call feedkeys("\<esc>a", 'n') | call s:UpdateChangedSnip(0)
|
call feedkeys("\<esc>a", 'n')
|
||||||
|
return ''
|
||||||
endif
|
endif
|
||||||
if !exists('s:sid') && exists('g:SuperTabMappingForward')
|
if !exists('s:sid') && exists('g:SuperTabMappingForward')
|
||||||
\ && g:SuperTabMappingForward == "<tab>"
|
\ && g:SuperTabMappingForward == "<tab>"
|
||||||
@@ -149,7 +171,7 @@ fun s:GetSnippet(word, scope)
|
|||||||
wh !exists('s:snippet')
|
wh !exists('s:snippet')
|
||||||
if exists('s:snippets["'.a:scope.'"]['''.word.''']')
|
if exists('s:snippets["'.a:scope.'"]['''.word.''']')
|
||||||
let s:snippet = s:snippets[a:scope][word]
|
let s:snippet = s:snippets[a:scope][word]
|
||||||
elseif exists('s:multi_snips["'.a:scope.'"]["'.word.'"]')
|
elseif exists('s:multi_snips["'.a:scope.'"]['''.word.''']')
|
||||||
let s:snippet = s:ChooseSnippet(a:scope, word)
|
let s:snippet = s:ChooseSnippet(a:scope, word)
|
||||||
else
|
else
|
||||||
if match(word, '\W') == -1 | break | endif
|
if match(word, '\W') == -1 | break | endif
|
||||||
@@ -317,7 +339,7 @@ fun s:BuildTabStops(lnum, col, indent)
|
|||||||
else
|
else
|
||||||
let s:snipPos = snipPos
|
let s:snipPos = snipPos
|
||||||
endif
|
endif
|
||||||
return i-1
|
return i - 1
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun s:JumpTabStop()
|
fun s:JumpTabStop()
|
||||||
|
|||||||
7
snippets/_.snippets
Normal file
7
snippets/_.snippets
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Global snippets
|
||||||
|
|
||||||
|
# (c) holds no legal value ;)
|
||||||
|
snippet c)
|
||||||
|
`&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
|
||||||
|
snippet date
|
||||||
|
`strftime("%Y-%m-%d")`
|
||||||
88
snippets/c.snippets
Normal file
88
snippets/c.snippets
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# main()
|
||||||
|
snippet main
|
||||||
|
int main (int argc, char const* argv[])
|
||||||
|
{
|
||||||
|
${1}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
# #include <...>
|
||||||
|
snippet inc
|
||||||
|
#include <${1:stdio}.h>${2}
|
||||||
|
# #include "..."
|
||||||
|
snippet Inc
|
||||||
|
#include "${1:`Filename("$1.h")`}"${2}
|
||||||
|
# #ifndef ... #define ... #endif
|
||||||
|
snippet def
|
||||||
|
#ifndef $1
|
||||||
|
#define ${1:SYMBOL} ${2:value}
|
||||||
|
#endif${3}
|
||||||
|
# Header Include-Guard
|
||||||
|
# (the randomizer code is taken directly from TextMate; it could probably be
|
||||||
|
# cleaner, I don't know how to do it in vim script)
|
||||||
|
snippet once
|
||||||
|
#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`}
|
||||||
|
|
||||||
|
#define $1
|
||||||
|
|
||||||
|
${2}
|
||||||
|
|
||||||
|
#endif /* end of include guard: $1 */
|
||||||
|
# If Condition
|
||||||
|
snippet if
|
||||||
|
if (${1:/* condition */}) {
|
||||||
|
${2:/* code */}
|
||||||
|
}
|
||||||
|
snippet el
|
||||||
|
else {
|
||||||
|
${1}
|
||||||
|
}
|
||||||
|
# Tertiary conditional
|
||||||
|
snippet t
|
||||||
|
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||||
|
# Do While Loop
|
||||||
|
snippet do
|
||||||
|
do {
|
||||||
|
${2:/* code */}
|
||||||
|
} while (${1:/* condition */});
|
||||||
|
# While Loop
|
||||||
|
snippet wh
|
||||||
|
while (${1:/* condition */}) {
|
||||||
|
${2:/* code */}
|
||||||
|
}
|
||||||
|
# For Loop
|
||||||
|
snippet for
|
||||||
|
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||||
|
${4:/* code */}
|
||||||
|
}
|
||||||
|
# Custom For Loop
|
||||||
|
snippet forr
|
||||||
|
for (${1:i} = 0; ${2:$1 < 10}; $1${3:++}) {
|
||||||
|
${4:/* code */}
|
||||||
|
}
|
||||||
|
# Function
|
||||||
|
snippet fun
|
||||||
|
${1:void} ${2:function_name} (${3})
|
||||||
|
{
|
||||||
|
${4:/* code */}
|
||||||
|
}
|
||||||
|
# Typedef
|
||||||
|
snippet td
|
||||||
|
typedef ${1:int} ${2:MyCustomType};
|
||||||
|
# Struct
|
||||||
|
snippet st
|
||||||
|
struct ${1:`Filename('$1_t', 'name')`} {
|
||||||
|
${2:/* data */}
|
||||||
|
}${3: /* optional variable list */};${4}
|
||||||
|
# Typedef struct
|
||||||
|
snippet tds
|
||||||
|
typedef struct ${2:$1 }{
|
||||||
|
${3:/* data */}
|
||||||
|
} ${1:`Filename('$1_t', 'name')`};
|
||||||
|
# printf
|
||||||
|
# unfortunately version this isn't as nice as TextMates's, given the lack of a
|
||||||
|
# dynamic `...`
|
||||||
|
snippet pr
|
||||||
|
printf("${1:%s}\n"${2});${3}
|
||||||
|
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||||
|
snippet fpr
|
||||||
|
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
||||||
31
snippets/cpp.snippets
Normal file
31
snippets/cpp.snippets
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Read File Into Vector
|
||||||
|
snippet readfile
|
||||||
|
std::vector<char> v;
|
||||||
|
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
|
||||||
|
char buf[1024];
|
||||||
|
while (size_t len =
|
||||||
|
fread(buf, 1, sizeof(buf), $2))
|
||||||
|
v.insert(v.end(), buf, buf + len);
|
||||||
|
fclose($2);
|
||||||
|
}${3}
|
||||||
|
# std::map
|
||||||
|
snippet map
|
||||||
|
std::map<${1:key}, ${2:value}> map${3};
|
||||||
|
# std::vector
|
||||||
|
snippet vector
|
||||||
|
std::vector<${1:char}> v${2};
|
||||||
|
# Namespace
|
||||||
|
snippet ns
|
||||||
|
namespace ${1:`Filename('', 'my')`} {
|
||||||
|
${2}
|
||||||
|
} /* $1 */
|
||||||
|
# Class
|
||||||
|
snippet cl
|
||||||
|
class ${1:`Filename('$1_t', 'name')`} {
|
||||||
|
public:
|
||||||
|
$1 (${2:arguments});
|
||||||
|
virtual ~$1 ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
${3:/* data */}
|
||||||
|
};
|
||||||
190
snippets/html.snippets
Normal file
190
snippets/html.snippets
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
# Some useful Unicode entities
|
||||||
|
# Non-Breaking Space
|
||||||
|
snippet nbs
|
||||||
|
|
||||||
|
# ←
|
||||||
|
snippet left
|
||||||
|
←
|
||||||
|
# →
|
||||||
|
snippet right
|
||||||
|
→
|
||||||
|
# ↑
|
||||||
|
snippet up
|
||||||
|
↑
|
||||||
|
# ↓
|
||||||
|
snippet down
|
||||||
|
↓
|
||||||
|
# ↩
|
||||||
|
snippet return
|
||||||
|
↩
|
||||||
|
# ⇤
|
||||||
|
snippet backtab
|
||||||
|
⇤
|
||||||
|
# ⇥
|
||||||
|
snippet tab
|
||||||
|
⇥
|
||||||
|
# ⇧
|
||||||
|
snippet shift
|
||||||
|
⇧
|
||||||
|
# ⌃
|
||||||
|
snippet control
|
||||||
|
⌃
|
||||||
|
# ⌅
|
||||||
|
snippet enter
|
||||||
|
⌅
|
||||||
|
# ⌘
|
||||||
|
snippet command
|
||||||
|
⌘
|
||||||
|
# ⌥
|
||||||
|
snippet option
|
||||||
|
⌥
|
||||||
|
# ⌦
|
||||||
|
snippet delete
|
||||||
|
⌦
|
||||||
|
# ⌫
|
||||||
|
snippet backspace
|
||||||
|
⌫
|
||||||
|
# ⎋
|
||||||
|
snippet escape
|
||||||
|
⎋
|
||||||
|
# Generic Doctype
|
||||||
|
snippet doctype HTML 4.01 Strict
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||||
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
snippet doctype HTML 4.01 Transitional
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
snippet doctype HTML 5
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
snippet doctype XHTML 1.0 Frameset
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
snippet doctype XHTML 1.0 Strict
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
snippet doctype XHTML 1.0 Transitional
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
snippet doctype XHTML 1.1
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
# HTML Doctype 4.01 Strict
|
||||||
|
snippet docts
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||||
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
# HTML Doctype 4.01 Transitional
|
||||||
|
snippet doct
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
# HTML Doctype 5
|
||||||
|
snippet doct5
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
# XHTML Doctype 1.0 Frameset
|
||||||
|
snippet docxf
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||||
|
# XHTML Doctype 1.0 Strict
|
||||||
|
snippet docxs
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
# XHTML Doctype 1.0 Transitional
|
||||||
|
snippet docxt
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
# XHTML Doctype 1.1
|
||||||
|
snippet docx
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
snippet html
|
||||||
|
<html>
|
||||||
|
${1}
|
||||||
|
</html>
|
||||||
|
snippet xhtml
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
${1}
|
||||||
|
</html>
|
||||||
|
snippet body
|
||||||
|
<body>
|
||||||
|
${1}
|
||||||
|
</body>
|
||||||
|
snippet head
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`>
|
||||||
|
|
||||||
|
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||||
|
${2}
|
||||||
|
</head>
|
||||||
|
snippet title
|
||||||
|
<title>${1:`substitute(Filename("", "Page Title"), "^.", "\u&", "")`}</title>${2}
|
||||||
|
snippet script
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
${1}
|
||||||
|
</script>${2}
|
||||||
|
snippet scriptsrc
|
||||||
|
<script src="${1}.js" type="text/javascript" charset="utf-8"></script>${2}
|
||||||
|
snippet style
|
||||||
|
<style type="text/css" media="${1:screen}">
|
||||||
|
${2}
|
||||||
|
</style>${3}
|
||||||
|
snippet base
|
||||||
|
<base href="${1}" target="${2}"`Close()`>
|
||||||
|
snippet r
|
||||||
|
<br`Close()[1:]`>
|
||||||
|
snippet div
|
||||||
|
<div id="${1:name}">
|
||||||
|
${2}
|
||||||
|
</div>
|
||||||
|
# Embed QT Movie
|
||||||
|
snippet movie
|
||||||
|
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
|
||||||
|
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||||
|
<param name="src" value="$1"`Close()`>
|
||||||
|
<param name="controller" value="$4"`Close()`>
|
||||||
|
<param name="autoplay" value="$5"`Close()`>
|
||||||
|
<embed src="${1:movie.mov}"
|
||||||
|
width="${2:320}" height="${3:240}"
|
||||||
|
controller="${4:true}" autoplay="${5:true}"
|
||||||
|
scale="tofit" cache="true"
|
||||||
|
pluginspage="http://www.apple.com/quicktime/download/"
|
||||||
|
`Close()[1:]`>
|
||||||
|
</object>${6}
|
||||||
|
snippet fieldset
|
||||||
|
<fieldset id="$1">
|
||||||
|
<legend>${1:name}</legend>
|
||||||
|
|
||||||
|
${3}
|
||||||
|
</fieldset>
|
||||||
|
snippet form
|
||||||
|
<form action="${1:`Filename('$1_submit')`}" method="${2:get}" accept-charset="utf-8">
|
||||||
|
${3}
|
||||||
|
|
||||||
|
|
||||||
|
<p><input type="submit" value="Continue →"`Close()`></p>
|
||||||
|
</form>
|
||||||
|
snippet h1
|
||||||
|
<h1 id="${1:heading}">${2:$1}</h1>
|
||||||
|
snippet input
|
||||||
|
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"`Close()`>${4}
|
||||||
|
snippet label
|
||||||
|
<label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"`Close()`>${7}
|
||||||
|
snippet link
|
||||||
|
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"`Close()`>${4}
|
||||||
|
snippet mailto
|
||||||
|
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
||||||
|
snippet meta
|
||||||
|
<meta name="${1:name}" content="${2:content}"`Close()`>${3}
|
||||||
|
snippet opt
|
||||||
|
<option value="${1:option}">${2:$1}</option>${3}
|
||||||
|
snippet optt
|
||||||
|
<option>${1:option}</option>${2}
|
||||||
|
snippet select
|
||||||
|
<select name="${1:some_name}" id="${2:$1}">
|
||||||
|
<option value="${3:option}">${4:$3}</option>
|
||||||
|
</select>${5}
|
||||||
|
snippet table
|
||||||
|
<table border="${1:0}">
|
||||||
|
<tr><th>${2:Header}</th></tr>
|
||||||
|
<tr><th>${3:Data}</th></tr>
|
||||||
|
</table>${4}
|
||||||
|
snippet textarea
|
||||||
|
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}
|
||||||
78
snippets/java.snippets
Normal file
78
snippets/java.snippets
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
snippet main
|
||||||
|
public static void main (String [] args)
|
||||||
|
{
|
||||||
|
${1:/* code */}
|
||||||
|
}
|
||||||
|
snippet pu
|
||||||
|
public
|
||||||
|
snippet po
|
||||||
|
protected
|
||||||
|
snippet pr
|
||||||
|
private
|
||||||
|
snippet st
|
||||||
|
static
|
||||||
|
snippet fi
|
||||||
|
final
|
||||||
|
snippet ab
|
||||||
|
abstract
|
||||||
|
snippet re
|
||||||
|
return
|
||||||
|
snippet br
|
||||||
|
break;
|
||||||
|
snippet de
|
||||||
|
default:
|
||||||
|
${1}
|
||||||
|
snippet ca
|
||||||
|
catch(${1:Exception} ${2:e}) ${3}
|
||||||
|
snippet th
|
||||||
|
throw
|
||||||
|
snippet sy
|
||||||
|
synchronized
|
||||||
|
snippet im
|
||||||
|
import
|
||||||
|
snippet j.u
|
||||||
|
java.util
|
||||||
|
snippet j.i
|
||||||
|
java.io.
|
||||||
|
snippet j.b
|
||||||
|
java.beans.
|
||||||
|
snippet j.n
|
||||||
|
java.net.
|
||||||
|
snippet j.m
|
||||||
|
java.math.
|
||||||
|
snippet if
|
||||||
|
if (${1}) ${2}
|
||||||
|
snippet el
|
||||||
|
else
|
||||||
|
snippet elif
|
||||||
|
else if (${1}) ${2}
|
||||||
|
snippet wh
|
||||||
|
while (${1}) ${2}
|
||||||
|
snippet for
|
||||||
|
for (${1}; ${2}; ${3}) ${4}
|
||||||
|
snippet fore
|
||||||
|
for (${1} : ${2}) ${3}
|
||||||
|
snippet sw
|
||||||
|
switch (${1}) ${2}
|
||||||
|
snippet cs
|
||||||
|
case ${1}:
|
||||||
|
${2}
|
||||||
|
${3}
|
||||||
|
snippet tc
|
||||||
|
public class ${1:`Filename()`} extends ${2:TestCase}
|
||||||
|
snippet t
|
||||||
|
public void test${1:Name}() throws Exception ${2}
|
||||||
|
snippet cl
|
||||||
|
class ${1:`Filename("", "untitled")`} ${2}
|
||||||
|
snippet in
|
||||||
|
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}
|
||||||
|
snippet m
|
||||||
|
${1:void} ${2:method}(${3}) ${4:throws }${5}
|
||||||
|
snippet v
|
||||||
|
${1:String} ${2:var}${3: = null}${4};${5}
|
||||||
|
snippet co
|
||||||
|
static public final ${1:String} ${2:var} = ${3};${4}
|
||||||
|
snippet cos
|
||||||
|
static public final String ${1:var} = "${2}";${3}
|
||||||
|
snippet as
|
||||||
|
assert ${1:test} : "${2:Failure message}";${3}
|
||||||
74
snippets/javascript.snippets
Normal file
74
snippets/javascript.snippets
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# Prototype
|
||||||
|
snippet proto
|
||||||
|
${1:class_name}.prototype.${2:method_name} =
|
||||||
|
function(${3:first_argument}) {
|
||||||
|
${4:// body...}
|
||||||
|
};
|
||||||
|
# Function
|
||||||
|
snippet fun
|
||||||
|
function ${1:function_name} (${2:argument}) {
|
||||||
|
${3:// body...}
|
||||||
|
}
|
||||||
|
# Anonymous Function
|
||||||
|
snippet f
|
||||||
|
function(${1}) {${2}};
|
||||||
|
# if
|
||||||
|
snippet if
|
||||||
|
if (${1:true}) {${2}};
|
||||||
|
# if ... else
|
||||||
|
snippet ife
|
||||||
|
if (${1:true}) {${2}}
|
||||||
|
else{${3}};
|
||||||
|
# tertiary conditional
|
||||||
|
snippet t
|
||||||
|
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||||
|
# switch
|
||||||
|
snippet switch
|
||||||
|
switch(${1:expression}) {
|
||||||
|
case '${3:case}':
|
||||||
|
${4:// code}
|
||||||
|
break;
|
||||||
|
${5}
|
||||||
|
default:
|
||||||
|
${2:// code}
|
||||||
|
}
|
||||||
|
# case
|
||||||
|
snippet case
|
||||||
|
case '${1:case}':
|
||||||
|
${2:// code}
|
||||||
|
break;
|
||||||
|
${3}
|
||||||
|
# for (...) {...}
|
||||||
|
snippet for
|
||||||
|
for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
|
||||||
|
${4:$1[$2]}
|
||||||
|
};
|
||||||
|
# for (...) {...} (Improved Native For-Loop)
|
||||||
|
snippet forr
|
||||||
|
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
|
||||||
|
${4:$1[$2]}
|
||||||
|
};
|
||||||
|
# while (...) {...}
|
||||||
|
snippet wh
|
||||||
|
while (${1:/* condition */}) {
|
||||||
|
${2:/* code */}
|
||||||
|
}
|
||||||
|
# do...while
|
||||||
|
snippet do
|
||||||
|
do {
|
||||||
|
${2:/* code */}
|
||||||
|
} while (${1:/* condition */});
|
||||||
|
# Object Method
|
||||||
|
snippet :f
|
||||||
|
${1:method_name}: function(${2:attribute}) {
|
||||||
|
${4}
|
||||||
|
}${3:,}
|
||||||
|
# setTimeout function
|
||||||
|
snippet timeout
|
||||||
|
setTimeout(function() {${3}}${2}, ${1:10};
|
||||||
|
# Get Elements
|
||||||
|
snippet get
|
||||||
|
getElementsBy${1:TagName}('${2}')${3}
|
||||||
|
# Get Element
|
||||||
|
snippet gett
|
||||||
|
getElementBy${1:Id}('${2}')${3}
|
||||||
122
snippets/objc.snippets
Normal file
122
snippets/objc.snippets
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
# #import <...>
|
||||||
|
snippet imp
|
||||||
|
#import <${1:Cocoa/Cocoa.h}>${2}
|
||||||
|
# #import "..."
|
||||||
|
snippet Imp
|
||||||
|
#import "${1:`Filename()`.h}"${2}
|
||||||
|
# @selector(...)
|
||||||
|
snippet sel
|
||||||
|
@selector(${1:method}:)${3}
|
||||||
|
# NSLog(...)
|
||||||
|
snippet log
|
||||||
|
NSLog(@"${1}"${2});${3}
|
||||||
|
# Class
|
||||||
|
snippet objc
|
||||||
|
@interface ${1:`Filename('', 'object')`} : ${2:NSObject}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation $1
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if (self = [super init])
|
||||||
|
# Class Interface
|
||||||
|
snippet clh
|
||||||
|
@interface ${1:ClassName} : ${2:NSObject}
|
||||||
|
{${3}
|
||||||
|
}
|
||||||
|
${4}
|
||||||
|
@end
|
||||||
|
snippet ibo
|
||||||
|
IBOutlet ${1:NSSomeClass} *${2:$1};
|
||||||
|
# Category
|
||||||
|
snippet cat
|
||||||
|
@interface ${1:NSObject} (${2:Category})
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation $1 ($2)
|
||||||
|
${3}
|
||||||
|
@end
|
||||||
|
# Category Interface
|
||||||
|
snippet cath
|
||||||
|
@interface ${1:NSObject} (${2:Category})
|
||||||
|
${3}
|
||||||
|
@end
|
||||||
|
# NSArray
|
||||||
|
snippet array
|
||||||
|
NSMutableArray *${1:array} = [NSMutable array];${2}
|
||||||
|
# NSDictionary
|
||||||
|
snippet dict
|
||||||
|
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
|
||||||
|
# NSBezierPath
|
||||||
|
snippet bez
|
||||||
|
NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}
|
||||||
|
# Method
|
||||||
|
snippet m
|
||||||
|
- (${1:id})${2:method}
|
||||||
|
{
|
||||||
|
${3:return self;}
|
||||||
|
}
|
||||||
|
# Method declaration
|
||||||
|
snippet md
|
||||||
|
- (${1:id})${2:method};${3}
|
||||||
|
# Class Method
|
||||||
|
snippet M
|
||||||
|
+ (${1:id})${2:method}
|
||||||
|
{${3}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
# Sub-method (Call super)
|
||||||
|
snippet sm
|
||||||
|
- (${1:id})${2:method}
|
||||||
|
{
|
||||||
|
[super $2];${3}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
# Method: Initialize
|
||||||
|
snippet I
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:
|
||||||
|
${1}@"value", @"key",
|
||||||
|
nil]];
|
||||||
|
}
|
||||||
|
# Accessor Methods For:
|
||||||
|
# Object
|
||||||
|
snippet objacc
|
||||||
|
- (${1:id})${2:thing}
|
||||||
|
{
|
||||||
|
return $2;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) set$2:($1)
|
||||||
|
{
|
||||||
|
$1 old$2 = $2;
|
||||||
|
$2 = [aValue retain];
|
||||||
|
[old$2 release];
|
||||||
|
}
|
||||||
|
snippet forarray
|
||||||
|
unsigned int ${1:object}Count = [${2:array} count];
|
||||||
|
|
||||||
|
for (unsigned int index = 0; index < $1Count; index++)
|
||||||
|
{
|
||||||
|
${3:id} $1 = [$2 $1AtIndex:index];
|
||||||
|
${4}
|
||||||
|
}
|
||||||
|
# IBOutlet
|
||||||
|
# @property (Objective-C 2.0)
|
||||||
|
snippet prop
|
||||||
|
@property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4}
|
||||||
|
# @synthesize (Objective-C 2.0)
|
||||||
|
snippet syn
|
||||||
|
@synthesize ${1:NSSomeClass};${2}
|
||||||
|
# [[ alloc] init]
|
||||||
|
snippet alloc
|
||||||
|
[[${1:foo} alloc] init]${2};${3}
|
||||||
|
# retain
|
||||||
|
snippet ret
|
||||||
|
[${1:foo} retain];${2}
|
||||||
|
# release
|
||||||
|
snippet rel
|
||||||
|
[${1:foo} release];${2}
|
||||||
91
snippets/perl.snippets
Normal file
91
snippets/perl.snippets
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# #!/usr/bin/perl
|
||||||
|
snippet #!
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# Hash Pointer
|
||||||
|
snippet .
|
||||||
|
=>
|
||||||
|
# Function
|
||||||
|
snippet sub
|
||||||
|
sub ${1:function_name} {
|
||||||
|
${2:#body ...}
|
||||||
|
}
|
||||||
|
# Conditional
|
||||||
|
snippet if
|
||||||
|
if (${1}) {
|
||||||
|
${2:# body...}
|
||||||
|
}
|
||||||
|
# Conditional if..else
|
||||||
|
snippet ife
|
||||||
|
if (${1}) {
|
||||||
|
${2:# body...}
|
||||||
|
} else {
|
||||||
|
${3:# else...}
|
||||||
|
}
|
||||||
|
# Conditional if..elsif..else
|
||||||
|
snippet ifee
|
||||||
|
if (${1}) {
|
||||||
|
${2:# body...}
|
||||||
|
} elsif (${3}) {
|
||||||
|
${4:# elsif...}
|
||||||
|
} else {
|
||||||
|
${5:# else...}
|
||||||
|
}
|
||||||
|
# Conditional One-line
|
||||||
|
snippet xif
|
||||||
|
${1:expression} if ${2:condition};${3}
|
||||||
|
# Unless conditional
|
||||||
|
snippet unless
|
||||||
|
unless (${1}) {
|
||||||
|
${2:# body...}
|
||||||
|
}
|
||||||
|
# Unless conditional One-line
|
||||||
|
snippet xunless
|
||||||
|
${1:expression} unless ${2:condition};${3}
|
||||||
|
# Try/Except
|
||||||
|
snippet eval
|
||||||
|
eval {
|
||||||
|
${1:# do something risky...}
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
${2:# handle failure...}
|
||||||
|
}
|
||||||
|
# While Loop
|
||||||
|
snippet wh
|
||||||
|
while (${1}) {
|
||||||
|
${2:# body...}
|
||||||
|
}
|
||||||
|
# While Loop One-line
|
||||||
|
snippet xwh
|
||||||
|
${1:expression} while ${2:condition};${3}
|
||||||
|
# For Loop
|
||||||
|
snippet for
|
||||||
|
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||||
|
${4:# body...}
|
||||||
|
}
|
||||||
|
# Foreach Loop
|
||||||
|
snippet fore
|
||||||
|
foreach my $${1:x} (@${2:array}) {
|
||||||
|
${3:# body...}
|
||||||
|
}
|
||||||
|
# Foreach Loop One-line
|
||||||
|
snippet xfore
|
||||||
|
${1:expression} foreach @${2:array};${3}
|
||||||
|
# Package
|
||||||
|
snippet cl
|
||||||
|
package ${1:ClassName};
|
||||||
|
|
||||||
|
use base qw(${2:ParentClass});
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
$class = ref $class if ref $class;
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
$self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;${3}
|
||||||
|
# Read File
|
||||||
|
snippet slurp
|
||||||
|
my $${1:var};
|
||||||
|
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${2}
|
||||||
216
snippets/php.snippets
Normal file
216
snippets/php.snippets
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
snippet php
|
||||||
|
<?php
|
||||||
|
${1}
|
||||||
|
?>
|
||||||
|
snippet ec
|
||||||
|
echo "${1:string}"${2};
|
||||||
|
snippet inc
|
||||||
|
include '${1:file}';${2}
|
||||||
|
snippet inc1
|
||||||
|
include_once '${1:file}';${2}
|
||||||
|
snippet req
|
||||||
|
require '${1:file}';${2}
|
||||||
|
snippet req1
|
||||||
|
require_once '${1:file}';${2}
|
||||||
|
# $GLOBALS['...']
|
||||||
|
snippet globals
|
||||||
|
$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
|
||||||
|
snippet $_ COOKIE['...']
|
||||||
|
$_COOKIE['${1:variable}']${2}
|
||||||
|
snippet $_ ENV['...']
|
||||||
|
$_ENV['${1:variable}']${2}
|
||||||
|
snippet $_ FILES['...']
|
||||||
|
$_FILES['${1:variable}']${2}
|
||||||
|
snippet $_ Get['...']
|
||||||
|
$_GET['${1:variable}']${2}
|
||||||
|
snippet $_ POST['...']
|
||||||
|
$_POST['${1:variable}']${2}
|
||||||
|
snippet $_ REQUEST['...']
|
||||||
|
$_REQUEST['${1:variable}']${2}
|
||||||
|
snippet $_ SERVER['...']
|
||||||
|
$_SERVER['${1:variable}']${2}
|
||||||
|
snippet $_ SESSION['...']
|
||||||
|
$_SESSION['${1:variable}']${2}
|
||||||
|
# Start Docblock
|
||||||
|
snippet /*
|
||||||
|
/**
|
||||||
|
* ${1}
|
||||||
|
**/
|
||||||
|
# Class - post doc
|
||||||
|
snippet doc_cp
|
||||||
|
/**
|
||||||
|
* ${1:undocumented class}
|
||||||
|
*
|
||||||
|
* @package ${2:default}
|
||||||
|
* @author ${3:`g:snips_author`}
|
||||||
|
**/${4}
|
||||||
|
# Class Variable - post doc
|
||||||
|
snippet doc_vp
|
||||||
|
/**
|
||||||
|
* ${1:undocumented class variable}
|
||||||
|
*
|
||||||
|
* @var ${2:string}
|
||||||
|
**/${3}
|
||||||
|
# Class Variable
|
||||||
|
snippet doc_v
|
||||||
|
/**
|
||||||
|
* ${3:undocumented class variable}
|
||||||
|
*
|
||||||
|
* @var ${4:string}
|
||||||
|
**/
|
||||||
|
${1:var} $${2};${5}
|
||||||
|
# Class
|
||||||
|
snippet doc_c
|
||||||
|
/**
|
||||||
|
* ${3:undocumented class}
|
||||||
|
*
|
||||||
|
* @packaged ${4:default}
|
||||||
|
* @author ${5:`g:snips_author`}
|
||||||
|
**/
|
||||||
|
${1:}class ${2:}
|
||||||
|
{${6}
|
||||||
|
} // END $1class $2
|
||||||
|
# Constant Definition - post doc
|
||||||
|
snippet doc_dp
|
||||||
|
/**
|
||||||
|
* ${1:undocumented constant}
|
||||||
|
**/${2}
|
||||||
|
# Constant Definition
|
||||||
|
snippet doc_d
|
||||||
|
/**
|
||||||
|
* ${3:undocumented constant}
|
||||||
|
**/
|
||||||
|
define(${1}, ${2});${4}
|
||||||
|
# Function - post doc
|
||||||
|
snippet doc_fp
|
||||||
|
/**
|
||||||
|
* ${1:undocumented function}
|
||||||
|
*
|
||||||
|
* @return ${2:void}
|
||||||
|
* @author ${3:`g:snips_author`}
|
||||||
|
**/${4}
|
||||||
|
# Function signature
|
||||||
|
snippet doc_s
|
||||||
|
/**
|
||||||
|
* ${4:undocumented function}
|
||||||
|
*
|
||||||
|
* @return ${5:void}
|
||||||
|
* @author ${6:`g:snips_author`}
|
||||||
|
**/
|
||||||
|
${1}function ${2}(${3});${7}
|
||||||
|
# Function
|
||||||
|
snippet doc_f
|
||||||
|
/**
|
||||||
|
* ${4:undocumented function}
|
||||||
|
*
|
||||||
|
* @return ${5:void}
|
||||||
|
* @author ${6:`g:snips_author`}
|
||||||
|
**/
|
||||||
|
${1}function ${2}(${3})
|
||||||
|
{${7}
|
||||||
|
}
|
||||||
|
# Header
|
||||||
|
snippet doc_h
|
||||||
|
/**
|
||||||
|
* ${1}
|
||||||
|
*
|
||||||
|
* @author ${2:`g:snips_author`}
|
||||||
|
* @version ${3:$Id$}
|
||||||
|
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
||||||
|
* @package ${5:default}
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define DocBlock
|
||||||
|
*//
|
||||||
|
# Interface
|
||||||
|
snippet doc_i
|
||||||
|
/**
|
||||||
|
* ${2:undocumented class}
|
||||||
|
*
|
||||||
|
* @package ${3:default}
|
||||||
|
* @author ${4:`g:snips_author`}
|
||||||
|
**/
|
||||||
|
interface ${1:}
|
||||||
|
{${5}
|
||||||
|
} // END interface $1
|
||||||
|
# class ...
|
||||||
|
snippet class
|
||||||
|
/**
|
||||||
|
* ${1}
|
||||||
|
**/
|
||||||
|
class ${2:ClassName}
|
||||||
|
{
|
||||||
|
${3}
|
||||||
|
function ${4:__construct}(${5:argument})
|
||||||
|
{
|
||||||
|
${6:// code...}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# define(...)
|
||||||
|
snippet def
|
||||||
|
define('${1}'${2});${3}
|
||||||
|
# defined(...)
|
||||||
|
snippet def?
|
||||||
|
${1}defined('${2}')${3}
|
||||||
|
snippet wh
|
||||||
|
while (${1:/* condition */}) {
|
||||||
|
${2:// code...}
|
||||||
|
}
|
||||||
|
# do ... while
|
||||||
|
snippet do
|
||||||
|
do {
|
||||||
|
${2:// code... }
|
||||||
|
} while (${1:/* condition */});
|
||||||
|
snippet if
|
||||||
|
if (${1:/* condition */}) {
|
||||||
|
${2:// code...}
|
||||||
|
}
|
||||||
|
snippet ife
|
||||||
|
if (${1:/* condition */}) {
|
||||||
|
${2:// code...}
|
||||||
|
} else {
|
||||||
|
${3:// code...}
|
||||||
|
}
|
||||||
|
${4}
|
||||||
|
snippet else
|
||||||
|
else {
|
||||||
|
${1:// code...}
|
||||||
|
}
|
||||||
|
snippet elseif
|
||||||
|
elseif (${1:/* condition */}) {
|
||||||
|
${2:// code...}
|
||||||
|
}
|
||||||
|
# Tertiary conditional
|
||||||
|
snippet t
|
||||||
|
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
||||||
|
snippet switch
|
||||||
|
switch ($${1:variable}) {
|
||||||
|
case '${2:value}':
|
||||||
|
${3:// code...}
|
||||||
|
break;
|
||||||
|
${5}
|
||||||
|
default:
|
||||||
|
${4:// code...}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
snippet case
|
||||||
|
case '${1:value}':
|
||||||
|
${2:// code...}
|
||||||
|
break;${3}
|
||||||
|
snippet for
|
||||||
|
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||||
|
${4: // code...}
|
||||||
|
}
|
||||||
|
snippet foreach
|
||||||
|
foreach ($${1:variable} as $${2:key}) {
|
||||||
|
${3:// code...}
|
||||||
|
}
|
||||||
|
snippet fun
|
||||||
|
${1:public }function ${2:FunctionName}(${3})
|
||||||
|
{
|
||||||
|
${4:// code...}
|
||||||
|
}
|
||||||
|
# $... = array (...)
|
||||||
|
snippet array
|
||||||
|
$${1:arrayName} = array('${2}' => ${3});${4}
|
||||||
75
snippets/python.snippets
Normal file
75
snippets/python.snippets
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# #!/usr/bin/python
|
||||||
|
snippet #!
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# While
|
||||||
|
snippet wh
|
||||||
|
while ${1:condition}:
|
||||||
|
${2:# code...}
|
||||||
|
# New Class
|
||||||
|
snippet cl
|
||||||
|
class ${1:ClassName}(${2:object}):
|
||||||
|
"""${3:docstring for $1}"""
|
||||||
|
def __init__(self, ${4:arg}):
|
||||||
|
${5:super($1, self).__init__()}
|
||||||
|
self.$4 = $4
|
||||||
|
${6}
|
||||||
|
# New Function
|
||||||
|
snippet def
|
||||||
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||||
|
"""${3:docstring for $1}"""
|
||||||
|
${4:pass}
|
||||||
|
# New Method
|
||||||
|
snippet defs
|
||||||
|
def ${1:mname}(self, ${2:arg})):
|
||||||
|
${3:pass}
|
||||||
|
# New Property
|
||||||
|
snippet property
|
||||||
|
def ${1:foo}():
|
||||||
|
doc = "${2:The $1 property.}"
|
||||||
|
def fget(self):
|
||||||
|
${3:return self._$1}
|
||||||
|
def fset(self, value):
|
||||||
|
|
||||||
|
# Self
|
||||||
|
snippet .
|
||||||
|
self.
|
||||||
|
# Try/Except
|
||||||
|
snippet try
|
||||||
|
try:
|
||||||
|
${1:pass}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
# Try/Except/Else
|
||||||
|
snippet trye
|
||||||
|
try:
|
||||||
|
${1:pass}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
else:
|
||||||
|
${5:pass}
|
||||||
|
# Try/Except/Finally
|
||||||
|
snippet tryf
|
||||||
|
try:
|
||||||
|
${1:pass}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
finally:
|
||||||
|
${5:pass}
|
||||||
|
# Try/Except/Else/Finally
|
||||||
|
snippet tryef
|
||||||
|
try:
|
||||||
|
${1:pass}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
else:
|
||||||
|
${5:pass}
|
||||||
|
finally:
|
||||||
|
${6:pass}
|
||||||
|
# if __name__ == '__main__':
|
||||||
|
snippet ifmain
|
||||||
|
if __name__ == '__main__':
|
||||||
|
${1:main()}
|
||||||
|
# __magic__
|
||||||
|
snippet _
|
||||||
|
__${1:init}__${2}
|
||||||
412
snippets/ruby.snippets
Normal file
412
snippets/ruby.snippets
Normal file
@@ -0,0 +1,412 @@
|
|||||||
|
# #!/usr/bin/ruby
|
||||||
|
snippet #!
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
|
# New Block
|
||||||
|
snippet =b
|
||||||
|
=begin rdoc
|
||||||
|
${1}
|
||||||
|
=end
|
||||||
|
snippet y
|
||||||
|
:yields: ${1:arguments}
|
||||||
|
snippet rb
|
||||||
|
#!/usr/bin/env ruby -wKU
|
||||||
|
|
||||||
|
snippet req
|
||||||
|
require "${1}"${2}
|
||||||
|
snippet #
|
||||||
|
# =>
|
||||||
|
snippet end
|
||||||
|
__END__
|
||||||
|
snippet case
|
||||||
|
case ${1:object}
|
||||||
|
when ${2:condition}
|
||||||
|
${3}
|
||||||
|
end
|
||||||
|
snippet when
|
||||||
|
when ${1:condition}
|
||||||
|
${2}
|
||||||
|
snippet def
|
||||||
|
def ${1:method_name}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet deft
|
||||||
|
def test_${1:case_name}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet if
|
||||||
|
if ${1:condition}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet ife
|
||||||
|
if ${1:condition}
|
||||||
|
${2}
|
||||||
|
else
|
||||||
|
${3}
|
||||||
|
end
|
||||||
|
snippet elsif
|
||||||
|
elsif ${1:condition}
|
||||||
|
${2}
|
||||||
|
snippet unless
|
||||||
|
unless ${1:condition}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet while
|
||||||
|
while ${1:condition}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet until
|
||||||
|
until ${1:condition}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet cla class .. end
|
||||||
|
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet cla class .. initialize .. end
|
||||||
|
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||||
|
def initialize(${2:args})
|
||||||
|
${3}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
snippet cla class .. < ParentClass .. initialize .. end
|
||||||
|
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
|
||||||
|
def initialize(${3:args})
|
||||||
|
${4}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
snippet cla ClassName = Struct .. do .. end
|
||||||
|
${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
|
||||||
|
def ${3:method_name}
|
||||||
|
${4}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
snippet cla class BlankSlate .. initialize .. end
|
||||||
|
class ${1:BlankSlate}
|
||||||
|
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
|
||||||
|
snippet cla class << self .. end
|
||||||
|
class << ${1:self}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
# class .. < DelegateClass .. initialize .. end
|
||||||
|
snippet cla-
|
||||||
|
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
|
||||||
|
def initialize(${3:args})
|
||||||
|
super(${4:del_obj})
|
||||||
|
|
||||||
|
${5}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
snippet mod module .. end
|
||||||
|
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet mod module .. module_function .. end
|
||||||
|
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||||
|
module_function
|
||||||
|
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet mod module .. ClassMethods .. end
|
||||||
|
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||||
|
module ClassMethods
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# attr_reader
|
||||||
|
snippet r
|
||||||
|
attr_reader :${1:attr_names}
|
||||||
|
# attr_writer
|
||||||
|
snippet w
|
||||||
|
attr_writer :${1:attr_names}
|
||||||
|
# attr_accessor
|
||||||
|
snippet rw
|
||||||
|
attr_accessor :${1:attr_names}
|
||||||
|
# include Enumerable
|
||||||
|
snippet Enum
|
||||||
|
include Enumerable
|
||||||
|
|
||||||
|
def each(&block)
|
||||||
|
${1}
|
||||||
|
end
|
||||||
|
# include Comparable
|
||||||
|
snippet Comp
|
||||||
|
include Comparable
|
||||||
|
|
||||||
|
def <=>(other)
|
||||||
|
${1}
|
||||||
|
end
|
||||||
|
# extend Forwardable
|
||||||
|
snippet Forw-
|
||||||
|
extend Forwardable
|
||||||
|
# def self
|
||||||
|
snippet defs
|
||||||
|
def self.${1:class_method_name}
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
# def method_missing
|
||||||
|
snippet defmm
|
||||||
|
def method_missing(meth, *args, &blk)
|
||||||
|
${1}
|
||||||
|
end
|
||||||
|
snippet defd
|
||||||
|
def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
|
||||||
|
snippet defds
|
||||||
|
def_delegators :${1:@del_obj}, :${2:del_methods}
|
||||||
|
snippet am
|
||||||
|
alias_method :${1:new_name}, :${2:old_name}
|
||||||
|
snippet app
|
||||||
|
if __FILE__ == $PROGRAM_NAME
|
||||||
|
${1}
|
||||||
|
end
|
||||||
|
# usage_if()
|
||||||
|
snippet usai
|
||||||
|
if ARGV.${1}
|
||||||
|
abort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}
|
||||||
|
end
|
||||||
|
# usage_unless()
|
||||||
|
snippet usau
|
||||||
|
unless ARGV.${1}
|
||||||
|
abort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}
|
||||||
|
end
|
||||||
|
snippet array
|
||||||
|
Array.new(${1:10}) { |${2:i}| ${3} }
|
||||||
|
snippet hash
|
||||||
|
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
|
||||||
|
snippet file File.foreach() { |line| .. }
|
||||||
|
File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
|
||||||
|
snippet file File.read()
|
||||||
|
File.read(${1:"path/to/file"})${2}
|
||||||
|
snippet Dir Dir.global() { |file| .. }
|
||||||
|
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
|
||||||
|
snippet Dir Dir[''..'']
|
||||||
|
Dir[${1:"glob/**/*.rb"}]${2}
|
||||||
|
snippet dir
|
||||||
|
Filename.dirname(__FILE__)
|
||||||
|
snippet deli
|
||||||
|
delete_if { |${1:e}| ${2} }
|
||||||
|
snippet fil
|
||||||
|
fill(${1:range}) { |${2:i}| ${3} }
|
||||||
|
# flatten_once()
|
||||||
|
snippet flao
|
||||||
|
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
|
||||||
|
snippet zip
|
||||||
|
zip(${1:enums}) { |${2:row}| ${3} }
|
||||||
|
# downto(0) { |n| .. }
|
||||||
|
snippet dow
|
||||||
|
downto(${1:0}) { |${2:n}| ${3} }
|
||||||
|
snippet ste
|
||||||
|
step(${1:2}) { |${2:n}| ${3} }
|
||||||
|
snippet tim
|
||||||
|
times { |${1:n}| ${2} }
|
||||||
|
snippet upt
|
||||||
|
upto(${1:1.0/0.0}) { |${2:n}| ${3} }
|
||||||
|
snippet loo
|
||||||
|
loop { ${1} }
|
||||||
|
snippet ea
|
||||||
|
each { |${1:e}| ${2} }
|
||||||
|
snippet eab
|
||||||
|
each_byte { |${1:byte}| ${2} }
|
||||||
|
snippet eac- each_char { |chr| .. }
|
||||||
|
each_char { |${1:chr}| ${2} }
|
||||||
|
snippet eac- each_cons(..) { |group| .. }
|
||||||
|
each_cons(${1:2}) { |${2:group}| ${3} }
|
||||||
|
snippet eai
|
||||||
|
each_index { |${1:i}| ${2} }
|
||||||
|
snippet eak
|
||||||
|
each_key { |${1:key}| ${2} }
|
||||||
|
snippet eal
|
||||||
|
each_line { |${1:line}| ${2} }
|
||||||
|
snippet eap
|
||||||
|
each_pair { |${1:name}, ${2:val}| ${3} }
|
||||||
|
snippet eas-
|
||||||
|
each_slice(${1:2}) { |${2:group}| ${3} }
|
||||||
|
snippet eav
|
||||||
|
each_value { |${1:val}| ${2} }
|
||||||
|
snippet eawi
|
||||||
|
each_with_index { |${1:e}, ${2:i}| ${3} }
|
||||||
|
snippet reve
|
||||||
|
reverse_each { |${1:e}| ${2} }
|
||||||
|
snippet inj
|
||||||
|
inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
|
||||||
|
snippet map
|
||||||
|
map { |${1:e}| ${2} }
|
||||||
|
snippet mapwi-
|
||||||
|
enum_with_index.map { |${1:e}, ${2:i}| ${3} }
|
||||||
|
snippet sor
|
||||||
|
sort { |a, b| ${1} }
|
||||||
|
snippet sorb
|
||||||
|
sort_by { |${1:e}| ${2} }
|
||||||
|
snippet ran
|
||||||
|
sort_by { rand }
|
||||||
|
snippet all
|
||||||
|
all? { |${1:e}| ${2} }
|
||||||
|
snippet any
|
||||||
|
any? { |${1:e}| ${2} }
|
||||||
|
snippet cl
|
||||||
|
classify { |${1:e}| ${2} }
|
||||||
|
snippet col
|
||||||
|
collect { |${1:e}| ${2} }
|
||||||
|
snippet det
|
||||||
|
detect { |${1:e}| ${2} }
|
||||||
|
snippet fet
|
||||||
|
fetch(${1:name}) { |${2:key}| ${3} }
|
||||||
|
snippet fin
|
||||||
|
find { |${1:e}| ${2} }
|
||||||
|
snippet fina
|
||||||
|
find_all { |${1:e}| ${2} }
|
||||||
|
snippet gre
|
||||||
|
grep(${1:/pattern/}) { |${2:match}| ${3} }
|
||||||
|
snippet sub
|
||||||
|
${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
|
||||||
|
snippet sca
|
||||||
|
scan(${1:/pattern/}) { |${2:match}| ${3} }
|
||||||
|
snippet max
|
||||||
|
max { |a, b|, ${1} }
|
||||||
|
snippet min
|
||||||
|
min { |a, b|, ${1} }
|
||||||
|
snippet par
|
||||||
|
partition { |${1:e}|, ${2} }
|
||||||
|
snippet rej
|
||||||
|
reject { |${1:e}|, ${2} }
|
||||||
|
snippet sel
|
||||||
|
select { |${1:e}|, ${2} }
|
||||||
|
snippet lam
|
||||||
|
lambda { |${1:args}| ${2} }
|
||||||
|
snippet do
|
||||||
|
do |${1:variable}|
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet :
|
||||||
|
:${1:key} => ${2:"value"}${3}
|
||||||
|
snippet ope
|
||||||
|
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
||||||
|
# path_from_here()
|
||||||
|
snippet patfh
|
||||||
|
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
||||||
|
# unix_filter {}
|
||||||
|
snippet unif
|
||||||
|
ARGF.each_line${1} do |${2:line}|
|
||||||
|
${3}
|
||||||
|
end
|
||||||
|
# option_parse {}
|
||||||
|
snippet optp
|
||||||
|
require \"optparse\"
|
||||||
|
|
||||||
|
options = {${1:default => \"args\"}}
|
||||||
|
|
||||||
|
ARGV.options do |opts|
|
||||||
|
opts.banner = \"Usage: #{File.basename($PROGRAM_NAME)}
|
||||||
|
snippet opt
|
||||||
|
opts.on( \"-${1:o}\", \"--${2:long-option-name}\", ${3:String},
|
||||||
|
\"${4:Option description.}\") do |${5:opt}|
|
||||||
|
${6}
|
||||||
|
end
|
||||||
|
snippet tc
|
||||||
|
require \"test/unit\"
|
||||||
|
|
||||||
|
require \"${1:library_file_name}\"
|
||||||
|
|
||||||
|
class Test${2:$1} < Test::Unit::TestCase
|
||||||
|
def test_${3:case_name}
|
||||||
|
${4}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
snippet ts
|
||||||
|
require \"test/unit\"
|
||||||
|
|
||||||
|
require \"tc_${1:test_case_file}\"
|
||||||
|
require \"tc_${2:test_case_file}\"${3}
|
||||||
|
snippet as
|
||||||
|
assert(${1:test}, \"${2:Failure message.}\")${3}
|
||||||
|
snippet ase
|
||||||
|
assert_equal(${1:expected}, ${2:actual})${3}
|
||||||
|
snippet asne
|
||||||
|
assert_not_equal(${1:unexpected}, ${2:actual})${3}
|
||||||
|
snippet asid
|
||||||
|
assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
|
||||||
|
snippet asio
|
||||||
|
assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
|
||||||
|
snippet asko
|
||||||
|
assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
|
||||||
|
snippet asn
|
||||||
|
assert_nil(${1:instance})${2}
|
||||||
|
snippet asnn
|
||||||
|
assert_not_nil(${1:instance})${2}
|
||||||
|
snippet asm
|
||||||
|
assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
|
||||||
|
snippet asnm
|
||||||
|
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
|
||||||
|
snippet aso
|
||||||
|
assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
|
||||||
|
snippet asr
|
||||||
|
assert_raise(${1:Exception}) { ${2} }
|
||||||
|
snippet asnr
|
||||||
|
assert_nothing_raised(${1:Exception}) { ${2} }
|
||||||
|
snippet asrt
|
||||||
|
assert_respond_to(${1:object}, :${2:method})${3}
|
||||||
|
snippet ass assert_same(..)
|
||||||
|
assert_same(${1:expected}, ${2:actual})${3}
|
||||||
|
snippet ass assert_send(..)
|
||||||
|
assert_send([${1:object}, :${2:message}, ${3:args}])${4}
|
||||||
|
snippet asns
|
||||||
|
assert_not_same(${1:unexpected}, ${2:actual})${3}
|
||||||
|
snippet ast
|
||||||
|
assert_throws(:${1:expected}) { ${2} }
|
||||||
|
snippet asnt
|
||||||
|
assert_nothing_thrown { ${1} }
|
||||||
|
snippet fl
|
||||||
|
flunk("${1:Failure message.}")${2}
|
||||||
|
# Benchmark.bmbm do .. end
|
||||||
|
snippet bm-
|
||||||
|
TESTS = ${1:10_000}
|
||||||
|
Benchmark.bmbm do |results|
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet rep
|
||||||
|
results.report("${1:name}:") { TESTS.times { ${2} }}
|
||||||
|
# Marshal.dump(.., file)
|
||||||
|
snippet Md
|
||||||
|
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
|
||||||
|
# Mashal.load(obj)
|
||||||
|
snippet Ml
|
||||||
|
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
|
||||||
|
# deep_copy(..)
|
||||||
|
snippet deec
|
||||||
|
Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
|
||||||
|
snippet Pn-
|
||||||
|
PStore.new(${1:"file_name.pstore"})${2}
|
||||||
|
snippet tra
|
||||||
|
transaction(${1:true}) { ${2} }
|
||||||
|
# xmlread(..)
|
||||||
|
snippet xml-
|
||||||
|
REXML::Document.new(File.read(${1:"path/to/file"}))${2}
|
||||||
|
# xpath(..) { .. }
|
||||||
|
snippet xpa
|
||||||
|
elements.each(${1:\"//Xpath\"}) do |${2:node}|
|
||||||
|
${3}
|
||||||
|
end
|
||||||
|
# class_from_name()
|
||||||
|
snippet clafn
|
||||||
|
split("::").inject(Object) { |par, const| par.const_get(const) }
|
||||||
|
# singleton_class()
|
||||||
|
snippet sinc
|
||||||
|
class << self; self end
|
||||||
|
snippet nam
|
||||||
|
namespace :${1:`Filename()`} do
|
||||||
|
${2}
|
||||||
|
end
|
||||||
|
snippet tas
|
||||||
|
desc \"${1:Task description\}\"
|
||||||
|
task :${2:task_name => [:dependent, :tasks]} do
|
||||||
|
${3}
|
||||||
|
end
|
||||||
28
snippets/sh.snippets
Normal file
28
snippets/sh.snippets
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# #!/bin/bash
|
||||||
|
snippet #!
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
snippet if
|
||||||
|
if [[ ${1:condition} ]]; then
|
||||||
|
${2:#statements}
|
||||||
|
fi
|
||||||
|
snippet elif
|
||||||
|
elif [[ ${1:condition} ]]; then
|
||||||
|
${2:#statements}
|
||||||
|
snippet for
|
||||||
|
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||||
|
${3:#statements}
|
||||||
|
done
|
||||||
|
snippet wh
|
||||||
|
while [[ ${1:condition} ]]; do
|
||||||
|
${2:#statements}
|
||||||
|
done
|
||||||
|
snippet until
|
||||||
|
[[ ${1:condition} ]]; do
|
||||||
|
${2:#statements}
|
||||||
|
done
|
||||||
|
snippet case
|
||||||
|
case ${1:word} in
|
||||||
|
${2:pattern})
|
||||||
|
${3};;
|
||||||
|
esac
|
||||||
7
snippets/snippets.snippets
Normal file
7
snippets/snippets.snippets
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# snippets for making snippets :)
|
||||||
|
snippet snip
|
||||||
|
snippet ${1:trigger}
|
||||||
|
${2}
|
||||||
|
snippet msnip
|
||||||
|
snippet ${1:trigger} ${2:description}
|
||||||
|
${3}
|
||||||
115
snippets/tex.snippets
Normal file
115
snippets/tex.snippets
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
# \begin{}...\end{}
|
||||||
|
snippet begin
|
||||||
|
\begin{${1:env}}
|
||||||
|
${2}
|
||||||
|
\end{$1}
|
||||||
|
# Tabular
|
||||||
|
snippet tab
|
||||||
|
\begin{${1:tabular}}{${2:c}}
|
||||||
|
${3}
|
||||||
|
\end{$1}
|
||||||
|
# Align(ed)
|
||||||
|
snippet ali
|
||||||
|
\begin{align${1:ed}}
|
||||||
|
${2}
|
||||||
|
\end{align$1}
|
||||||
|
# Gather(ed)
|
||||||
|
snippet gat
|
||||||
|
\begin{gather${1:ed}}
|
||||||
|
${2}
|
||||||
|
\end{gather$1}
|
||||||
|
# Equation
|
||||||
|
snippet eq
|
||||||
|
\begin{equation}
|
||||||
|
${1}
|
||||||
|
\end{equation}
|
||||||
|
# Unnumbered Equation
|
||||||
|
snippet \
|
||||||
|
\\[
|
||||||
|
${1}
|
||||||
|
\\]
|
||||||
|
# Enumerate
|
||||||
|
snippet enum
|
||||||
|
\begin{enumerate}
|
||||||
|
\item ${1}
|
||||||
|
\end{enumerate}
|
||||||
|
# Itemize
|
||||||
|
snippet item
|
||||||
|
\begin{itemize}
|
||||||
|
\item ${1}
|
||||||
|
\end{itemize}
|
||||||
|
# Description
|
||||||
|
snippet desc
|
||||||
|
\begin{description}
|
||||||
|
\item[${1}] ${2}
|
||||||
|
\end{description}
|
||||||
|
# Matrix
|
||||||
|
snippet mat
|
||||||
|
\begin{${1:p/b/v/V/B/small}matrix}
|
||||||
|
${2}
|
||||||
|
\end{$1matrix}
|
||||||
|
# Cases
|
||||||
|
snippet cas
|
||||||
|
\begin{cases}
|
||||||
|
${1:equation}, &\ ext{ if }${2:case}\\
|
||||||
|
${3}
|
||||||
|
\end{cases}
|
||||||
|
# Split
|
||||||
|
snippet spl
|
||||||
|
\begin{split}
|
||||||
|
${1}
|
||||||
|
\end{split}
|
||||||
|
# Part
|
||||||
|
snippet part
|
||||||
|
\part{${1:part name}} % (fold)
|
||||||
|
\label{prt:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% part $2 (end)
|
||||||
|
# Chapter
|
||||||
|
snippet cha
|
||||||
|
\chapter{${1:chapter name}} % (fold)
|
||||||
|
\label{cha:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% chapter $2 (end)
|
||||||
|
# Section
|
||||||
|
snippet sec
|
||||||
|
\section{${1:section name}} % (fold)
|
||||||
|
\label{sec:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% section $2 (end)
|
||||||
|
# Sub Section
|
||||||
|
snippet sub
|
||||||
|
\subsection{${1:subsection name}} % (fold)
|
||||||
|
\label{sub:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% subsection $2 (end)
|
||||||
|
# Sub Sub Section
|
||||||
|
snippet subs
|
||||||
|
\subsubsection{${1:subsubsection name}} % (fold)
|
||||||
|
\label{ssub:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% subsubsection $2 (end)
|
||||||
|
# Paragraph
|
||||||
|
snippet par
|
||||||
|
\paragraph{${1:paragraph name}} % (fold)
|
||||||
|
\label{par:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% paragraph $2 (end)
|
||||||
|
# Sub Paragraph
|
||||||
|
snippet subp
|
||||||
|
\subparagraph{${1:subparagraph name}} % (fold)
|
||||||
|
\label{subp:${2:$1}}
|
||||||
|
${3}
|
||||||
|
% subparagraph $2 (end)
|
||||||
|
snippet itd
|
||||||
|
\item[${1:description}] ${2:item}
|
||||||
|
snippet figure
|
||||||
|
${1:Figure}~\ref{${2:fig:}}${3}
|
||||||
|
snippet table
|
||||||
|
${1:Table}~\ref{${2:tab:}}${3}
|
||||||
|
snippet listing
|
||||||
|
${1:Listing}~\ref{${2:list}}${3}
|
||||||
|
snippet section
|
||||||
|
${1:Section}~\ref{${2:sec:}}${3}
|
||||||
|
snippet page
|
||||||
|
${1:page}~\pageref{${2}}${3}
|
||||||
27
snippets/vim.snippets
Normal file
27
snippets/vim.snippets
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
snippet guard
|
||||||
|
if exists('${1:did_`expand('%:t:r')`}') || &cp
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let $1 = 1${2}
|
||||||
|
snippet f
|
||||||
|
fun ${1:function_name}(${2})
|
||||||
|
${3:" code}
|
||||||
|
endf
|
||||||
|
snippet for
|
||||||
|
for ${1:needle} in ${2:haystack}
|
||||||
|
${3:" code}
|
||||||
|
endfor
|
||||||
|
snippet wh
|
||||||
|
wh ${1:condition}
|
||||||
|
${2:" code}
|
||||||
|
endw
|
||||||
|
snippet if
|
||||||
|
if ${1:condition}
|
||||||
|
${2:" code}
|
||||||
|
endif
|
||||||
|
snippet ife
|
||||||
|
if ${1:condition}
|
||||||
|
${2}
|
||||||
|
else
|
||||||
|
${3}
|
||||||
|
endif
|
||||||
Reference in New Issue
Block a user