From 6964753858c08d3780de2b0d7645c7ef080ac6c9 Mon Sep 17 00:00:00 2001 From: Honza Pokorny Date: Mon, 20 Jun 2011 14:40:28 -0300 Subject: [PATCH] Import snippets. These snippets are taken from garbas/vim-snipmate. The SHA is: 307880b0809fdb0bd70226e3fedd4acdf58a7e0b --- _.snippets | 11 + actionscript.snippets | 135 ++++++ autoit.snippets | 66 +++ c.snippets | 134 ++++++ cmake.snippets | 58 +++ cpp.snippets | 58 +++ css.snippets | 967 ++++++++++++++++++++++++++++++++++++++++++ diff.snippets | 11 + django.snippets | 108 +++++ erlang.snippets | 39 ++ eruby.snippets | 124 ++++++ falcon.snippets | 110 +++++ haml.snippets | 20 + html.snippets | 244 +++++++++++ htmldjango.snippets | 137 ++++++ java.snippets | 144 +++++++ javascript.snippets | 102 +++++ jsp.snippets | 99 +++++ mako.snippets | 54 +++ markdown.snippets | 7 + objc.snippets | 247 +++++++++++ perl.snippets | 97 +++++ php.snippets | 247 +++++++++++ progress.snippets | 58 +++ python.snippets | 122 ++++++ rst.snippets | 22 + ruby.snippets | 562 ++++++++++++++++++++++++ sh.snippets | 28 ++ snippet.snippets | 9 + tcl.snippets | 92 ++++ tex.snippets | 153 +++++++ vim.snippets | 34 ++ zsh.snippets | 58 +++ 33 files changed, 4357 insertions(+) create mode 100644 _.snippets create mode 100644 actionscript.snippets create mode 100644 autoit.snippets create mode 100644 c.snippets create mode 100644 cmake.snippets create mode 100644 cpp.snippets create mode 100644 css.snippets create mode 100644 diff.snippets create mode 100644 django.snippets create mode 100644 erlang.snippets create mode 100644 eruby.snippets create mode 100644 falcon.snippets create mode 100644 haml.snippets create mode 100644 html.snippets create mode 100644 htmldjango.snippets create mode 100644 java.snippets create mode 100644 javascript.snippets create mode 100644 jsp.snippets create mode 100644 mako.snippets create mode 100644 markdown.snippets create mode 100644 objc.snippets create mode 100644 perl.snippets create mode 100644 php.snippets create mode 100644 progress.snippets create mode 100644 python.snippets create mode 100644 rst.snippets create mode 100644 ruby.snippets create mode 100644 sh.snippets create mode 100644 snippet.snippets create mode 100644 tcl.snippets create mode 100644 tex.snippets create mode 100644 vim.snippets create mode 100644 zsh.snippets diff --git a/_.snippets b/_.snippets new file mode 100644 index 0000000..06dfaf7 --- /dev/null +++ b/_.snippets @@ -0,0 +1,11 @@ +# Global snippets + +# (c) holds no legal value ;) +snippet c) + Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} +snippet date + `strftime("%Y-%m-%d")` +snippet ddate + `strftime("%B %d, %Y")` +snippet lorem + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/actionscript.snippets b/actionscript.snippets new file mode 100644 index 0000000..f77a334 --- /dev/null +++ b/actionscript.snippets @@ -0,0 +1,135 @@ +snippet main + package { + import flash.display.*; + import flash.Events.*; + + public class Main extends Sprite { + public function Main ( ) { + trace("start"); + stage.scaleMode = StageScaleMode.NO_SCALE; + stage.addEventListener(Event.RESIZE, resizeListener); + } + + private function resizeListener (e:Event):void { + trace("The application window changed size!"); + trace("New width: " + stage.stageWidth); + trace("New height: " + stage.stageHeight); + } + + } + + } +snippet class + ${1:public|internal} class ${2:name} ${3:extends } { + public function $2 ( ) { + ("start"); + } + } +snippet all + package name { + + ${1:public|internal|final} class ${2:name} ${3:extends } { + private|public| static const FOO = "abc"; + private|public| static var BAR = "abc"; + + // class initializer - no JIT !! one time setup + if Cababilities.os == "Linux|MacOS" { + FOO = "other"; + } + + // constructor: + public function $2 ( ){ + super2(); + trace("start"); + } + public function name (a, b...){ + super.name(..); + lable:break + } + } + } + + function A(){ + // A can only be accessed within this file + } +snippet switch + switch(${1}){ + case ${2}: + ${3} + break; + default: + } +snippet case + case ${1}: + ${2} + break; +snippet package + package ${1:package}{ + ${2} + } +snippet wh + while ${1:cond}{ + ${2} + } +snippet do + do { + ${2} + } while (${1:cond}) +snippet while + while ${1:cond}{ + ${2} + } +snippet for enumerate names + for (${1:var} in ${2:object}){ + ${3} + } +snippet for enumerate values + for each (${1:var} in ${2:object}){ + ${3} + } +snippet get_set + function get ${1:name} { + return ${2} + } + function set $1 (newValue) { + ${3} + } +snippet interface + interface name { + function method(${1}):${2:returntype}; + } +snippet try + try { + ${1} + } catch (error:ErrorType) { + ${2} + } finally { + ${3} + } +# For Loop (same as c.snippet) +snippet for + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4:/* code */} + } +# Custom For Loop +snippet forr + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${5:/* code */} + } +# If Condition +snippet if + if (${1:/* condition */}) { + ${2:/* code */} + } +snippet el + else { + ${1} + } +# Ternary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +snippet fun + function ${1:function_name}(${2})${3} + { + ${4:/* code */} + } diff --git a/autoit.snippets b/autoit.snippets new file mode 100644 index 0000000..690018c --- /dev/null +++ b/autoit.snippets @@ -0,0 +1,66 @@ +snippet if + If ${1:condition} Then + ${2:; True code} + EndIf +snippet el + Else + ${1} +snippet elif + ElseIf ${1:condition} Then + ${2:; True code} +# If/Else block +snippet ifel + If ${1:condition} Then + ${2:; True code} + Else + ${3:; Else code} + EndIf +# If/ElseIf/Else block +snippet ifelif + If ${1:condition 1} Then + ${2:; True code} + ElseIf ${3:condition 2} Then + ${4:; True code} + Else + ${5:; Else code} + EndIf +# Switch block +snippet switch + Switch (${1:condition}) + Case {$2:case1}: + {$3:; Case 1 code} + Case Else: + {$4:; Else code} + EndSwitch +# Select block +snippet select + Select (${1:condition}) + Case {$2:case1}: + {$3:; Case 1 code} + Case Else: + {$4:; Else code} + EndSelect +# While loop +snippet while + While (${1:condition}) + ${2:; code...} + WEnd +# For loop +snippet for + For ${1:n} = ${3:1} to ${2:count} + ${4:; code...} + Next +# New Function +snippet func + Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${4:Return} + EndFunc +# Message box +snippet msg + MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"}) +# Debug Message +snippet debug + MsgBox(0, "Debug", ${1:"Debug Message"}) +# Show Variable Debug Message +snippet showvar + MsgBox(0, "${1:VarName}", $1) diff --git a/c.snippets b/c.snippets new file mode 100644 index 0000000..38e8d9e --- /dev/null +++ b/c.snippets @@ -0,0 +1,134 @@ +# main() +snippet main + int main(int argc, const char *argv[]) + { + ${1} + return 0; + } +snippet mainn + int main(void) + { + ${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} +snippet def + #define +snippet ifdef + #ifdef ${1:FOO} + ${2:#define } + #endif +snippet #if + #if ${1:FOO} + ${2} + #endif +# Header Include-Guard +snippet once + #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} + + #define $1 + + ${2} + + #endif /* end of include guard: $1 */ +# If Condition +snippet if + if (${1:/* condition */}) { + ${2:/* code */} + } +snippet el + else { + ${1} + } +# Ternary 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} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${5:/* code */} + } +# Function +snippet fun + ${1:void} ${2:function_name}(${3}) + { + ${4:/* code */} + } +# Function Declaration +snippet fund + ${1:void} ${2:function_name}(${3});${4} +# Typedef +snippet td + typedef ${1:int} ${2:MyCustomType};${3} +# 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')`}; +# Typdef enum +snippet tde + typedef enum { + ${1:/* data */} + } ${2:foo}; +# 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} +# This is kind of convenient +snippet . + [${1}]${2} +# GPL +snippet gpl + /* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) ${1:Author}, `strftime("%Y")` + */ + + ${2} diff --git a/cmake.snippets b/cmake.snippets new file mode 100644 index 0000000..26aa9ac --- /dev/null +++ b/cmake.snippets @@ -0,0 +1,58 @@ +snippet cmake + CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + PROJECT(${1:ProjectName}) + + FIND_PACKAGE(${2:LIBRARY}) + + INCLUDE_DIRECTORIES( + ${$2_INCLUDE_DIR} + ) + + ADD_SUBDIRECTORY(${3:src}) + + ADD_EXECUTABLE($1) + + TARGET_LINK_LIBRARIES($1 + ${$2_LIBRARIES} + ) + +snippet include + INCLUDE_DIRECTORIES( + ${${1:INCLUDE_DIR}} + ) + +snippet find + FIND_PACKAGE(${1:LIBRARY}) + +snippet glob + FILE(GLOB ${1:SRCS} *.${2:cpp}) + +snippet subdir + ADD_SUBDIRECTORY(${1:src}) + +snippet lib + ADD_LIBRARY(${1:lib} ${2:STATIC} + ${${3:SRCS}} + ) + +snippet link + TARGET_LINK_LIBRARIES(${1:bin} + ${2:somelib} + ) + +snippet bin + ADD_EXECUTABLE(${1:bin}) + +snippet set + SET(${1:var} ${2:val}) + +snippet dep + ADD_DEPENDENCIES(${1:target} + ${2:dep} + ) + +snippet props + SET_TARGET_PROPERTIES(${1:target} + ${2:PROPERTIES} ${3:COMPILE_FLAGS} + ${4:"-O3 -Wall -pedantic"} + ) diff --git a/cpp.snippets b/cpp.snippets new file mode 100644 index 0000000..94f7de5 --- /dev/null +++ b/cpp.snippets @@ -0,0 +1,58 @@ +# Read File Into Vector +snippet readfile + std::vector 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}> ${3}; + +# std::vector +snippet vector + std::vector<${1:char}> ${2}; + +# Namespace +snippet ns + namespace ${1:`Filename('', 'my')`} { + ${2} + } /* namespace $1 */ + +# Class +snippet class + class ${1:`Filename('$1', 'name')`} + { + public: + $1(${2}); + ~$1(); + + private: + ${3:/* data */} + }; + +snippet fori + for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4:/* code */} + } + +# auto iterator +snippet itera + for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) { + ${2:std::cout << *$1 << std::endl;} + } + +# iterator +snippet iter + for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) { + ${6} + } + +# member function implementations +snippet mfun + ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { + ${5:return}; + } diff --git a/css.snippets b/css.snippets new file mode 100644 index 0000000..72212d2 --- /dev/null +++ b/css.snippets @@ -0,0 +1,967 @@ +snippet . + ${1} { + ${2} + } +snippet ! + !important +snippet bdi:m+ + -moz-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch}; +snippet bdi:m + -moz-border-image: ${1}; +snippet bdrz:m + -moz-border-radius: ${1}; +snippet bxsh:m+ + -moz-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000}; +snippet bxsh:m + -moz-box-shadow: ${1}; +snippet bdi:w+ + -webkit-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch}; +snippet bdi:w + -webkit-border-image: ${1}; +snippet bdrz:w + -webkit-border-radius: ${1}; +snippet bxsh:w+ + -webkit-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000}; +snippet bxsh:w + -webkit-box-shadow: ${1}; +snippet @f + @font-face { + font-family: ${1}; + src: url(${2}); + } +snippet @i + @import url(${1}); +snippet @m + @media ${1:print} { + ${2} + } +snippet bg+ + background: #${1:FFF} url(${2}) ${3:0} ${4:0} ${5:no-repeat}; +snippet bga + background-attachment: ${1}; +snippet bga:f + background-attachment: fixed; +snippet bga:s + background-attachment: scroll; +snippet bgbk + background-break: ${1}; +snippet bgbk:bb + background-break: bounding-box; +snippet bgbk:c + background-break: continuous; +snippet bgbk:eb + background-break: each-box; +snippet bgcp + background-clip: ${1}; +snippet bgcp:bb + background-clip: border-box; +snippet bgcp:cb + background-clip: content-box; +snippet bgcp:nc + background-clip: no-clip; +snippet bgcp:pb + background-clip: padding-box; +snippet bgc + background-color: #${1:FFF}; +snippet bgc:t + background-color: transparent; +snippet bgi + background-image: url(${1}); +snippet bgi:n + background-image: none; +snippet bgo + background-origin: ${1}; +snippet bgo:bb + background-origin: border-box; +snippet bgo:cb + background-origin: content-box; +snippet bgo:pb + background-origin: padding-box; +snippet bgpx + background-position-x: ${1}; +snippet bgpy + background-position-y: ${1}; +snippet bgp + background-position: ${1:0} ${2:0}; +snippet bgr + background-repeat: ${1}; +snippet bgr:n + background-repeat: no-repeat; +snippet bgr:x + background-repeat: repeat-x; +snippet bgr:y + background-repeat: repeat-y; +snippet bgr:r + background-repeat: repeat; +snippet bgz + background-size: ${1}; +snippet bgz:a + background-size: auto; +snippet bgz:ct + background-size: contain; +snippet bgz:cv + background-size: cover; +snippet bg + background: ${1}; +snippet bg:ie + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${2:crop}'); +snippet bg:n + background: none; +snippet bd+ + border: ${1:1px} ${2:solid} #${3:000}; +snippet bdb+ + border-bottom: ${1:1px} ${2:solid} #${3:000}; +snippet bdbc + border-bottom-color: #${1:000}; +snippet bdbi + border-bottom-image: url(${1}); +snippet bdbi:n + border-bottom-image: none; +snippet bdbli + border-bottom-left-image: url(${1}); +snippet bdbli:c + border-bottom-left-image: continue; +snippet bdbli:n + border-bottom-left-image: none; +snippet bdblrz + border-bottom-left-radius: ${1}; +snippet bdbri + border-bottom-right-image: url(${1}); +snippet bdbri:c + border-bottom-right-image: continue; +snippet bdbri:n + border-bottom-right-image: none; +snippet bdbrrz + border-bottom-right-radius: ${1}; +snippet bdbs + border-bottom-style: ${1}; +snippet bdbs:n + border-bottom-style: none; +snippet bdbw + border-bottom-width: ${1}; +snippet bdb + border-bottom: ${1}; +snippet bdb:n + border-bottom: none; +snippet bdbk + border-break: ${1}; +snippet bdbk:c + border-break: close; +snippet bdcl + border-collapse: ${1}; +snippet bdcl:c + border-collapse: collapse; +snippet bdcl:s + border-collapse: separate; +snippet bdc + border-color: #${1:000}; +snippet bdci + border-corner-image: url(${1}); +snippet bdci:c + border-corner-image: continue; +snippet bdci:n + border-corner-image: none; +snippet bdf + border-fit: ${1}; +snippet bdf:c + border-fit: clip; +snippet bdf:of + border-fit: overwrite; +snippet bdf:ow + border-fit: overwrite; +snippet bdf:r + border-fit: repeat; +snippet bdf:sc + border-fit: scale; +snippet bdf:sp + border-fit: space; +snippet bdf:st + border-fit: stretch; +snippet bdi + border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch}; +snippet bdi:n + border-image: none; +snippet bdl+ + border-left: ${1:1px} ${2:solid} #${3:000}; +snippet bdlc + border-left-color: #${1:000}; +snippet bdli + border-left-image: url(${1}); +snippet bdli:n + border-left-image: none; +snippet bdls + border-left-style: ${1}; +snippet bdls:n + border-left-style: none; +snippet bdlw + border-left-width: ${1}; +snippet bdl + border-left: ${1}; +snippet bdl:n + border-left: none; +snippet bdlt + border-length: ${1}; +snippet bdlt:a + border-length: auto; +snippet bdrz + border-radius: ${1}; +snippet bdr+ + border-right: ${1:1px} ${2:solid} #${3:000}; +snippet bdrc + border-right-color: #${1:000}; +snippet bdri + border-right-image: url(${1}); +snippet bdri:n + border-right-image: none; +snippet bdrs + border-right-style: ${1}; +snippet bdrs:n + border-right-style: none; +snippet bdrw + border-right-width: ${1}; +snippet bdr + border-right: ${1}; +snippet bdr:n + border-right: none; +snippet bdsp + border-spacing: ${1}; +snippet bds + border-style: ${1}; +snippet bds:ds + border-style: dashed; +snippet bds:dtds + border-style: dot-dash; +snippet bds:dtdtds + border-style: dot-dot-dash; +snippet bds:dt + border-style: dotted; +snippet bds:db + border-style: double; +snippet bds:g + border-style: groove; +snippet bds:h + border-style: hidden; +snippet bds:i + border-style: inset; +snippet bds:n + border-style: none; +snippet bds:o + border-style: outset; +snippet bds:r + border-style: ridge; +snippet bds:s + border-style: solid; +snippet bds:w + border-style: wave; +snippet bdt+ + border-top: ${1:1px} ${2:solid} #${3:000}; +snippet bdtc + border-top-color: #${1:000}; +snippet bdti + border-top-image: url(${1}); +snippet bdti:n + border-top-image: none; +snippet bdtli + border-top-left-image: url(${1}); +snippet bdtli:c + border-corner-image: continue; +snippet bdtli:n + border-corner-image: none; +snippet bdtlrz + border-top-left-radius: ${1}; +snippet bdtri + border-top-right-image: url(${1}); +snippet bdtri:c + border-top-right-image: continue; +snippet bdtri:n + border-top-right-image: none; +snippet bdtrrz + border-top-right-radius: ${1}; +snippet bdts + border-top-style: ${1}; +snippet bdts:n + border-top-style: none; +snippet bdtw + border-top-width: ${1}; +snippet bdt + border-top: ${1}; +snippet bdt:n + border-top: none; +snippet bdw + border-width: ${1}; +snippet bd + border: ${1}; +snippet bd:n + border: none; +snippet b + bottom: ${1}; +snippet b:a + bottom: auto; +snippet bxsh+ + box-shadow: ${1:0} ${2:0} ${3:0} #${4:000}; +snippet bxsh + box-shadow: ${1}; +snippet bxsh:n + box-shadow: none; +snippet bxz + box-sizing: ${1}; +snippet bxz:bb + box-sizing: border-box; +snippet bxz:cb + box-sizing: content-box; +snippet cps + caption-side: ${1}; +snippet cps:b + caption-side: bottom; +snippet cps:t + caption-side: top; +snippet cl + clear: ${1}; +snippet cl:b + clear: both; +snippet cl:l + clear: left; +snippet cl:n + clear: none; +snippet cl:r + clear: right; +snippet cp + clip: ${1}; +snippet cp:a + clip: auto; +snippet cp:r + clip: rect(${1:0} ${2:0} ${3:0} ${4:0}); +snippet c + color: #${1:000}; +snippet ct + content: ${1}; +snippet ct:a + content: attr(${1}); +snippet ct:cq + content: close-quote; +snippet ct:c + content: counter(${1}); +snippet ct:cs + content: counters(${1}); +snippet ct:ncq + content: no-close-quote; +snippet ct:noq + content: no-open-quote; +snippet ct:n + content: normal; +snippet ct:oq + content: open-quote; +snippet coi + counter-increment: ${1}; +snippet cor + counter-reset: ${1}; +snippet cur + cursor: ${1}; +snippet cur:a + cursor: auto; +snippet cur:c + cursor: crosshair; +snippet cur:d + cursor: default; +snippet cur:ha + cursor: hand; +snippet cur:he + cursor: help; +snippet cur:m + cursor: move; +snippet cur:p + cursor: pointer; +snippet cur:t + cursor: text; +snippet d + display: ${1}; +snippet d:mib + display: -moz-inline-box; +snippet d:mis + display: -moz-inline-stack; +snippet d:b + display: block; +snippet d:cp + display: compact; +snippet d:ib + display: inline-block; +snippet d:itb + display: inline-table; +snippet d:i + display: inline; +snippet d:li + display: list-item; +snippet d:n + display: none; +snippet d:ri + display: run-in; +snippet d:tbcp + display: table-caption; +snippet d:tbc + display: table-cell; +snippet d:tbclg + display: table-column-group; +snippet d:tbcl + display: table-column; +snippet d:tbfg + display: table-footer-group; +snippet d:tbhg + display: table-header-group; +snippet d:tbrg + display: table-row-group; +snippet d:tbr + display: table-row; +snippet d:tb + display: table; +snippet ec + empty-cells: ${1}; +snippet ec:h + empty-cells: hide; +snippet ec:s + empty-cells: show; +snippet exp + expression() +snippet fl + float: ${1}; +snippet fl:l + float: left; +snippet fl:n + float: none; +snippet fl:r + float: right; +snippet f+ + font: ${1:1em} ${2:Arial},${3:sans-serif}; +snippet fef + font-effect: ${1}; +snippet fef:eb + font-effect: emboss; +snippet fef:eg + font-effect: engrave; +snippet fef:n + font-effect: none; +snippet fef:o + font-effect: outline; +snippet femp + font-emphasize-position: ${1}; +snippet femp:a + font-emphasize-position: after; +snippet femp:b + font-emphasize-position: before; +snippet fems + font-emphasize-style: ${1}; +snippet fems:ac + font-emphasize-style: accent; +snippet fems:c + font-emphasize-style: circle; +snippet fems:ds + font-emphasize-style: disc; +snippet fems:dt + font-emphasize-style: dot; +snippet fems:n + font-emphasize-style: none; +snippet fem + font-emphasize: ${1}; +snippet ff + font-family: ${1}; +snippet ff:c + font-family: ${1:'Monotype Corsiva','Comic Sans MS'},cursive; +snippet ff:f + font-family: ${1:Capitals,Impact},fantasy; +snippet ff:m + font-family: ${1:Monaco,'Courier New'},monospace; +snippet ff:ss + font-family: ${1:Helvetica,Arial},sans-serif; +snippet ff:s + font-family: ${1:Georgia,'Times New Roman'},serif; +snippet fza + font-size-adjust: ${1}; +snippet fza:n + font-size-adjust: none; +snippet fz + font-size: ${1}; +snippet fsm + font-smooth: ${1}; +snippet fsm:aw + font-smooth: always; +snippet fsm:a + font-smooth: auto; +snippet fsm:n + font-smooth: never; +snippet fst + font-stretch: ${1}; +snippet fst:c + font-stretch: condensed; +snippet fst:e + font-stretch: expanded; +snippet fst:ec + font-stretch: extra-condensed; +snippet fst:ee + font-stretch: extra-expanded; +snippet fst:n + font-stretch: normal; +snippet fst:sc + font-stretch: semi-condensed; +snippet fst:se + font-stretch: semi-expanded; +snippet fst:uc + font-stretch: ultra-condensed; +snippet fst:ue + font-stretch: ultra-expanded; +snippet fs + font-style: ${1}; +snippet fs:i + font-style: italic; +snippet fs:n + font-style: normal; +snippet fs:o + font-style: oblique; +snippet fv + font-variant: ${1}; +snippet fv:n + font-variant: normal; +snippet fv:sc + font-variant: small-caps; +snippet fw + font-weight: ${1}; +snippet fw:b + font-weight: bold; +snippet fw:br + font-weight: bolder; +snippet fw:lr + font-weight: lighter; +snippet fw:n + font-weight: normal; +snippet f + font: ${1}; +snippet h + height: ${1}; +snippet h:a + height: auto; +snippet l + left: ${1}; +snippet l:a + left: auto; +snippet lts + letter-spacing: ${1}; +snippet lh + line-height: ${1}; +snippet lisi + list-style-image: url(${1}); +snippet lisi:n + list-style-image: none; +snippet lisp + list-style-position: ${1}; +snippet lisp:i + list-style-position: inside; +snippet lisp:o + list-style-position: outside; +snippet list + list-style-type: ${1}; +snippet list:c + list-style-type: circle; +snippet list:dclz + list-style-type: decimal-leading-zero; +snippet list:dc + list-style-type: decimal; +snippet list:d + list-style-type: disc; +snippet list:lr + list-style-type: lower-roman; +snippet list:n + list-style-type: none; +snippet list:s + list-style-type: square; +snippet list:ur + list-style-type: upper-roman; +snippet lis + list-style: ${1}; +snippet lis:n + list-style: none; +snippet mb + margin-bottom: ${1}; +snippet mb:a + margin-bottom: auto; +snippet ml + margin-left: ${1}; +snippet ml:a + margin-left: auto; +snippet mr + margin-right: ${1}; +snippet mr:a + margin-right: auto; +snippet mt + margin-top: ${1}; +snippet mt:a + margin-top: auto; +snippet m + margin: ${1}; +snippet m:4 + margin: ${1:0} ${2:0} ${3:0} ${4:0}; +snippet m:3 + margin: ${1:0} ${2:0} ${3:0}; +snippet m:2 + margin: ${1:0} ${2:0}; +snippet m:0 + margin: 0; +snippet m:a + margin: auto; +snippet mah + max-height: ${1}; +snippet mah:n + max-height: none; +snippet maw + max-width: ${1}; +snippet maw:n + max-width: none; +snippet mih + min-height: ${1}; +snippet miw + min-width: ${1}; +snippet op + opacity: ${1}; +snippet op:ie + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=${1:100}); +snippet op:ms + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${1:100})'; +snippet orp + orphans: ${1}; +snippet o+ + outline: ${1:1px} ${2:solid} #${3:000}; +snippet oc + outline-color: ${1:#000}; +snippet oc:i + outline-color: invert; +snippet oo + outline-offset: ${1}; +snippet os + outline-style: ${1}; +snippet ow + outline-width: ${1}; +snippet o + outline: ${1}; +snippet o:n + outline: none; +snippet ovs + overflow-style: ${1}; +snippet ovs:a + overflow-style: auto; +snippet ovs:mq + overflow-style: marquee; +snippet ovs:mv + overflow-style: move; +snippet ovs:p + overflow-style: panner; +snippet ovs:s + overflow-style: scrollbar; +snippet ovx + overflow-x: ${1}; +snippet ovx:a + overflow-x: auto; +snippet ovx:h + overflow-x: hidden; +snippet ovx:s + overflow-x: scroll; +snippet ovx:v + overflow-x: visible; +snippet ovy + overflow-y: ${1}; +snippet ovy:a + overflow-y: auto; +snippet ovy:h + overflow-y: hidden; +snippet ovy:s + overflow-y: scroll; +snippet ovy:v + overflow-y: visible; +snippet ov + overflow: ${1}; +snippet ov:a + overflow: auto; +snippet ov:h + overflow: hidden; +snippet ov:s + overflow: scroll; +snippet ov:v + overflow: visible; +snippet pb + padding-bottom: ${1}; +snippet pl + padding-left: ${1}; +snippet pr + padding-right: ${1}; +snippet pt + padding-top: ${1}; +snippet p + padding: ${1}; +snippet p:4 + padding: ${1:0} ${2:0} ${3:0} ${4:0}; +snippet p:3 + padding: ${1:0} ${2:0} ${3:0}; +snippet p:2 + padding: ${1:0} ${2:0}; +snippet p:0 + padding: 0; +snippet pgba + page-break-after: ${1}; +snippet pgba:aw + page-break-after: always; +snippet pgba:a + page-break-after: auto; +snippet pgba:l + page-break-after: left; +snippet pgba:r + page-break-after: right; +snippet pgbb + page-break-before: ${1}; +snippet pgbb:aw + page-break-before: always; +snippet pgbb:a + page-break-before: auto; +snippet pgbb:l + page-break-before: left; +snippet pgbb:r + page-break-before: right; +snippet pgbi + page-break-inside: ${1}; +snippet pgbi:a + page-break-inside: auto; +snippet pgbi:av + page-break-inside: avoid; +snippet pos + position: ${1}; +snippet pos:a + position: absolute; +snippet pos:f + position: fixed; +snippet pos:r + position: relative; +snippet pos:s + position: static; +snippet q + quotes: ${1}; +snippet q:en + quotes: '\201C' '\201D' '\2018' '\2019'; +snippet q:n + quotes: none; +snippet q:ru + quotes: '\00AB' '\00BB' '\201E' '\201C'; +snippet rz + resize: ${1}; +snippet rz:b + resize: both; +snippet rz:h + resize: horizontal; +snippet rz:n + resize: none; +snippet rz:v + resize: vertical; +snippet r + right: ${1}; +snippet r:a + right: auto; +snippet tbl + table-layout: ${1}; +snippet tbl:a + table-layout: auto; +snippet tbl:f + table-layout: fixed; +snippet tal + text-align-last: ${1}; +snippet tal:a + text-align-last: auto; +snippet tal:c + text-align-last: center; +snippet tal:l + text-align-last: left; +snippet tal:r + text-align-last: right; +snippet ta + text-align: ${1}; +snippet ta:c + text-align: center; +snippet ta:l + text-align: left; +snippet ta:r + text-align: right; +snippet td + text-decoration: ${1}; +snippet td:l + text-decoration: line-through; +snippet td:n + text-decoration: none; +snippet td:o + text-decoration: overline; +snippet td:u + text-decoration: underline; +snippet te + text-emphasis: ${1}; +snippet te:ac + text-emphasis: accent; +snippet te:a + text-emphasis: after; +snippet te:b + text-emphasis: before; +snippet te:c + text-emphasis: circle; +snippet te:ds + text-emphasis: disc; +snippet te:dt + text-emphasis: dot; +snippet te:n + text-emphasis: none; +snippet th + text-height: ${1}; +snippet th:a + text-height: auto; +snippet th:f + text-height: font-size; +snippet th:m + text-height: max-size; +snippet th:t + text-height: text-size; +snippet ti + text-indent: ${1}; +snippet ti:- + text-indent: -9999px; +snippet tj + text-justify: ${1}; +snippet tj:a + text-justify: auto; +snippet tj:d + text-justify: distribute; +snippet tj:ic + text-justify: inter-cluster; +snippet tj:ii + text-justify: inter-ideograph; +snippet tj:iw + text-justify: inter-word; +snippet tj:k + text-justify: kashida; +snippet tj:t + text-justify: tibetan; +snippet to+ + text-outline: ${1:0} ${2:0} #${3:000}; +snippet to + text-outline: ${1}; +snippet to:n + text-outline: none; +snippet tr + text-replace: ${1}; +snippet tr:n + text-replace: none; +snippet tsh+ + text-shadow: ${1:0} ${2:0} ${3:0} #${4:000}; +snippet tsh + text-shadow: ${1}; +snippet tsh:n + text-shadow: none; +snippet tt + text-transform: ${1}; +snippet tt:c + text-transform: capitalize; +snippet tt:l + text-transform: lowercase; +snippet tt:n + text-transform: none; +snippet tt:u + text-transform: uppercase; +snippet tw + text-wrap: ${1}; +snippet tw:no + text-wrap: none; +snippet tw:n + text-wrap: normal; +snippet tw:s + text-wrap: suppress; +snippet tw:u + text-wrap: unrestricted; +snippet t + top: ${1}; +snippet t:a + top: auto; +snippet va + vertical-align: ${1}; +snippet va:bl + vertical-align: baseline; +snippet va:b + vertical-align: bottom; +snippet va:m + vertical-align: middle; +snippet va:sub + vertical-align: sub; +snippet va:sup + vertical-align: super; +snippet va:tb + vertical-align: text-bottom; +snippet va:tt + vertical-align: text-top; +snippet va:t + vertical-align: top; +snippet v + visibility: ${1}; +snippet v:c + visibility: collapse; +snippet v:h + visibility: hidden; +snippet v:v + visibility: visible; +snippet whsc + white-space-collapse: ${1}; +snippet whsc:ba + white-space-collapse: break-all; +snippet whsc:bs + white-space-collapse: break-strict; +snippet whsc:k + white-space-collapse: keep-all; +snippet whsc:l + white-space-collapse: loose; +snippet whsc:n + white-space-collapse: normal; +snippet whs + white-space: ${1}; +snippet whs:n + white-space: normal; +snippet whs:nw + white-space: nowrap; +snippet whs:pl + white-space: pre-line; +snippet whs:pw + white-space: pre-wrap; +snippet whs:p + white-space: pre; +snippet wid + widows: ${1}; +snippet w + width: ${1}; +snippet w:a + width: auto; +snippet wob + word-break: ${1}; +snippet wob:ba + word-break: break-all; +snippet wob:bs + word-break: break-strict; +snippet wob:k + word-break: keep-all; +snippet wob:l + word-break: loose; +snippet wob:n + word-break: normal; +snippet wos + word-spacing: ${1}; +snippet wow + word-wrap: ${1}; +snippet wow:no + word-wrap: none; +snippet wow:n + word-wrap: normal; +snippet wow:s + word-wrap: suppress; +snippet wow:u + word-wrap: unrestricted; +snippet z + z-index: ${1}; +snippet z:a + z-index: auto; +snippet zoo + zoom: 1; diff --git a/diff.snippets b/diff.snippets new file mode 100644 index 0000000..de28450 --- /dev/null +++ b/diff.snippets @@ -0,0 +1,11 @@ +# DEP-3 (http://dep.debian.net/deps/dep3/) style patch header +snippet header DEP-3 style header + Description: ${1} + Origin: ${2} + Bug: ${3} + Forwarded: ${4} + Author: ${5:`g:snips_author`} + Reviewed-by: ${6} + Last-Update: ${7:`strftime("%Y-%m-%d")`} + Applied-Upstream: ${8} + diff --git a/django.snippets b/django.snippets new file mode 100644 index 0000000..b89cb5b --- /dev/null +++ b/django.snippets @@ -0,0 +1,108 @@ +# Model Fields + +# Note: Optional arguments are using defaults that match what Django will use +# as a default, e.g. with max_length fields. Doing this as a form of self +# documentation and to make it easy to know whether you should override the +# default or not. + +# Note: Optional arguments that are booleans will use the opposite since you +# can either not specify them, or override them, e.g. auto_now_add=False. + +snippet auto + ${1:FIELDNAME} = models.AutoField() +snippet bool + ${1:FIELDNAME} = models.BooleanField(${2:default=True}) +snippet char + ${1:FIELDNAME} = models.CharField(max_length=${2}${3:, blank=True}) +snippet comma + ${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2}${3:, blank=True}) +snippet date + ${1:FIELDNAME} = models.DateField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True}) +snippet datetime + ${1:FIELDNAME} = models.DateTimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True}) +snippet decimal + ${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3}) +snippet email + ${1:FIELDNAME} = models.EmailField(max_length=${2:75}${3:, blank=True}) +snippet file + ${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload}${3:, max_length=100}) +snippet filepath + ${1:FIELDNAME} = models.FilePathField(path=${2:"/abs/path/to/dir"}${3:, max_length=100}${4:, match="*.ext"}${5:, recursive=True}${6:, blank=True, }) +snippet float + ${1:FIELDNAME} = models.FloatField() +snippet image + ${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100}) +snippet int + ${1:FIELDNAME} = models.IntegerField() +snippet ip + ${1:FIELDNAME} = models.IPAddressField() +snippet nullbool + ${1:FIELDNAME} = models.NullBooleanField() +snippet posint + ${1:FIELDNAME} = models.PositiveIntegerField() +snippet possmallint + ${1:FIELDNAME} = models.PositiveSmallIntegerField() +snippet slug + ${1:FIELDNAME} = models.SlugField(max_length=${2:50}${3:, blank=True}) +snippet smallint + ${1:FIELDNAME} = models.SmallIntegerField() +snippet text + ${1:FIELDNAME} = models.TextField(${2:blank=True}) +snippet time + ${1:FIELDNAME} = models.TimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True}) +snippet url + ${1:FIELDNAME} = models.URLField(${2:verify_exists=False}${3:, max_length=200}${4:, blank=True}) +snippet xml + ${1:FIELDNAME} = models.XMLField(schema_path=${2:None}${3:, blank=True}) +# Relational Fields +snippet fk + ${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, to_field=''}) +snippet m2m + ${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, symmetrical=False}${6:, through=''}${7:, db_table=''}) +snippet o2o + ${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}${3:, parent_link=True}${4:, related_name=''}${5:, limit_choices_to=}${6:, to_field=''}) + +# Code Skeletons + +snippet form + class ${1:FormName}(forms.Form): + """${2:docstring}""" + ${3} + +snippet model + class ${1:ModelName}(models.Model): + """${2:docstring}""" + ${3} + + class Meta: + ${4} + + def __unicode__(self): + ${5} + + def save(self, force_insert=False, force_update=False): + ${6} + + @models.permalink + def get_absolute_url(self): + return ('${7:view_or_url_name}' ${8}) + +snippet modeladmin + class ${1:ModelName}Admin(admin.ModelAdmin): + ${2} + + admin.site.register($1, $1Admin) + +snippet tabularinline + class ${1:ModelName}Inline(admin.TabularInline): + model = $1 + +snippet stackedinline + class ${1:ModelName}Inline(admin.StackedInline): + model = $1 + +snippet r2r + return render_to_response('${1:template.html}', { + ${2} + }${3:, context_instance=RequestContext(request)} + ) diff --git a/erlang.snippets b/erlang.snippets new file mode 100644 index 0000000..7238149 --- /dev/null +++ b/erlang.snippets @@ -0,0 +1,39 @@ +# module and export all +snippet mod + -module(${1:`Filename('', 'my')`}). + + -compile([export_all]). + + start() -> + ${2} + + stop() -> + ok. +# define directive +snippet def + -define(${1:macro}, ${2:body}).${3} +# export directive +snippet exp + -export([${1:function}/${2:arity}]). +# include directive +snippet inc + -include("${1:file}").${2} +# behavior directive +snippet beh + -behaviour(${1:behaviour}).${2} +# if expression +snippet if + if + ${1:guard} -> + ${2:body} + end +# case expression +snippet case + case ${1:expression} of + ${2:pattern} -> + ${3:body}; + end +# record directive +snippet rec + -record(${1:record}, { + ${2:field}=${3:value}}).${4} diff --git a/eruby.snippets b/eruby.snippets new file mode 100644 index 0000000..bebfc02 --- /dev/null +++ b/eruby.snippets @@ -0,0 +1,124 @@ +# .erb and .rhmtl files + +# Includes html.snippets + +# Rails ***************************** +snippet rc + <% ${1} -%> +snippet rce + <%= ${1} %>${2} +snippet end + <% end -%>${1} +snippet for + <% for ${2:item} in $1 %> + ${3} + <% end %> +snippet rp + <%= render :partial => '${1:item}' %> +snippet rpl + <%= render :partial => '${1:item}', :locals => { :${2:name} => '${3:value}'$4 } %> +snippet rps + <%= render :partial => '${1:item}', :status => ${2:500} %> +snippet rpc + <%= render :partial => '${1:item}', :collection => ${2:items} %> +snippet lia + <%= link_to '${1:link text...}', :action => '${2:index}' %> +snippet liai + <%= link_to '${1:link text...}', :action => '${2:edit}', :id => ${3:@item} %> +snippet lic + <%= link_to '${1:link text...}', :controller => '${2:items}' %> +snippet lica + <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:index}' %> +snippet licai + <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:edit}', :id => ${4:@item} %> +snippet yield + <%= yield${1::content_symbol}%>${2} +snippet conf + <% content_for ${1::foo} do %> + ${2} + <% end -%> +# Ruby ****************************** +snippet : + :${1:key} => ${2:"value"}${3} +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 case + case ${1:object} + when ${2:condition} + ${3} + end +snippet when + when ${1:condition} + ${2} + end +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 col + collect { |${1:e}| ${2} } +snippet det + detect { |${1:e}| ${2} } +snippet rej + reject { |${1:e}|, ${2} } +snippet sel + select { |${1:e}|, ${2} } diff --git a/falcon.snippets b/falcon.snippets new file mode 100644 index 0000000..2d12df3 --- /dev/null +++ b/falcon.snippets @@ -0,0 +1,110 @@ +snippet #! + #!/usr/bin/env falcon +# Import +snippet imp + import ${1:module} +# Function +snippet fun + function ${2:function_name}(${3}) + ${4:/* code */} + end +# Class +snippet class + class ${1:class_name}(${2:class_params}) + ${3:/* members/methods */} + end +# If +snippet if + if ${1:condition} + ${2:/* code */} + end +# If else +snippet ife + if ${1:condition} + ${2:/* code */} + else + ${1} + end +# If else if +snippet elif + elif ${1:condition} + ${2:/* code */} +# For/in Loop +snippet forin + for ${1:element} in ${2:container} + ${3:/* code */} + end +# For/to Loop +snippet forto + for ${1:lowerbound} to ${2:upperbound} + ${3:/* code */} + end +# While Loop +snippet while + while ${1:conidition} + ${2:/* code */} + end + +#==================================== +# Common Licenses +#==================================== +# GPL +snippet gpl + /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version ${3:version} of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +# APLv2 +snippet apache + /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +# BSD +snippet bsd + /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/haml.snippets b/haml.snippets new file mode 100644 index 0000000..61e9cf2 --- /dev/null +++ b/haml.snippets @@ -0,0 +1,20 @@ +snippet t + %table + %tr + %th + ${1:headers} + %tr + %td + ${2:headers} +snippet ul + %ul + %li + ${1:item} + %li +snippet =rp + = render :partial => '${1:partial}' +snippet =rpl + = render :partial => '${1:partial}', :locals => {} +snippet =rpc + = render :partial => '${1:partial}', :collection => @$1 + diff --git a/html.snippets b/html.snippets new file mode 100644 index 0000000..34fae04 --- /dev/null +++ b/html.snippets @@ -0,0 +1,244 @@ +# 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 + +snippet doctype HTML 4.01 Transitional + +snippet doctype HTML 5 + +snippet doctype XHTML 1.0 Frameset + +snippet doctype XHTML 1.0 Strict + +snippet doctype XHTML 1.0 Transitional + +snippet doctype XHTML 1.1 + +# HTML Doctype 4.01 Strict +snippet docts + +# HTML Doctype 4.01 Transitional +snippet doct + +# HTML Doctype 5 +snippet doct5 + +# XHTML Doctype 1.0 Frameset +snippet docxf + +# XHTML Doctype 1.0 Strict +snippet docxs + +# XHTML Doctype 1.0 Transitional +snippet docxt + +# XHTML Doctype 1.1 +snippet docx + +snippet html + + ${1} + +snippet xhtml + + ${1} + +snippet body + + ${1} + +snippet head + + + + ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} + ${2} + +snippet title + ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}${2} +snippet script + ${2} +snippet scriptsrc + ${2} +snippet style + ${3} +snippet base + +snippet r + +snippet div +
+ ${2} +
+# Embed QT Movie +snippet movie + + + + + + ${6} +snippet fieldset +
+ ${1:name} + + ${3} +
+snippet form +
+ ${3} + + +

+
+snippet h1 +

${2:$1}

+snippet input + ${4} +snippet label + ${7} +snippet link + ${4} +snippet mailto + ${3:email me} +snippet meta + ${3} +snippet opt + ${3} +snippet optt + ${2} +snippet select + ${5} +snippet table + + + +
${2:Header}
${3:Data}
${4} +snippet textarea + ${5} +snippet # + #{${1:tagName}} /}${2} +snippet ## + #{${1:tagName} ${2:param}} ${3} #{/${1}} +snippet dobody + #{doBody /}${1} +snippet dolayout + #{doLayout /}${1} +snippet elseif + #{elseif ${1:condition}} ${2} #{/elseif} +snippet else + #{else} ${1} #{/else} +snippet extends + #{extends '${1:class}' /} ${2} +snippet get + #{get '${1:param}' /} ${2} +snippet if + #{if ${1:condition}} ${2} #{/if} +snippet include + #{include ${1:page} /} ${2} +snippet list + #{list items:${1:list}, as:'${2:item}'} ${3} #{/list} +snippet set + #{set ${1:var}: '${2:value}' /} +snippet $ + \$\{${1:expression}}${2} +snippet % + %{${1:script}}%${2} +snippet * + *{ ${1:comment} }*${2} +snippet em + ${1:text}${2} +snippet li +
  • ${1:item}
  • ${2} +snippet p +

    ${1:text}

    ${2} +snippet span + ${2}${3} +snippet strong + ${1:text}${2} +snippet ul +
      +
    • ${1:item}
    • ${2} +
    +snippet ulc +
      +
    • ${2:item}
    • ${3} +
    +snippet uli +
      +
    • ${2:item}
    • ${3} +
    +snippet @ + @{${1:action}}${2} diff --git a/htmldjango.snippets b/htmldjango.snippets new file mode 100644 index 0000000..6bff8c1 --- /dev/null +++ b/htmldjango.snippets @@ -0,0 +1,137 @@ +# Generic tags + +snippet % + {% ${1} %}${2} +snippet %% + {% ${1:tag_name} %} + ${2} + {% end$1 %} +snippet { + {{ ${1} }}${2} + +# Template Tags + +snippet autoescape + {% autoescape ${1:off} %} + ${2} + {% endautoescape %} +snippet block + {% block ${1} %} + ${2} + {% endblock %} +snippet # + {# ${1:comment} #} +snippet comment + {% comment %} + ${1} + {% endcomment %} +snippet cycle + {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +snippet debug + {% debug %} +snippet extends + {% extends "${1:base.html}" %} +snippet filter + {% filter ${1} %} + ${2} + {% endfilter %} +snippet firstof + {% firstof ${1} %} +snippet for + {% for ${1} in ${2} %} + ${3} + {% endfor %} +snippet empty + {% empty %} + ${1} +snippet if + {% if ${1} %} + ${2} + {% endif %} +snippet else + {% else %} + ${1} +snippet ifchanged + {% ifchanged %}${1}{% endifchanged %} +snippet ifequal + {% ifequal ${1} ${2} %} + ${3} + {% endifequal %} +snippet ifnotequal + {% ifnotequal ${1} ${2} %} + ${3} + {% endifnotequal %} +snippet include + {% include "${1}" %} +snippet load + {% load ${1} %} +snippet now + {% now "${1:jS F Y H:i}" %} +snippet regroup + {% regroup ${1} by ${2} as ${3} %} +snippet spaceless + {% spaceless %}${1}{% endspaceless %} +snippet ssi + {% ssi ${1} %} +snippet trans + {% trans "${1:string}" %} +snippet url + {% url ${1} as ${2} %} +snippet widthratio + {% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +snippet with + {% with ${1} as ${2} %} + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add + add:"${1}" +snippet center + center:"${1}" +snippet cut + cut:"${1}" +snippet date + date:"${1}" +snippet default + default:"${1}" +snippet defaultifnone + default_if_none:"${1}" +snippet dictsort + dictsort:"${1}" +snippet dictsortrev + dictsortreversed:"${1}" +snippet divisibleby + divisibleby:"${1}" +snippet floatformat + floatformat:"${1}" +snippet getdigit + get_digit:"${1}" +snippet join + join:"${1}" +snippet lengthis + length_is:"${1}" +snippet pluralize + pluralize:"${1}" +snippet removetags + removetags:"${1}" +snippet slice + slice:"${1}" +snippet stringformat + stringformat:"${1}" +snippet time + time:"${1}" +snippet truncatewords + truncatewords:${1} +snippet truncatewordshtml + truncatewords_html:${1} +snippet urlizetrunc + urlizetrunc:${1} +snippet wordwrap + wordwrap:${1} + diff --git a/java.snippets b/java.snippets new file mode 100644 index 0000000..37494c0 --- /dev/null +++ b/java.snippets @@ -0,0 +1,144 @@ +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 imp + implements +snippet ext + extends +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} +snippet try + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } +snippet tryf + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } finally { + } +snippet rst + ResultSet ${1:rst}${2: = null}${3};${4} +snippet mm + @ManyToMany + ${1} +snippet mo + @ManyToOne + ${1} +snippet om + OneToMany${1:(cascade=CascadeType.ALL)} + ${2} +snippet oo + @OneToOne + ${1} +snippet action + public static void ${1:index}(${2:args}) { ${3} } +snippet before + @Before + static void ${1:intercept}(${2:args}) { ${3} } +snippet debug + Logger.debug(${1:param});${2} +snippet error + Logger.error(${1:param});${2} +snippet findall + List<${1:listName}> ${2:items} = ${1}.findAll();${3} +snippet findbyid + ${1:var} ${2:item} = ${1}.findById(${3});${4} +snippet info + Logger.info(${1:param});${2} +snippet rnf + notFound(${1:param});${2} +snippet rnfin + notFoundIfNull(${1:param});${2} +snippet rr + redirect(${1:param});${2} +snippet ru + unauthorized(${1:param});${2} +snippet ren + render(${1:param});${2} +snippet rena + renderArgs.put("${1}", ${2});${3} +snippet renb + renderBinary(${1:param});${2} +snippet renj + renderJSON(${1:param});${2} +snippet renx + renderXml(${1:param});${2} +snippet unless + (unless=${1:param});${2} +snippet warn + Logger.warn(${1:param});${2} diff --git a/javascript.snippets b/javascript.snippets new file mode 100644 index 0000000..ba865ce --- /dev/null +++ b/javascript.snippets @@ -0,0 +1,102 @@ +# 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}) { + ${3} + }${2:;} +# Immediate function +snippet (f + (function(${1}) { + ${3:/* code */} + }(${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: += 1}) { + ${4:$1[$2]} + }; +# for (...) {...} (Improved Native For-Loop) +snippet forr + for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3: -= 1}) { + ${4:$1[$2]} + }; +# while (...) {...} +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + } +# try +snippet try + try { + ${1:/* code */} + } catch(e) { + ${2:/* handle error */} + } +# 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} +# Get Element +snippet try + try { + ${2} + } catch (${2:e}) { + } +# console.log (Firebug) +snippet cl + console.log(${1}); diff --git a/jsp.snippets b/jsp.snippets new file mode 100644 index 0000000..0d8aa2b --- /dev/null +++ b/jsp.snippets @@ -0,0 +1,99 @@ +snippet @page + <%@page contentType="text/html" pageEncoding="UTF-8"%> +snippet jstl + <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +snippet jstl:c + <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +snippet jstl:fn + <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +snippet cpath + ${pageContext.request.contextPath} +snippet cout + +snippet cset + +snippet cremove + +snippet ccatch + +snippet cif + + ${2} + +snippet cchoose + + ${1} + +snippet cwhen + + ${2} + +snippet cother + + ${1} + +snippet cfore + + ${4:} + +snippet cfort + ${2:item1,item2,item3} + + ${5:} + +snippet cparam + +snippet cparam+ + + cparam+${3} +snippet cimport + +snippet cimport+ + + + cparam+${4} + +snippet curl + + ${3} +snippet curl+ + + + cparam+${6} + + ${3} +snippet credirect + +snippet contains + ${fn:contains(${1:string}, ${2:substr})} +snippet contains:i + ${fn:containsIgnoreCase(${1:string}, ${2:substr})} +snippet endswith + ${fn:endsWith(${1:string}, ${2:suffix})} +snippet escape + ${fn:escapeXml(${1:string})} +snippet indexof + ${fn:indexOf(${1:string}, ${2:substr})} +snippet join + ${fn:join(${1:collection}, ${2:delims})} +snippet length + ${fn:length(${1:collection_or_string})} +snippet replace + ${fn:replace(${1:string}, ${2:substr}, ${3:replace})} +snippet split + ${fn:split(${1:string}, ${2:delims})} +snippet startswith + ${fn:startsWith(${1:string}, ${2:prefix})} +snippet substr + ${fn:substring(${1:string}, ${2:begin}, ${3:end})} +snippet substr:a + ${fn:substringAfter(${1:string}, ${2:substr})} +snippet substr:b + ${fn:substringBefore(${1:string}, ${2:substr})} +snippet lc + ${fn:toLowerCase(${1:string})} +snippet uc + ${fn:toUpperCase(${1:string})} +snippet trim + ${fn:trim(${1:string})} diff --git a/mako.snippets b/mako.snippets new file mode 100644 index 0000000..2a0aef9 --- /dev/null +++ b/mako.snippets @@ -0,0 +1,54 @@ +snippet def + <%def name="${1:name}"> + ${2:} + +snippet call + <%call expr="${1:name}"> + ${2:} + +snippet doc + <%doc> + ${1:} + +snippet text + <%text> + ${1:} + +snippet for + % for ${1:i} in ${2:iter}: + ${3:} + % endfor +snippet if if + % if ${1:condition}: + ${2:} + % endif +snippet if if/else + % if ${1:condition}: + ${2:} + % else: + ${3:} + % endif +snippet try + % try: + ${1:} + % except${2:}: + ${3:pass} + % endtry +snippet wh + % while ${1:}: + ${2:} + % endwhile +snippet $ + ${ ${1:} } +snippet <% + <% ${1:} %> +snippet +snippet inherit + <%inherit file="${1:filename}" /> +snippet include + <%include file="${1:filename}" /> +snippet namespace + <%namespace file="${1:name}" /> +snippet page + <%page args="${1:}" /> diff --git a/markdown.snippets b/markdown.snippets new file mode 100644 index 0000000..d8d44c7 --- /dev/null +++ b/markdown.snippets @@ -0,0 +1,7 @@ +# Markdown + +snippet [ + [${1:text}](http://${2:address} "${3:title}") +snippet ![ + ![${1:alttext}](${2:/images/image.jpg} "${3:title}") + diff --git a/objc.snippets b/objc.snippets new file mode 100644 index 0000000..85b80d9 --- /dev/null +++ b/objc.snippets @@ -0,0 +1,247 @@ +# #import <...> +snippet Imp + #import <${1:Cocoa/Cocoa.h}>${2} +# #import "..." +snippet imp + #import "${1:`Filename()`.h}"${2} +# @selector(...) +snippet sel + @selector(${1:method}:)${3} +# @"..." string +snippet s + @"${1}"${2} +# Object +snippet o + ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5} +# NSLog(...) +snippet log + NSLog(@"${1:%@}"${2});${3} +# Class +snippet objc + @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} + { + } + @end + + @implementation $1 + ${3} + @end +# Class Interface +snippet int + @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} + {${3} + } + ${4} + @end +snippet @interface + @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} + {${3} + } + ${4} + @end +# Class Implementation +snippet impl + @implementation ${1:`Filename('', 'someClass')`} + ${2} + @end +snippet @implementation + @implementation ${1:`Filename('', 'someClass')`} + ${2} + @end +# Protocol +snippet pro + @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:} + ${3} + @end +snippet @protocol + @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:} + ${3} + @end +# init Definition +snippet init + - (id)init + { + if (self = [super init]) { + ${1} + } + return self; + } +# dealloc Definition +snippet dealloc + - (void) dealloc + { + ${1:deallocations} + [super dealloc]; + } +snippet su + [super ${1:init}]${2} +snippet ibo + IBOutlet ${1:NSSomeClass} *${2:$1};${3} +# Category +snippet cat + @interface ${1:NSObject} (${2:MyCategory}) + @end + + @implementation $1 ($2) + ${3} + @end +# Category Interface +snippet cath + @interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory}) + ${3} + @end +# Method +snippet m + - (${1:id})${2:method} + { + ${3} + } +# Method declaration +snippet md + - (${1:id})${2:method};${3} +# IBAction declaration +snippet ibad + - (IBAction)${1:method}:(${2:id})sender;${3} +# IBAction method +snippet iba + - (IBAction)${1:method}:(${2:id})sender + { + ${3} + } +# awakeFromNib method +snippet wake + - (void)awakeFromNib + { + ${1} + } +# 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; + } +# Accessor Methods For: +# Object +snippet objacc + - (${1:id})${2:thing} + { + return $2; + } + + - (void)set$2:($1)${3:new$2} + { + [$3 retain]; + [$2 release]; + $2 = $3; + }${4} +# for (object in array) +snippet forin + for (${1:Class} *${2:some$1} in ${3:array}) { + ${4} + } +snippet fore + for (${1:object} in ${2:array}) { + ${3:statements} + } +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} + } +snippet fora + unsigned int ${1:object}Count = [${2:array} count]; + + for (unsigned int index = 0; index < $1Count; index++) { + ${3:id} $1 = [$2 $1AtIndex:index]; + ${4} + } +# Try / Catch Block +snippet @try + @try { + ${1:statements} + } + @catch (NSException * e) { + ${2:handler} + } + @finally { + ${3:statements} + } +snippet @catch + @catch (${1:exception}) { + ${2:handler} + } +snippet @finally + @finally { + ${1:statements} + } +# 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:property};${2} +# [[ alloc] init] +snippet alloc + [[${1:foo} alloc] init${2}];${3} +snippet a + [[${1:foo} alloc] init${2}];${3} +# retain +snippet ret + [${1:foo} retain];${2} +# release +snippet rel + [${1:foo} release]; +# autorelease +snippet arel + [${1:foo} autorelease]; +# autorelease pool +snippet pool + NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; + ${2:/* code */} + [$1 drain]; +# Throw an exception +snippet except + NSException *${1:badness}; + $1 = [NSException exceptionWithName:@"${2:$1Name}" + reason:@"${3}" + userInfo:nil]; + [$1 raise]; +snippet prag + #pragma mark ${1:-} +snippet cl + @class ${1:Foo};${2} +snippet color + [[NSColor ${1:blackColor}] set]; +# NSArray +snippet array + NSMutableArray *${1:array} = [NSMutable array];${2} +snippet nsa + NSArray ${1} +snippet nsma + NSMutableArray ${1} +snippet aa + NSArray * array;${1} +snippet ma + NSMutableArray * array;${1} +# NSDictionary +snippet dict + NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} +snippet nsd + NSDictionary ${1} +snippet nsmd + NSMutableDictionary ${1} +# NSString +snippet nss + NSString ${1} +snippet nsms + NSMutableString ${1} diff --git a/perl.snippets b/perl.snippets new file mode 100644 index 0000000..381831f --- /dev/null +++ b/perl.snippets @@ -0,0 +1,97 @@ +# #!/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} +# C-style For Loop +snippet cfor + for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4:# body...} + } +# For loop one-line +snippet xfor + ${1:expression} for @${2:array};${3} +# Foreach Loop +snippet for + foreach my $${1:x} (@${2:array}) { + ${3:# body...} + } +# Foreach Loop One-line +snippet fore + ${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} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; + ${3} diff --git a/php.snippets b/php.snippets new file mode 100644 index 0000000..d7308ae --- /dev/null +++ b/php.snippets @@ -0,0 +1,247 @@ +snippet php + +snippet phpil + +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 G + $GLOBALS['${1:variable}'] +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:value}) { + ${3:// code...} + } +snippet foreachk + foreach ($${1:variable} as $${2:key} => $${3:value}) { + ${4:// code...} + } +snippet fun + ${1:public }function ${2:FunctionName}(${3}) + { + ${4:// code...} + } +# $... = array (...) +snippet array + $${1:arrayName} = array('${2}' => ${3});${4} +snippet try + try { + ${2} + } catch (${1:Exception} $e) { + } +# lambda with closure +snippet lambda + ${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) { + ${4} + }; +# pre_dump(); +snippet pd + echo '
    '; var_dump(${1}); echo '
    '; +# pre_dump(); die(); +snippet pdd + echo '
    '; var_dump(${1}); echo '
    '; die(${2:}); +snippet vd + var_dump(${1}); + +snippet http_redirect + header ("HTTP/1.1 301 Moved Permanently"); + header ("Location: ".URL); + exit(); diff --git a/progress.snippets b/progress.snippets new file mode 100644 index 0000000..0e6d47b --- /dev/null +++ b/progress.snippets @@ -0,0 +1,58 @@ +# Progress/OpenEdge ABL snippets +# define +snippet defbuf + DEFINE BUFFER b_${1:TableName} FOR $1 ${2}. +snippet defvar + DEFINE VARIABLE ${1:VariableName} AS ${2}. +snippet nl + NO-LOCK +snippet ne + NO-ERROR +snippet nle + NO-LOCK NO-ERROR +snippet ini + INITIAL ${1:?} +snippet nu + NO-UNDO +snippet err + ERROR +snippet ff + FIND FIRST ${1:BufferName} + ${2:WHERE $1.${3}} ${4} +snippet input + DEFINE INPUT PARAMETER ${1:ParamName} AS ${2}. +snippet output + DEFINE OUTPUT PARAMETER ${1:ParamName} AS ${2:ParamType}. +snippet proc + + /******************************************************************************/ + + PROCEDURE ${1:ProcName}: + + ${2} + + END PROCEDURE. /* $1 */ + + /******************************************************************************/ + +snippet alert + MESSAGE "${1:MessageContent}" ${2:Data} VIEW-AS ALERT-BOX. +snippet if + IF ${1:Condition} + THEN ${2:Action} + ${3:ELSE ${4:OtherWise}} +snippet do + DO${1: Clauses}: + ${2} + END. +# datatypes +snippet int + INTEGER +snippet char + CHARACTER +snippet log + LOGICAL +snippet dec + DECIMAL +snippet sep + /* ------------------------------------------------------------------------- */ diff --git a/python.snippets b/python.snippets new file mode 100644 index 0000000..8e26d2f --- /dev/null +++ b/python.snippets @@ -0,0 +1,122 @@ +snippet #! + #!/usr/bin/env python +snippet imp + import ${1:module} +# Module Docstring +snippet docs + ''' + File: ${1:`Filename('$1.py', 'foo.py')`} + Author: ${2:`g:snips_author`} + Description: ${3} + ''' +snippet wh + while ${1:condition}: + ${2:# code...} +# dowh - does the same as do...while in other languages +snippet dowh + while True: + ${1:# code...} + if ${2:condition}: + break +snippet with + with ${1:expr} as ${2:var}: + ${3:# code...} +snippet for + for ${1:needle} in ${2:haystack}: + ${3:# 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} +snippet deff + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${3} +# 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): + ${4:self._$1 = value} +# Lambda +snippet ld + ${1:var} = lambda ${2:vars} : ${3:action} +snippet . + self. +snippet try Try/Except + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} +snippet try Try/Except/Else + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} + else: + ${5:pass} +snippet try Try/Except/Finally + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} + finally: + ${5:pass} +snippet try Try/Except/Else/Finally + 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} +# python debugger (pdb) +snippet pdb + import pdb; pdb.set_trace() +# ipython debugger (ipdb) +snippet ipdb + import ipdb; ipdb.set_trace() +# ipython debugger (pdbbb) +snippet pdbbb + import pdbpp; pdbpp.set_trace() +# GPL +snippet gpl + # ${1:Name} + # Copyright (C) `strftime("%Y")` ${2:Author} + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation, either version 3 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + + ${3:#code} diff --git a/rst.snippets b/rst.snippets new file mode 100644 index 0000000..d31a13f --- /dev/null +++ b/rst.snippets @@ -0,0 +1,22 @@ +# rst + +snippet : + :${1:Text}: ${2:blah blah} +snippet * + *${1:Emphasis}* +snippet ** + **${1:Strong emphasis}** +snippet _ + \`${1:Text}\`_ + .. _\`$1\`: ${2:blah blah} +snippet = + ${1:Title} + =====${2:=} + ${3} +snippet - + ${1:Title} + -----${2:-} + ${3} +snippet cont: + .. contents:: + diff --git a/ruby.snippets b/ruby.snippets new file mode 100644 index 0000000..31b8416 --- /dev/null +++ b/ruby.snippets @@ -0,0 +1,562 @@ +# #!/usr/bin/env ruby +snippet #! + #!/usr/bin/env ruby + +# New Block +snippet =b + =begin rdoc + ${1} + =end +snippet y + :yields: ${1:arguments} +snippet rb + #!/usr/bin/env ruby -wKU +snippet beg + begin + ${3} + rescue ${1:Exception} => ${2:e} + end + +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 for + for ${1:e} in ${2:c} + ${3} + 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 + + module InstanceMethods + + end + + def self.included(receiver) + receiver.extend ClassMethods + receiver.send :include, InstanceMethods + end + 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 ead + each do |${1:e}| + ${2} + end +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 eaid + each_index do |${1:i}| + ${2} + end +snippet eak + each_key { |${1:key}| ${2} } +snippet eakd + each_key do |${1:key}| + ${2} + end +snippet eal + each_line { |${1:line}| ${2} } +snippet eald + each_line do |${1:line}| + ${2} + end +snippet eap + each_pair { |${1:name}, ${2:val}| ${3} } +snippet eapd + each_pair do |${1:name}, ${2:val}| + ${3} + end +snippet eas- + each_slice(${1:2}) { |${2:group}| ${3} } +snippet easd- + each_slice(${1:2}) do |${2:group}| + ${3} + end +snippet eav + each_value { |${1:val}| ${2} } +snippet eavd + each_value do |${1:val}| + ${2} + end +snippet eawi + each_with_index { |${1:e}, ${2:i}| ${3} } +snippet eawid + each_with_index do |${1:e},${2:i}| + ${3} + end +snippet reve + reverse_each { |${1:e}| ${2} } +snippet reved + reverse_each do |${1:e}| + ${2} + end +snippet inj + inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } +snippet injd + inject(${1:init}) do |${2:mem}, ${3:var}| + ${4} + end +snippet map + map { |${1:e}| ${2} } +snippet mapd + map do |${1:e}| + ${2} + end +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 cold + collect do |${1:e}| + ${2} + end +snippet det + detect { |${1:e}| ${2} } +snippet detd + detect do |${1:e}| + ${2} + end +snippet fet + fetch(${1:name}) { |${2:key}| ${3} } +snippet fin + find { |${1:e}| ${2} } +snippet find + find do |${1:e}| + ${2} + end +snippet fina + find_all { |${1:e}| ${2} } +snippet finad + find_all do |${1:e}| + ${2} + end +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 scad + scan(${1:/pattern/}) do |${2:match}| + ${3} + end +snippet max + max { |a, b| ${1} } +snippet min + min { |a, b| ${1} } +snippet par + partition { |${1:e}| ${2} } +snippet pard + partition do |${1:e}| + ${2} + end +snippet rej + reject { |${1:e}| ${2} } +snippet rejd + reject do |${1:e}| + ${2} + end +snippet sel + select { |${1:e}| ${2} } +snippet seld + select do |${1:e}| + ${2} + end +snippet lam + lambda { |${1:args}| ${2} } +snippet doo + do + ${1} + end +snippet dov + 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 +# block +snippet b + {|${1:var}| ${2}} +snippet begin + begin + raise 'A test exception.' + rescue Exception => e + puts e.message + puts e.backtrace.inspect + else + # other exception + ensure + # always excute + end + +#migrations +snippet mac + add_column :${1:table_name}, :${2:column_name}, :${3:data_type} +snippet mrc + remove_column :${1:table_name}, :${2:column_name} +snippet mrenc + rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name} +#rspec +snippet it + it "${1:spec_name}" do + ${2} + end +snippet desc + describe ${1:class_name} do + ${2} + end +snippet cont + context "${1:message}" do + ${2} + end +snippet bef + before(:${1:each}) do + ${2} + end +snippet aft + after(:${1:each}) do + ${2} + end + +#debugging +snippet debug + require 'ruby-debug'; debugger; +#views +snippet cfor + <% content_for :${1:head} do %> + ${2} + <% end %> +>>>>>>> d46588cad4f48f1fe6f0e80c06b87f9b78792422 diff --git a/sh.snippets b/sh.snippets new file mode 100644 index 0000000..f035126 --- /dev/null +++ b/sh.snippets @@ -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 + until [[ ${1:condition} ]]; do + ${2:#statements} + done +snippet case + case ${1:word} in + ${2:pattern}) + ${3};; + esac diff --git a/snippet.snippets b/snippet.snippets new file mode 100644 index 0000000..4223fa3 --- /dev/null +++ b/snippet.snippets @@ -0,0 +1,9 @@ +# snippets for making snippets :) +snippet snip + snippet ${1:trigger} + ${2} +snippet msnip + snippet ${1:trigger} ${2:description} + ${3} +snippet v + {VISUAL} diff --git a/tcl.snippets b/tcl.snippets new file mode 100644 index 0000000..1fe1cb9 --- /dev/null +++ b/tcl.snippets @@ -0,0 +1,92 @@ +# #!/usr/bin/env tclsh +snippet #! + #!/usr/bin/env tclsh + +# Process +snippet pro + proc ${1:function_name} {${2:args}} { + ${3:#body ...} + } +#xif +snippet xif + ${1:expr}? ${2:true} : ${3:false} +# 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...} + } elseif {${3}} { + ${4:# elsif...} + } else { + ${5:# else...} + } +# If catch then +snippet ifc + if { [catch {${1:#do something...}} ${2:err}] } { + ${3:# handle failure...} + } +# Catch +snippet catch + catch {${1}} ${2:err} ${3:options} +# While Loop +snippet wh + while {${1}} { + ${2:# body...} + } +# For Loop +snippet for + for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { + ${4:# body...} + } +# Foreach Loop +snippet fore + foreach ${1:x} {${2:#list}} { + ${3:# body...} + } +# after ms script... +snippet af + after ${1:ms} ${2:#do something} +# after cancel id +snippet afc + after cancel ${1:id or script} +# after idle +snippet afi + after idle ${1:script} +# after info id +snippet afin + after info ${1:id} +# Expr +snippet exp + expr {${1:#expression here}} +# Switch +snippet sw + switch ${1:var} { + ${3:pattern 1} { + ${4:#do something} + } + default { + ${2:#do something} + } + } +# Case +snippet ca + ${1:pattern} { + ${2:#do something} + }${3} +# Namespace eval +snippet ns + namespace eval ${1:path} {${2:#script...}} +# Namespace current +snippet nsc + namespace current diff --git a/tex.snippets b/tex.snippets new file mode 100644 index 0000000..4346e38 --- /dev/null +++ b/tex.snippets @@ -0,0 +1,153 @@ +# \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}, &\text{ 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) +#References +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} +#Formating text: italic, bold, underline, small capital, emphase .. +snippet it + \textit{${1:text}} +snippet bf + \textbf{${1:text}} +snippet under + \underline{${1:text}} +snippet emp + \emph{${1:text}} +snippet sc + \textsc{${1:text}} +#Choosing font +snippet sf + \textsf{${1:text}} +snippet rm + \textrm{${1:text}} +snippet tt + \texttt{${1:text}} +#misc +snippet ft + \footnote{${1:text}} +snippet fig + \begin{figure} + \begin{center} + \includegraphics[scale=$1]{Figures/$2} + \end{center} + \caption{$3} + \label{fig:$4} + \end{figure} +#math +snippet frac + \frac{$1}{$2} +snippet sum + $\sum^{${1:n}}_{${2:i=1}}{$3}$ +#cite +snippet cite + \cite{$1} diff --git a/vim.snippets b/vim.snippets new file mode 100644 index 0000000..07603c8 --- /dev/null +++ b/vim.snippets @@ -0,0 +1,34 @@ +snippet header + " File: ${1:`expand('%:t')`} + " Author: ${2:`g:snips_author`} + " Description: ${3} + ${4:" Last Modified: `strftime("%B %d, %Y")`} +snippet guard + if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} + finish + endif + let $1 = 1${3} +snippet f + fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3}) + ${4:" code} + endf +snippet for + for ${1:needle} in ${2:haystack} + ${3:" code} + endfor +snippet wh + while ${1:condition} + ${2:" code} + endw +snippet if + if ${1:condition} + ${2:" code} + endif +snippet ife + if ${1:condition} + ${2} + else + ${3} + endif + + diff --git a/zsh.snippets b/zsh.snippets new file mode 100644 index 0000000..7aee05b --- /dev/null +++ b/zsh.snippets @@ -0,0 +1,58 @@ +# #!/bin/zsh +snippet #! + #!/bin/zsh + +snippet if + if ${1:condition}; then + ${2:# statements} + fi +snippet ife + if ${1:condition}; then + ${2:# statements} + else + ${3:# 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 fore + for ${1:item} in ${2:list}; do + ${3:# statements} + done +snippet wh + while ${1:condition}; do + ${2:# statements} + done +snippet until + until ${1:condition}; do + ${2:# statements} + done +snippet repeat + repeat ${1:integer}; do + ${2:# statements} + done +snippet case + case ${1:word} in + ${2:pattern}) + ${3};; + esac +snippet select + select ${1:answer} in ${2:choices}; do + ${3:# statements} + done +snippet ( + ( ${1:#statements} ) +snippet { + { ${1:#statements} } +snippet [ + [[ ${1:test} ]] +snippet always + { ${1:try} } always { ${2:always} } +snippet fun + function ${1:name} (${2:args}) { + ${3:# body} + }