1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-26 16:32:37 +01:00

Version 0.61803399 (first commit)

This commit is contained in:
Michael
2009-02-16 21:11:41 -05:00
parent 2a9c9acd97
commit 9707a70f85
15 changed files with 1352 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
if !exists('g:loaded_snips') || exists('b:did_c_snips')
fini
en
let b:did_c_snips = 1
" 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; I don't know how to do
" it in vim script, it could probably be cleaner)
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 */"
" 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}"
" 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}"
" 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 {\n\t${2:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
" 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};"
" Namespace
exe "Snipp ns namespace ${1:`Filename('', 'my')`} {\n\t${2}\n} /* $1 */"
" std::map
exe "Snipp map std::map<${1:key}, ${2:value}> map${3};"
" std::vector
exe "Snipp vector std::vector<${1:char}> v${2};"
" 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}'

View File

@@ -0,0 +1,90 @@
if !exists('g:loaded_snips') || exists('b:did_html_snips')
fini
en
let b:did_html_snips = 1
" automatically add a closing '/' to the end of xhtml tags
let c = &ft == 'xhtml' ? ' /' : ''
" Some useful Unicode entities
" Non-Breaking Space
exe 'Snipp nbs &nbsp;'
" ←
exe 'Snipp left &#x2190;'
" →
exe 'Snipp right &#x2192;'
" ↑
exe 'Snipp up &#x2191;'
" ↓
exe 'Snipp down &#x2193;'
" ↩
exe 'Snipp return &#x21A9;'
" ⇤
exe 'Snipp backtab &#x21E4;'
" ⇥
exe 'Snipp tab &#x21E5;'
" ⇧
exe 'Snipp shift &#x21E7;'
" ⌃
exe 'Snipp control &#x2303;'
" ⌅
exe 'Snipp enter &#x2305;'
" ⌘
exe 'Snipp command &#x2318;'
" ⌥
exe 'Snipp option &#x2325;'
" ⌦
exe 'Snipp delete &#x2326;'
" ⌫
exe 'Snipp backspace &#x232B;'
" ⎋
exe 'Snipp escape &#x238B;'
" 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 \"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\">"
" 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 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 &rarr;\"".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}'

View File

@@ -0,0 +1,41 @@
if !exists('loaded_snips') || exists('b:did_java_snips')
fini
en
let b:did_java_snips = 1
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}'

View File

@@ -0,0 +1,37 @@
if !exists('loaded_snips') || exists('b:did_js_snips')
fini
en
let b:did_js_snips = 1
" 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}"

View File

@@ -0,0 +1,40 @@
if !exists('loaded_snips') || exists('b:did_js_snips')
fini
en
let b:did_js_snips = 1
" #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 cli @interface ${1:ClassName} : ${2:NSObject}\n{${3}\n}\n${4}\n@end"
" Category
exe "Snipp cat @interface ${1:NSObject} (${2:Category})\n@end\n\n@implementation $1 ($2)\n${3}\n@end"
" Category Interface
exe "Snipp cati @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}'
" 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}:(${3:id})${4:anArgument}\n{\n\t$1 res = [super $2:$4];${5}\n\treturn res;\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}"
" [[ alloc] init]
exe 'Snipp alloc [[${1:foo} alloc] init]${2};${3}'

View File

@@ -0,0 +1,37 @@
if !exists('loaded_snips') || exists('b:did_perl_snips')
fini
en
let b:did_perl_snips = 1
" 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}"

View File

@@ -0,0 +1,67 @@
if !exists('loaded_snips') || exists('b:did_php_snips')
fini
en
let b:did_php_snips = 1
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}"

View File

@@ -0,0 +1,28 @@
if !exists('loaded_snips') || exists('b:did_python_snips')
fini
en
let b:did_python_snips = 1
" 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 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${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${6:pass}"
" if __name__ == '__main__':
exe "Snipp ifmain if __name__ == '__main__':\n\t${1:main()}"
" __magic__
exe 'Snipp _ __${1:init}__${2}'

View File

@@ -0,0 +1,167 @@
if !exists('loaded_snips') || exists('b:did_ruby_snips')
fini
en
let b:did_ruby_snips = 1
" 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"

View File

@@ -0,0 +1,11 @@
if !exists('loaded_snips') || exists('b:did_sh_snips')
fini
en
let b:did_sh_snips = 1
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"

View File

@@ -0,0 +1,49 @@
if !exists('loaded_snips') || exists('b:did_tex_snips')
fini
en
let b:did_tex_snips = 1
" \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}'

View File

@@ -0,0 +1,8 @@
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")`'

13
after/plugin/snipMate.vim Normal file
View File

@@ -0,0 +1,13 @@
" These are the mappings for snipMate.vim. Putting it here ensures that it
" will be mapped after other plugins such as supertab.vim.
if exists('s:did_snips_mappings') || &cp || version < 700
fini
en
let s:did_snips_mappings = 1
ino <tab> <c-r>=ExpandSnippet()<cr>
snor <tab> <esc>i<right><c-r>=ExpandSnippet()<cr>
snor <bs> b<bs>
snor ' b<bs>'
snor <right> <esc>a
snor <left> <esc>bi