Skip to content

Commit

Permalink
Version 0.61803
Browse files Browse the repository at this point in the history
Fixed some other bugs for compatibility with supertab.vim and 'set expandtab' and added check to ensure snippets are not loaded twice.

I also changed the "Snip" command to "Snipp" to maintain compatibility with vimscript #244 (imaps.vim). Unfortunately this breaks backward compatibility; to update any snippets you have added, just execute this regex on the appropriate files: ":%s/exe \(.\)Snip /exe \1Snipp /g"
  • Loading branch information
Michael Sanders authored and vim-scripts committed Nov 16, 2010
1 parent 02da7de commit d733b01
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 390 deletions.
49 changes: 25 additions & 24 deletions after/ftplugin/c_snips.vim
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
if !exists('g:loaded_snips')
if !exists('g:loaded_snips') || exists('s:did_snips')
fini
en
let s:did_snips = 1

" main()
exe "Snip main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
" #include <...>
exe 'Snip inc #include <${1:stdio}.h>${2}'
exe 'Snipp inc #include <${1:stdio}.h>${2}'
" #include "..."
exe 'Snip Inc #include "${1:`Filename("$1.h")`}"${2}'
exe 'Snipp Inc #include "${1:`Filename("$1.h")`}"${2}'
" #ifndef ... #define ... #endif
exe "Snip def #ifndef $1\n#define ${1:SYMBOL} ${2:value}\n#endif${3}"
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 "Snip once #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system(\"/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'\"))`}\n"
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 "Snip readfile std::vector<char> v;\nif (FILE *${2:fp} = fopen(${1:\"filename\"}, \"r\")) {\n\tchar buf[1024];\n\twhile (size_t len = "
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 "Snip if if (${1:/* condition */}) {\n\t${2:/* code */}\n}"
exe "Snip el else {\n\t${1}\n}"
exe "Snipp if if (${1:/* condition */}) {\n\t${2:/* code */}\n}"
exe "Snipp el else {\n\t${1}\n}"
" Tertiary conditional
exe 'Snip t ${1:/* condition */} ? ${2:a} : ${3:b}'
exe 'Snipp t ${1:/* condition */} ? ${2:a} : ${3:b}'
" Do While Loop
exe "Snip do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
exe "Snipp do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
" While Loop
exe "Snip wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
" For Loop
exe "Snip for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\t${4:/* code */}\n}"
exe "Snipp for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\t${4:/* code */}\n}"
" Custom For Loop
exe "Snip forr for (${1:i} = 0; ${2:$1 < 5}; $1${3:++}) {\n\t${4:/* code */}\n}"
exe "Snipp forr for (${1:i} = 0; ${2:$1 < 5}; $1${3:++}) {\n\t${4:/* code */}\n}"
" Function
exe "Snip fun ${1:void} ${2:function_name} (${3})\n{\n\t${4:/* code */}\n}"
exe "Snipp fun ${1:void} ${2:function_name} (${3})\n{\n\t${4:/* code */}\n}"
" Typedef
exe 'Snip td typedef ${1:int} ${2:MyCustomType};'
exe 'Snipp td typedef ${1:int} ${2:MyCustomType};'
" Struct
exe "Snip st struct ${1:`Filename('$1_t', 'name')`} {\n\t${2:/* data */}\n}${3: /* optional variable list */};${4}"
exe "Snipp st struct ${1:`Filename('$1_t', 'name')`} {\n\t${2:/* data */}\n}${3: /* optional variable list */};${4}"
" Typedef struct
exe "Snip tds typedef struct {\n\t${2:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
exe "Snipp tds typedef struct {\n\t${2:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
" Class
exe "Snip cl class ${1:`Filename('$1_t', 'name')`} {\npublic:\n\t$1 (${2:arguments});\n\tvirtual ~$1 ();\n\nprivate:\n\t${3:/* data */}\n};"
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 "Snip ns namespace ${1:`Filename('', 'my')`} {\n\t${2}\n} /* $1 */"
exe "Snipp ns namespace ${1:`Filename('', 'my')`} {\n\t${2}\n} /* $1 */"
" std::map
exe "Snip map std::map<${1:key}, ${2:value}> map${3};"
exe "Snipp map std::map<${1:key}, ${2:value}> map${3};"
" std::vector
exe "Snip vector std::vector<${1:char}> v${2};"
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 'Snip pr printf("${1:%s}\n"${2});${3}'
exe 'Snipp pr printf("${1:%s}\n"${2});${3}'
" fprintf (again, this isn't as nice as TextMate's version, but it works)
exe 'Snip fpr fprintf(${1:stderr}, "${2:%s}\n"${3});${4}'
exe 'Snipp fpr fprintf(${1:stderr}, "${2:%s}\n"${3});${4}'
95 changes: 48 additions & 47 deletions after/ftplugin/html_snips.vim
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
if !exists('g:loaded_snips')
if !exists('g:loaded_snips') || exists('s:did_snips')
fini
en
let s:did_snips = 1
let c = &ft == 'xhtml' ? ' /' : ''

" Some useful Unicode entities
" Non-Breaking Space
exe 'Snip nbs &nbsp;'
exe 'Snipp nbs &nbsp;'
"
exe 'Snip left &#x2190;'
exe 'Snipp left &#x2190;'
"
exe 'Snip right &#x2192;'
exe 'Snipp right &#x2192;'
"
exe 'Snip up &#x2191;'
exe 'Snipp up &#x2191;'
"
exe 'Snip down &#x2193;'
exe 'Snipp down &#x2193;'
"
exe 'Snip return &#x21A9;'
exe 'Snipp return &#x21A9;'
"
exe 'Snip backtab &#x21E4;'
exe 'Snipp backtab &#x21E4;'
"
exe 'Snip tab &#x21E5;'
exe 'Snipp tab &#x21E5;'
"
exe 'Snip shift &#x21E7;'
exe 'Snipp shift &#x21E7;'
"
exe 'Snip control &#x2303;'
exe 'Snipp control &#x2303;'
"
exe 'Snip enter &#x2305;'
exe 'Snipp enter &#x2305;'
"
exe 'Snip command &#x2318;'
exe 'Snipp command &#x2318;'
"
exe 'Snip option &#x2325;'
exe 'Snipp option &#x2325;'
"
exe 'Snip delete &#x2326;'
exe 'Snipp delete &#x2326;'
"
exe 'Snip backspace &#x232B;'
exe 'Snipp backspace &#x232B;'
"
exe 'Snip escape &#x238B;'
exe 'Snipp escape &#x238B;'
" Generic Doctype
exe "Snip! doctype \"HTML 4.01 Strict\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
exe "Snip! doctype \"HTML 4.01 Transitional\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
Expand All @@ -44,44 +45,44 @@ exe "Snip! doctype \"XHTML 1.0 Strict\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTM
exe "Snip! 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 "Snip! 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 "Snip docts <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
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 "Snip doct <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
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 "Snip docxf <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"
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 "Snip docxs <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
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 "Snip docxt <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
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 "Snip docx <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
exe "Snip xhtml <html xmlns=\"http://www.w3.org/1999/xhtml\">\n${1}\n</html>"
exe "Snip body <body>\n\t${1}\n</body>"
exe "Snip head <head>\n\t<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"".c.">\n\t"
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 'Snip title <title>${1:`substitute(Filename("", "Page Title"), "^.", "\\u&", "")`}</title>${2}'
exe "Snip script <script type=\"text/javascript\" charset=\"utf-8\">\n\t${1}\n</script>${2}"
exe "Snip scriptsrc <script src=\"${1}.js\" type=\"text/javascript\" charset=\"utf-8\"></script>${2}"
exe "Snip style <style type=\"text/css\" media=\"${1:screen}\">\n\t${2}\n</style>${3}"
exe 'Snip base <base href="${1}" target="${2}"'.c.'>'
exe 'Snip r <br'.c[1:].'>'
exe "Snip div <div id=\"${1:name}\">\n\t${2}\n</div>"
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 "Snip movie <object width=\"$2\" height=\"$3\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\""
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 "Snip fieldset <fieldset id=\"$1\">\n\t<legend>${1:name}</legend>\n\n\t${3}\n</fieldset>"
exe "Snip form <form action=\"${1:`Filename('$1_submit')`}\" method=\"${2:get}\" accept-charset=\"utf-8\">\n\t${3}\n\n\t"
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 'Snip h1 <h1 id="${1:heading}">${2:$1}</h1>'
exe 'Snip input <input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"'.c.'>${4}'
exe 'Snip 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 'Snip link <link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"'.c.'>${4}'
exe 'Snip mailto <a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>'
exe 'Snip meta <meta name="${1:name}" content="${2:content}"'.c.'>${3}'
exe 'Snip opt <option value="${1:option}">${2:$1}</option>${3}'
exe 'Snip optt <option>${1:option}</option>${2}'
exe "Snip select <select name=\"${1:some_name}\" id=\"${2:$1}\">\n\t<option value=\"${3:option}\">${4:$3}</option>\n</select>${5}"
exe "Snip 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 'Snip textarea <textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}'
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}'
75 changes: 38 additions & 37 deletions after/ftplugin/java_snips.vim
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
if !exists('loaded_snips')
if !exists('loaded_snips') || exists('s:did_snips')
fini
en
let s:did_snips = 1

exe "Snip main public static void main (String [] args)\n{\n\t${1:/* code */}\n}"
exe 'Snip pu public'
exe 'Snip po protected'
exe 'Snip pr private'
exe 'Snip st static'
exe 'Snip fi final'
exe 'Snip ab abstract'
exe 'Snip re return'
exe 'Snip br break;'
exe "Snip de default:\n\t${1}"
exe 'Snip ca catch(${1:Exception} ${2:e}) ${3}'
exe 'Snip th throw '
exe 'Snip sy synchronized'
exe 'Snip im import'
exe 'Snip j.u java.util'
exe 'Snip j.i java.io.'
exe 'Snip j.b java.beans.'
exe 'Snip j.n java.net.'
exe 'Snip j.m java.math.'
exe 'Snip if if (${1}) ${2}'
exe 'Snip el else '
exe 'Snip elif else if (${1}) ${2}'
exe 'Snip wh while (${1}) ${2}'
exe 'Snip for for (${1}; ${2}; ${3}) ${4}'
exe 'Snip fore for (${1} : ${2}) ${3}'
exe 'Snip sw switch (${1}) ${2}'
exe "Snip cs case ${1}:\n\t${2}\n${3}"
exe 'Snip tc public class ${1:`Filename()`} extends ${2:TestCase}'
exe 'Snip t public void test${1:Name}() throws Exception ${2}'
exe 'Snip cl class ${1:`Filename("", "untitled")`} ${2}'
exe 'Snip in interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}'
exe 'Snip m ${1:void} ${2:method}(${3}) ${4:throws }${5}'
exe 'Snip v ${1:String} ${2:var}${3: = null}${4};${5}'
exe 'Snip co static public final ${1:String} ${2:var} = ${3};${4}'
exe 'Snip cos static public final String ${1:var} = "${2}";${3}'
exe 'Snip as assert ${1:test} : "${2:Failure message}";${3}'
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}'
35 changes: 18 additions & 17 deletions after/ftplugin/javascript_snips.vim
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
if !exists('loaded_snips')
if !exists('loaded_snips') || exists('s:did_snips')
fini
en
let s:did_snips = 1

" Prototype
exe "Snip proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"
exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"
" Function
exe "Snip fun function ${1:function_name} (${2:argument}) {\n\t${3:// body...}\n}"
exe "Snipp fun function ${1:function_name} (${2:argument}) {\n\t${3:// body...}\n}"
" Anonymous Function
exe 'Snip f function(${1}) {${2}};'
exe 'Snipp f function(${1}) {${2}};'
" if
exe 'Snip if if (${1:true}) {${2}};'
exe 'Snipp if if (${1:true}) {${2}};'
" if ... else
exe "Snip ife if (${1:true}) {${2}}\nelse{${3}};"
exe "Snipp ife if (${1:true}) {${2}}\nelse{${3}};"
" tertiary conditional
exe 'Snip t ${1:/* condition */} ? ${2:a} : ${3:b}'
exe 'Snipp t ${1:/* condition */} ? ${2:a} : ${3:b}'
" switch
exe "Snip 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}"
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 "Snip case case '${1:case}':\n\t${2:// code}\n\tbreak;\n${3}"
exe "Snipp case case '${1:case}':\n\t${2:// code}\n\tbreak;\n${3}"
" for (...) {...}
exe "Snip for for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {\n\t${4:$1[$2]}\n};"
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 "Snip forr for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {\n\t${4:$1[$2]}\n};"
exe "Snipp forr for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {\n\t${4:$1[$2]}\n};"
" while (...) {...}
exe "Snip wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
" do...while
exe "Snip do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
exe "Snipp do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
" Object Method
exe "Snip :f ${1:method_name}: function(${2:attribute}) {\n\t${4}\n}${3:,}"
exe "Snipp :f ${1:method_name}: function(${2:attribute}) {\n\t${4}\n}${3:,}"
" setTimeout function
exe 'Snip timeout setTimeout(function() {${3}}${2}, ${1:10};'
exe 'Snipp timeout setTimeout(function() {${3}}${2}, ${1:10};'
" Get Elements
exe "Snip get getElementsBy${1:TagName}('${2}')${3}"
exe "Snipp get getElementsBy${1:TagName}('${2}')${3}"
" Get Element
exe "Snip gett getElementBy${1:Id}('${2}')${3}"
exe "Snipp gett getElementBy${1:Id}('${2}')${3}"
Loading

0 comments on commit d733b01

Please sign in to comment.