diff --git a/AUTHORS b/AUTHORS index 30c65d9..1261dc8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ +Aaron Broder Adam Folmert Alberto Pose Angel Alonso @@ -36,3 +37,4 @@ Povilas Balzaravičius Pawka Dmitry Dementev Travis Holton Chrisyue +Erik Westrup diff --git a/README.md b/README.md index f1f8bac..a242eca 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,35 @@ +IMPORTANT: comment on: [What about merging whith Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114) + Snipmate Snippets ================= -This repository contains snippets files for various programming languages for -the famous [snipMate][1] plugin for vim. This repository is -community-maintained and many people have contributed snippet files and other -improvements already. +This repository contains snippets files for various programming languages. + +It was originally written for the the famous [snipMate][1] plugin for vim. +However today there are at least 3 plugins which can make use of this snippet repository: + +1) [snipMate][1] + +2) [Shougo's neosnippet][5] has a compatible mode allowing + to reuse most snippets. + +3) [ultisnip][6] (experimental, mind the branch snipmate-merge) + This code is subject to change. Take it as preview. That branch + has additional notes for Snipmate users. at the bottom. + In the long run ultisnip will have its own set of snippets, because it is + more powerful cause it supports nested snippets. + + + +It is community-maintained and many people have contributed snippet files and other +improvements already. Not sure whether it implements all features such as +guards - does anybody know? [vim-snipmate][1] was originally started by [Michael Sanders][2] who has now unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a [fork][4] of the project in hopes of improving the existing code base. + Language maintainers -------------------- @@ -27,7 +47,8 @@ Contributing notes ------------------ Until further work is done on `vim-snipmate`, please don't add folding markers -into snippets. +into snippets. `vim-snipmate` has some comments about how to patch all snippets +on the fly adding those. Authors ------- @@ -45,3 +66,5 @@ terms of the MIT license. [2]: http://github.com/msanders [3]: http://github.com/garbas [4]: http://github.com/garbas/vim-snipmate +[5]: https://github.com/Shougo/neosnippet +[6]: https://github.com/MarcWeber/UltiSnips/tree/snipmate-merge diff --git a/addon-info.json b/addon-info.json index 1f37bed..303bf28 100644 --- a/addon-info.json +++ b/addon-info.json @@ -4,7 +4,6 @@ "maintainer" : "honza @ github & others", "repository" : {"type": "git", "url": "git://github.com/honza/snipmate-snippets.git"}, "dependencies" : { - "snipmate": {} }, "description" : "community driven set of snippets for snipmate" } diff --git a/snippets/_.snippets b/snippets/_.snippets index 081db1c..d553449 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -216,12 +216,25 @@ snippet APACHE ${3} snippet BEERWARE - ${1:one line to give the program's name and a brief description} - Copyright `strftime("%Y")` ${2:copyright holder} + ${2:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${3:copyright holder} Licensed under the "THE BEER-WARE LICENSE" (Revision 42): ${1:`g:snips_author`} wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer or coffee in return - ${3} + ${4} + +snippet WTFPL + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright `strftime("%Y")` ${1:copyright holder} + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION diff --git a/snippets/actionscript.snippets b/snippets/actionscript.snippets index 999b8a3..af9611c 100644 --- a/snippets/actionscript.snippets +++ b/snippets/actionscript.snippets @@ -107,7 +107,7 @@ snippet try ${3} } # For Loop (same as c.snippet) -snippet for +snippet for for (..) {..} for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} } diff --git a/snippets/c.snippets b/snippets/c.snippets index 38e8d9e..c476de4 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -1,38 +1,45 @@ -# main() +## Main +# main snippet main int main(int argc, const char *argv[]) { ${1} return 0; } +# main(void) snippet mainn int main(void) { ${1} return 0; } +## +## Preprocessor # #include <...> snippet inc #include <${1:stdio}.h>${2} # #include "..." snippet Inc #include "${1:`Filename("$1.h")`}"${2} -# #ifndef ... #define ... #endif -snippet Def +# ifndef...define...endif +snippet ndef #ifndef $1 #define ${1:SYMBOL} ${2:value} #endif${3} +# define snippet def #define +# ifdef...endif snippet ifdef #ifdef ${1:FOO} ${2:#define } - #endif + #endif${3} +# if snippet #if #if ${1:FOO} ${2} #endif -# Header Include-Guard +# header include guard snippet once #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} @@ -41,73 +48,167 @@ snippet once ${2} #endif /* end of include guard: $1 */ -# If Condition +## +## Control Statements +# if snippet if if (${1:/* condition */}) { ${2:/* code */} - } + }${3} +# else snippet el else { ${1} - } -# Ternary conditional + }${3} +# else if +snippet elif + else if (${1:/* condition */}) { + ${2:/* code */} + }${3} +# ternary 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 +# switch +snippet switch + switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + default: + ${6} + }${7} +# switch without default +snippet switchndef + switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + }${6} +# case +snippet case + case ${1:/* variable case */}: + ${2} + ${3:break;}${4} +## +## Loops +# for snippet for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} - } -# Custom For Loop + }${5} +# for (custom) snippet forr for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { ${5:/* code */} - } -# Function + }${6} +# while +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + }${3} +# do... while +snippet do + do { + ${2:/* code */} + } while (${1:/* condition */});${3} +## +## Functions +# function definition snippet fun ${1:void} ${2:function_name}(${3}) { ${4:/* code */} - } -# Function Declaration + }${5} +# function declaration snippet fund ${1:void} ${2:function_name}(${3});${4} -# Typedef +## +## Types +# typedef snippet td typedef ${1:int} ${2:MyCustomType};${3} -# Struct +# struct snippet st struct ${1:`Filename('$1_t', 'name')`} { ${2:/* data */} }${3: /* optional variable list */};${4} -# Typedef struct +# typedef struct snippet tds typedef struct ${2:_$1 }{ ${3:/* data */} - } ${1:`Filename('$1_t', 'name')`}; -# Typdef enum + } ${1:`Filename('$1_t', 'name')`};${4} +# typedef enum snippet tde typedef enum { ${1:/* data */} - } ${2:foo}; + } ${2:foo};${3} +## +## Input/Output # 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} +# getopt +snippet getopt + int choice; + while (1) + { + static struct option long_options[] = + { + /* Use flags like so: + {"verbose", no_argument, &verbose_flag, 'V'}*/ + /* Argument styles: no_argument, required_argument, optional_argument */ + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + ${1} + {0,0,0,0} + }; + + int option_index = 0; + + /* Argument parameters: + no_argument: " " + required_argument: ":" + optional_argument: "::" */ + + choice = getopt_long( argc, argv, "vh", + long_options, &option_index); + + if (choice == -1) + break; + + switch( choice ) + { + case 'v': + ${2} + break; + + case 'h': + ${3} + break; + + case '?': + /* getopt_long will have already printed an error */ + break; + + default: + /* Not sure how to get here... */ + return EXIT_FAILURE; + } + } + + /* Deal with non-option arguments here */ + if ( optind < argc ) + { + while ( optind < argc ) + { + ${4} + } + } +## +## Miscellaneous # This is kind of convenient snippet . [${1}]${2} diff --git a/snippets/coffee.snippets b/snippets/coffee.snippets index dfe3658..83b77eb 100644 --- a/snippets/coffee.snippets +++ b/snippets/coffee.snippets @@ -1,3 +1,8 @@ +# Closure loop +snippet forindo + for ${1:name} in ${2:array} + do ($1) -> + ${3:// body} # Array comprehension snippet fora for ${1:name} in ${2:array} @@ -85,3 +90,6 @@ snippet try # Require snippet req ${2:$1} = require '${1:sys}'${3} +# Export +snippet exp + ${1:root} = exports ? this diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index c177a15..c3e19fe 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,29 +1,73 @@ -# 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}; - +## STL Collections +# std::array +snippet array + std::array<${1:T}, ${2:N}> ${3};${4} # std::vector snippet vector - std::vector<${1:char}> ${2}; - -# Namespace -snippet ns - namespace ${1:`Filename('', 'my')`} { - ${2} - } /* namespace $1 */ - -# Class -snippet class + std::vector<${1:T}> ${2};${3} +# std::deque +snippet deque + std::deque<${1:T}> ${2};${3} +# std::forward_list +snippet flist + std::forward_list<${1:T}> ${2};${3} +# std::list +snippet list + std::list<${1:T}> ${2};${3} +# std::set +snippet set + std::set<${1:T}> ${2};${3} +# std::map +snippet map + std::map<${1:Key}, ${2:T}> ${3};${4} +# std::multiset +snippet mset + std::multiset<${1:T}> ${2};${3} +# std::multimap +snippet mmap + std::multimap<${1:Key}, ${2:T}> ${3};${4} +# std::unordered_set +snippet uset + std::unordered_set<${1:T}> ${2};${3} +# std::unordered_map +snippet umap + std::unordered_map<${1:Key}, ${2:T}> ${3};${4} +# std::unordered_multiset +snippet umset + std::unordered_multiset<${1:T}> ${2};${3} +# std::unordered_multimap +snippet ummap + std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4} +# std::stack +snippet stack + std::stack<${1:T}> ${2};${3} +# std::queue +snippet queue + std::queue<${1:T}> ${2};${3} +# std::priority_queue +snippet pqueue + std::priority_queue<${1:T}> ${2};${3} +## +## Access Modifiers +# private +snippet pri + private +# protected +snippet pro + protected +# public +snippet pub + public +# friend +snippet fr + friend +# mutable +snippet mu + mutable +## +## Class +# class +snippet cl class ${1:`Filename('$1', 'name')`} { public: @@ -33,34 +77,55 @@ snippet class private: ${3:/* data */} }; - +# member function implementation +snippet mfun + ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { + ${5:/* code */} + } +# namespace +snippet ns + namespace ${1:`Filename('', 'my')`} { + ${2} + } /* namespace $1 */ +## +## Input/Output +# std::cout +snippet cout + std::cout << ${1} << std::endl;${2} +# std::cin +snippet cin + std::cin >> ${1};${2} +## +## Iteration +# for i snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} - } + }${5} + +# foreach +snippet fore + for (${1:auto} ${2:i} : ${3:container}) { + ${4:/* code */} + }${5} +# iterator +snippet iter + for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) { + ${6} + }${7} # 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}; - } -snippet scout - std::cout << ${1} << std::endl; -snippet cout - cout << ${1} << endl; -snippet scin - std::cin >> ${1}; -snippet cin - cin >> ${1}; + }${3} +## +## Lambdas +# lamda (one line) +snippet ld + [${1}](${2}){${3:/* code */}}${4} +# lambda (multi-line) +snippet lld + [${1}](${2}){ + ${3:/* code */} + }${4} diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index be1c7ec..f96ca84 100644 --- a/snippets/eruby.snippets +++ b/snippets/eruby.snippets @@ -81,10 +81,6 @@ snippet fields <% fields_for :${1:model}, @$1 do |${2:f}| %> ${3} <% end %> -snippet ff - <%= form_for @${1:model} do |f| %> - ${2} - <% end %> snippet i18 I18n.t('${1:type.key}')${2} snippet it diff --git a/snippets/html.snippets b/snippets/html.snippets index be8b0f6..0f75efd 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -353,11 +353,11 @@ snippet footer ${1} snippet footer. - snippet footer# - snippet form @@ -445,6 +445,18 @@ snippet xhtml ${1} +snippet html5 + + + + + ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} + ${2:meta} + + + ${3:body} + + snippet i ${1} snippet iframe diff --git a/snippets/java.snippets b/snippets/java.snippets index fb27b9c..854f14a 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -140,7 +140,7 @@ snippet /** * ${1} */ snippet @au - @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")` + @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5 | cut -d \",\" -f1")` snippet @br @brief ${1:Description} snippet @fi @@ -176,9 +176,9 @@ snippet main ## ## Print Methods snippet print - System.out.print("${1:Message"); + System.out.print("${1:Message}"); snippet printf - System.out.printf("${1:Message", ${2:args}); + System.out.printf("${1:Message}", ${2:args}); snippet println System.out.println(${1}); ## diff --git a/snippets/javascript.snippets b/snippets/javascript.snippets index de50a0c..fc845fa 100644 --- a/snippets/javascript.snippets +++ b/snippets/javascript.snippets @@ -11,12 +11,12 @@ snippet fun } # Anonymous Function snippet f - function(${1}) { + function (${1}) { ${3} }${2:;} # Immediate function snippet (f - (function(${1}) { + (function (${1}) { ${3:/* code */} }(${2})); # if @@ -32,11 +32,11 @@ snippet ife ${3} } # tertiary conditional -snippet t +snippet ter ${1:/* condition */} ? ${2:a} : ${3:b} # switch snippet switch - switch(${1:expression}) { + switch (${1:expression}) { case '${3:case}': ${4:// code} break; @@ -69,7 +69,7 @@ snippet wh snippet try try { ${1:/* code */} - } catch(${2:e}) { + } catch (${2:e}) { ${3:/* handle error */} } # do...while @@ -79,12 +79,12 @@ snippet do } while (${1:/* condition */}); # Object Method snippet :f - ${1:method_name}: function(${2:attribute}) { + ${1:method_name}: function (${2:attribute}) { ${4} }${3:,} # setTimeout function snippet timeout - setTimeout(function() {${3}}${2}, ${1:10}); + setTimeout(function () {${3}}${2}, ${1:10}); # Get Elements snippet get getElementsBy${1:TagName}('${2}')${3} diff --git a/snippets/ledger.snippets b/snippets/ledger.snippets new file mode 100644 index 0000000..293d4b6 --- /dev/null +++ b/snippets/ledger.snippets @@ -0,0 +1,5 @@ +# Ledger +snippet ent + `strftime("%Y/%m/%d")` ${1:transaction} + ${2:account} ${3:value} + ${4:account} diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 4ba985d..9cebede 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -79,48 +79,54 @@ snippet for snippet fore ${1:expression} foreach @${2:array};${3} # Package -snippet cl - package ${1:ClassName}; +snippet package + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; - use base qw(${2:ParentClass}); + ${2} - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } + 1; - 1;${3} + __END__ +# Package syntax perl >= 5.14 +snippet packagev514 + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; + + ${3} + + 1; + + __END__ +#moose +snippet moose + use Moose; + use namespace::autoclean; + ${1:#}BEGIN {extends '${2:ParentClass}'}; + + ${3} +# parent +snippet parent + use parent qw(${1:Parent Class}); # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; ${3} - - # strict warnings snippet strwar use strict; use warnings; - - -# standard versioning with perlcritic bypass +# older versioning with perlcritic bypass snippet vers ## no critic our $VERSION = '${1:version}'; eval $VERSION; ## use critic - - # new 'switch' like feature snippet switch use feature 'switch'; - - # Anonymous subroutine snippet asub - sub { + sub { ${1:# body } } @@ -133,19 +139,19 @@ snippet begin } # call package function with some parameter -snippet pkgmv +snippet pkgmv __PACKAGE__->${1:package_method}(${2:var}) # call package function without a parameter -snippet pkgm +snippet pkgm __PACKAGE__->${1:package_method}() # call package "get_" function without a parameter -snippet pkget +snippet pkget __PACKAGE__->get_${1:package_method}() # call package function with a parameter -snippet pkgetv +snippet pkgetv __PACKAGE__->get_${1:package_method}(${2:var}) # complex regex @@ -160,10 +166,10 @@ snippet qr/ #given snippet given - given ($${1:var}) { + given ($${1:var}) { ${2:# cases} ${3:# default} - } + } # switch-like case snippet when @@ -176,7 +182,6 @@ snippet hslice @{ ${1:hash} }{ ${2:array} } - # map snippet map map { ${2: body } } ${1: @array } ; @@ -190,7 +195,7 @@ snippet ppod ${1:ClassName} - ${2:ShortDesc} =head1 SYNOPSIS - + use $1; ${3:# synopsis...} @@ -202,7 +207,7 @@ snippet ppod =head1 INTERFACE - + =head1 DEPENDENCIES @@ -223,8 +228,17 @@ snippet psubi =cut +# inline documented subroutine +snippet subpod + =head2 $1 + Summary of $1 + =cut + + sub ${1:subroutine_name} { + ${2:# body...} + } # Subroutine signature snippet parg =over 2 @@ -232,7 +246,7 @@ snippet parg =item Arguments - + =over 3 =item @@ -255,47 +269,21 @@ snippet parg =back - =back -# Moose package -snippet moosecl - package ${1:ClassName}; - - use Moose; - #extends '${2:# ParentClass}'; - - ${6:# body of class} - - 1; - - - __END__ - - =head1 NAME - - $1 - ${3:ShortDesc} - - =head1 SYNOPSIS - - ${4:# synopsis...} - - =head1 DESCRIPTION - - ${5:# longer description...} - - # Moose has snippet has has ${1:attribute} => ( - is => '${2:ro|rw}', + is => '${2:ro|rw}', isa => '${3:Str|Int|HashRef|ArrayRef|etc}', - default => ${4:defaultvalue} - ,${5:# other attributes} + default => sub { + ${4:defaultvalue} + }, + ${5:# other attributes} ); @@ -303,14 +291,14 @@ snippet has snippet override override ${1:attribute} => sub { ${2:# my $self = shift;}; - ${3:# my ($self,$args) = @_;}; + ${3:# my ($self, $args) = @_;}; }; # use test classes snippet tuse use Test::More; - use Test::Deep (); + use Test::Deep; # (); # uncomment to stop prototype errors use Test::Exception; # local test lib @@ -331,7 +319,7 @@ snippet tsub sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) { my $self = shift; ${4:# body} - + } # Test::Routine-style test @@ -347,6 +335,7 @@ snippet tprep my $self = shift; ${4:# body} } + # cause failures to print stack trace snippet debug_trace use Carp; # 'verbose'; diff --git a/snippets/plsql.snippets b/snippets/plsql.snippets new file mode 100644 index 0000000..dba25ee --- /dev/null +++ b/snippets/plsql.snippets @@ -0,0 +1,109 @@ +# create package spec +snippet ps + create or replace package ${1:name} + as + ${2:-- spec} + end; -- end of package spec $1 +# create package body +snippet pb + create or replace package body ${1:name} + as + ${2:-- body} + end; -- end of package body $1; +# package procedure spec +snippet pps + procedure ${1:name}(${2:args}); +# package procedure body +snippet ppb + procedure ${1:name}(${2:args}) + as + begin + ${3:-- body} + end $2; +# package function spec +snippet pfs + function ${1:name}(${2:args}) + return ${3:type}; +# package function body +snippet pfb + function ${1:name}(${2:args}) + return ${3:type} + as + l_res $3; + begin + ${4:-- body}; + return l_res; + end $1; +# snow errors +snippet err + show errors; +# proc/func in parameter +snippet p + ${1:name} ${2:in} ${3:type} ${4: := null} +# package type: record +snippet tr + type tr_${1:name} is record (${2:/* columns */}); +# package type: nested table +snippet tt + type tt_${1:name} is table of tr_${2:name}; +# package type: indexed table +snippet tti + type tt_${1:name} is table of tr_${2:name} index by binary_integer; +# proc/func comment +snippet doc + /* + * ${1: comment ...} + */ +# plsql block +snippet beg + begin + ${1} + end; +# plsql block with declare part +snippet dec + declare + ${1} + begin + ${2} + end; +# return pipe row +snippet rpipe + for ${1:i} in 1 .. ${2:l_res}.count loop + pipe row( $2($1) ); + end loop; + return; +# bulk collect +snippet bc + bulk collect into ${1} +# local variable +snippet l + l_${1} ${2:number}; +# output +snippet log + dbms_output.put_line('${1}'); +# for loop +snippet for + for ${1:i} in ${2:1}..${3:42} loop + ${3} + end loop; +# for loop with select +snippet fors + for ${1:rec} in (${2: select}) loop + ${3} + end loop; +# for loop with collection +snippet forc + for ${1:i} in ${2:l_var}.first .. $2.last loop + ${3: -- dbms_output.put_line($2($1)); } + end loop; +# if +snippet if + if ${1} then + ${2} + end if; +snippet ife + if ${1} then + ${2} + else + ${3} + end if; diff --git a/snippets/python.snippets b/snippets/python.snippets index b3b1e9b..dd2e812 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -13,16 +13,16 @@ snippet docs ''' snippet wh while ${1:condition}: - ${2:# code...} + ${2:# TODO: write code...} # dowh - does the same as do...while in other languages snippet dowh while True: - ${1:# code...} + ${1:# TODO: write code...} if ${2:condition}: break snippet with with ${1:expr} as ${2:var}: - ${3:# code...} + ${3:# TODO: write code...} # New Class snippet cl class ${1:ClassName}(${2:object}): @@ -35,14 +35,14 @@ snippet cl snippet def def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): """${3:docstring for $1}""" - ${4:pass} + ${4:# TODO: write code...} snippet deff def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - ${3} + ${3:# TODO: write code...} # New Method snippet defs def ${1:mname}(self, ${2:arg}): - ${3:pass} + ${3:# TODO: write code...} # New Property snippet property def ${1:foo}(): @@ -54,17 +54,17 @@ snippet property # Ifs snippet if if ${1:condition}: - ${2:code...} + ${2:# TODO: write code...} snippet el else: - ${1:code...} + ${1:# TODO: write code...} snippet ei elif ${1:condition}: - ${2:code...} + ${2:# TODO: write code...} # For snippet for for ${1:item} in ${2:items}: - ${3:code...} + ${3:# TODO: write code...} # Encodes snippet cutf8 # -*- coding: utf-8 -*- @@ -79,32 +79,32 @@ snippet . self. snippet try Try/Except try: - ${1:pass} + ${1:# TODO: write code...} except ${2:Exception}, ${3:e}: ${4:raise $3} snippet try Try/Except/Else try: - ${1:pass} + ${1:# TODO: write code...} except ${2:Exception}, ${3:e}: ${4:raise $3} else: - ${5:pass} + ${5:# TODO: write code...} snippet try Try/Except/Finally try: - ${1:pass} + ${1:# TODO: write code...} except ${2:Exception}, ${3:e}: ${4:raise $3} finally: - ${5:pass} + ${5:# TODO: write code...} snippet try Try/Except/Else/Finally try: - ${1:pass} + ${1:# TODO: write code...} except ${2:Exception}, ${3:e}: ${4:raise $3} else: - ${5:pass} + ${5:# TODO: write code...} finally: - ${6:pass} + ${6:# TODO: write code...} # if __name__ == '__main__': snippet ifmain if __name__ == '__main__': @@ -130,12 +130,29 @@ snippet " # test function/method snippet test def test_${1:description}(${2:`indent('.') ? 'self' : ''`}): - ${3:pass} + ${3:# TODO: write code...} # test case snippet testcase class ${1:ExampleCase}(unittest.TestCase): def test_${2:description}(self): - ${3:pass} + ${3:# TODO: write code...} snippet fut from __future__ import ${1} +#getopt +snippet getopt + try: + # Short option syntax: "hv:" + # Long option syntax: "help" or "verbose=" + opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}]) + + except getopt.GetoptError, err: + # Print debug info + print str(err) + ${3:error_action} + + for option, argument in opts: + if option in ("-h", "--help"): + ${4} + elif option in ("-v", "--verbose"): + verbose = argument diff --git a/snippets/r.snippets b/snippets/r.snippets new file mode 100644 index 0000000..909e70d --- /dev/null +++ b/snippets/r.snippets @@ -0,0 +1,95 @@ +snippet #! + #!/usr/bin/env Rscript + +# includes +snippet lib + library(${1:package}) +snippet req + require(${1:package}) +snippet source + source('${1:file}') + +# conditionals +snippet if + if (${1:condition}) { + ${2:code} + } +snippet el + else { + ${1:code} + } +snippet ei + else if (${1:condition}) { + ${2:code} + } + +# functions +snippet fun + ${1:name} = function (${2:variables}) { + ${3:code} + } +snippet ret + return(${1:code}) + +# dataframes, lists, etc +snippet df + ${1:name}[${2:rows}, ${3:cols}] +snippet c + c(${1:items}) +snippet li + list(${1:items}) +snippet mat + matrix(${1:data}, nrow=${2:rows}, ncol=${3:cols}) + +# apply functions +snippet apply + apply(${1:array}, ${2:margin}, ${3:function}) +snippet lapply + lapply(${1:list}, ${2:function}) +snippet sapply + lapply(${1:list}, ${2:function}) +snippet vapply + vapply(${1:list}, ${2:function}, ${3:type}) +snippet mapply + mapply(${1:function}, ${2:...}) +snippet tapply + tapply(${1:vector}, ${2:index}, ${3:function}) +snippet rapply + rapply(${1:list}, ${2:function}) + +# plyr functions +snippet dd + ddply(${1:frame}, ${2:variables}, ${3:function}) +snippet dl + dlply(${1:frame}, ${2:variables}, ${3:function}) +snippet da + daply(${1:frame}, ${2:variables}, ${3:function}) +snippet d_ + d_ply(${1:frame}, ${2:variables}, ${3:function}) + +snippet ad + adply(${1:array}, ${2:margin}, ${3:function}) +snippet al + alply(${1:array}, ${2:margin}, ${3:function}) +snippet aa + aaply(${1:array}, ${2:margin}, ${3:function}) +snippet a_ + a_ply(${1:array}, ${2:margin}, ${3:function}) + +snippet ld + ldply(${1:list}, ${2:function}) +snippet ll + llply(${1:list}, ${2:function}) +snippet la + laply(${1:list}, ${2:function}) +snippet l_ + l_ply(${1:list}, ${2:function}) + +snippet md + mdply(${1:matrix}, ${2:function}) +snippet ml + mlply(${1:matrix}, ${2:function}) +snippet ma + maply(${1:matrix}, ${2:function}) +snippet m_ + m_ply(${1:matrix}, ${2:function}) diff --git a/snippets/rst.snippets b/snippets/rst.snippets index d31a13f..97845de 100644 --- a/snippets/rst.snippets +++ b/snippets/rst.snippets @@ -1,14 +1,14 @@ # rst snippet : - :${1:Text}: ${2:blah blah} + :${1:field name}: ${2:field body} snippet * *${1:Emphasis}* snippet ** **${1:Strong emphasis}** snippet _ - \`${1:Text}\`_ - .. _\`$1\`: ${2:blah blah} + \`${1:hyperlink-name}\`_ + .. _\`$1\`: ${2:link-block} snippet = ${1:Title} =====${2:=} diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 26bdfa5..0500aaa 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -2,6 +2,10 @@ # Ruby snippets - for Rails, see below # ######################################## +# encoding for Ruby 1.9 +snippet enc + # encoding: utf-8 + # #!/usr/bin/env ruby snippet #! #!/usr/bin/env ruby @@ -22,7 +26,7 @@ snippet beg rescue ${1:Exception} => ${2:e} end -snippet req +snippet req require require "${1}"${2} snippet # # => @@ -390,7 +394,7 @@ snippet : snippet ope open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } # path_from_here() -snippet patfh +snippet fpath File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} # unix_filter {} snippet unif @@ -571,7 +575,7 @@ snippet asre assert_response :${1:success}, @response.body${2} snippet asrj assert_rjs :${1:replace}, "${2:dom id}" -snippet ass +snippet ass assert_select(..) assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do} snippet bf before_filter :${1:method} @@ -865,7 +869,6 @@ snippet test test "should ${1:do something}" do ${2} end - #migrations snippet mac add_column :${1:table_name}, :${2:column_name}, :${3:data_type} diff --git a/snippets/sh.snippets b/snippets/sh.snippets index 508056c..9a48eb5 100644 --- a/snippets/sh.snippets +++ b/snippets/sh.snippets @@ -41,3 +41,43 @@ snippet go # Set SCRIPT_DIR variable to directory script is located. snippet sdir SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# getopt +snippet getopt + __ScriptVersion="${1:version}" + + #=== FUNCTION ================================================================ + # NAME: usage + # DESCRIPTION: Display usage information. + #=============================================================================== + function usage () + { + cat <<- EOT + + Usage : $${0:0} [options] [--] + + Options: + -h|help Display this message + -v|version Display script version + + EOT + } # ---------- end of function usage ---------- + + #----------------------------------------------------------------------- + # Handle command line arguments + #----------------------------------------------------------------------- + + while getopts ":hv" opt + do + case $opt in + + h|help ) usage; exit 0 ;; + + v|version ) echo "$${0:0} -- Version $__ScriptVersion"; exit 0 ;; + + \? ) echo -e "\n Option does not exist : $OPTARG\n" + usage; exit 1 ;; + + esac # --- end of case --- + done + shift $(($OPTIND-1)) + diff --git a/snippets/sql.snippets b/snippets/sql.snippets new file mode 100644 index 0000000..eb4b37c --- /dev/null +++ b/snippets/sql.snippets @@ -0,0 +1,26 @@ +snippet tbl + create table ${1:table} ( + ${2:columns} + ); +snippet col + ${1:name} ${2:type} ${3:default ''} ${4:not null} +snippet ccol + ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null} +snippet ncol + ${1:name} number ${3:default 0} ${4:not null} +snippet dcol + ${1:name} date ${3:default sysdate} ${4:not null} +snippet ind + create index ${3:$1_$2} on ${1:table}(${2:column}); +snippet uind + create unique index ${1:name} on ${2:table}(${3:column}); +snippet tblcom + comment on table ${1:table} is '${2:comment}'; +snippet colcom + comment on column ${1:table}.${2:column} is '${3:comment}'; +snippet addcol + alter table ${1:table} add (${2:column} ${3:type}); +snippet seq + create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1}; +snippet s* + select * from ${1:table} diff --git a/snippets/tex.snippets b/snippets/tex.snippets index 511a4c9..10fa82e 100644 --- a/snippets/tex.snippets +++ b/snippets/tex.snippets @@ -1,5 +1,3 @@ -# recomendation: change the fold marker from {{{,}}} to (fold),(end) ; tex uses "{" and "}" a lot - #PREAMBLE #newcommand snippet nc @@ -97,40 +95,34 @@ snippet part % part $2 (end) # Chapter snippet cha - \chapter{${1:chapter name}} % (fold) + \chapter{${1:chapter name}} \label{cha:${2:$1}} ${3} - % chapter $2 (end) # Section snippet sec - \section{${1:section name}} % (fold) + \section{${1:section name}} \label{sec:${2:$1}} ${3} - % section $2 (end) # Sub Section snippet sub - \subsection{${1:subsection name}} % (fold) + \subsection{${1:subsection name}} \label{sub:${2:$1}} ${3} - % subsection $2 (end) # Sub Sub Section snippet subs - \subsubsection{${1:subsubsection name}} % (fold) + \subsubsection{${1:subsubsection name}} \label{ssub:${2:$1}} ${3} - % subsubsection $2 (end) # Paragraph snippet par - \paragraph{${1:paragraph name}} % (fold) + \paragraph{${1:paragraph name}} \label{par:${2:$1}} ${3} - % paragraph $2 (end) # Sub Paragraph snippet subp - \subparagraph{${1:subparagraph name}} % (fold) + \subparagraph{${1:subparagraph name}} \label{subp:${2:$1}} ${3} - % subparagraph $2 (end) #References snippet itd \item[${1:description}] ${2:item} @@ -146,9 +138,11 @@ snippet page ${1:page}~\pageref{${2}}${3} snippet index \index{${1:index}}${2} -#cite +#Citations snippet cite - \cite{${1}}${2} + \cite[${1}]{${2}}${3} +snippet fcite + \footcite[${1}]{${2}}${3} #Formating text: italic, bold, underline, small capital, emphase .. snippet it \textit{${1:text}} diff --git a/snippets/xslt.snippets b/snippets/xslt.snippets new file mode 100644 index 0000000..e7abdf3 --- /dev/null +++ b/snippets/xslt.snippets @@ -0,0 +1,97 @@ +snippet apply-templates with-param + + ${3}${4} + ${5} + +snippet apply-templates sort-by + + ${5} + ${6} + +snippet apply-templates plain + ${2} + +snippet attribute blank + ${2}${3} + +snippet attribute value-of + + + ${3} + +snippet call-template + + +snippet call-template with-param + + ${3}${4} + ${5} + +snippet choose + + + ${2} + ${3} + + +snippet copy-of + ${2} + +snippet for-each + ${2} + ${3} + +snippet if + ${2} + ${3} + +snippet import + ${2} + +snippet include + ${2} + +snippet otherwise + ${1} + + +snippet param + ${2} + ${3} + +snippet stylesheet + ${1} + + +snippet template + ${3} + + +snippet template named + ${2} + + +snippet text + ${1} + +snippet value-of + ${2} + +snippet variable blank + ${2} + + +snippet variable select + ${2} + +snippet when + ${2} + + +snippet with-param + ${2} + +snippet with-param select + + diff --git a/snippets/yii-chtml.snippets b/snippets/yii-chtml.snippets new file mode 100644 index 0000000..91c65b9 --- /dev/null +++ b/snippets/yii-chtml.snippets @@ -0,0 +1,248 @@ +#--------------------Yii CHtml--------------------------------- +#Yii CHtml::radioButton +snippet yhrb + echo CHtml::radioButton('${1:name}', ${2:false},array(${3:optionName}=>${4:optionValue} ); + +#Yii CHtml::asset +snippet yhass + echo CHtml::asset('${1:path}'); + +#Yii CHtml::activeLabelEx +snippet yhale + echo CHtml::activeLabelEx(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::encodeArray +snippet yheca + echo CHtml::encodeArray(array(${1})); + +#Yii CHtml::normalizeUrl +snippet yhnurl + echo CHtml::normalizeUrl(array('${1}')); + +#Yii CHtml::resetButton +snippet yhsb + echo CHtml::submitButton('${1:label}',array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::linkButton +snippet yhlinkb + echo CHtml::linkButton('${1:lable}',array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::activeTextArea +snippet yhata + echo CHtml::activeTextArea(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::ajaxButton +snippet yhajb + echo CHtml::ajaxButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); + +#Yii CHtml::activeId +snippet yhai + echo CHtml::activeId(${1:model}, '${2:attribute}'); + +#Yii CHtml::activeCheckBox +snippet yhacb + echo CHtml::activeCheckBox(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeHiddenField +snippet yhahf + echo CHtml::activeHiddenField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::encode +snippet yhec + echo CHtml::encode(${1:text}); + +#Yii CHtml::metaTag +snippet yhmtag + echo CHtml::metaTag('${1:content}', '${2:name}', '${3:httpEquiv}',array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::dropDownList +snippet yhddl + echo CHtml::dropDownList('${1:name}', '${2:select}', array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::listBox +snippet yhlb + echo CHtml::listBox('${1:name}', '${2:select}',array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::script +snippet yhjs + echo CHtml::script('${1:test}'); + +#Yii CHtml::ajax +snippet yhaj + echo CHtml::ajax(array(${1})); + +#Yii CHtml::textField +snippet yhtf + echo CHtml::textField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activePasswordField +snippet yhapf + echo CHtml::activePasswordField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::listData +snippet yhld + echo CHtml::listData(array(${1}),'${2:valueField}', '${3:textField}','${4:groupField}'); + +#Yii CHtml::mailto +snippet yhmt + echo CHtml::mailto('${1:text}', '${2:email}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::image +snippet yhimg + echo CHtml::image('${1:src}', '${2:alt}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeListBox +snippet yhalb + echo CHtml::activeListBox(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::activeFileField +snippet yhaff + echo CHtml::activeFileField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::closeTag +snippet yhct + echo CHtml::closeTag('${1:tag}'); + +#Yii CHtml::activeInputField +snippet yhaif + echo CHtml::activeInputField('${1:type}', ${2:model}, '${3:attribute}',array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::scriptFile +snippet yhjsf + echo CHtml::scriptFile('${1:url}'); + +#Yii CHtml::radioButtonList +snippet yhrbl + echo CHtml::radioButtonList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::cssFile +snippet yhcssf + echo CHtml::cssFile('${1:url}','${2:media}'); + +#Yii CHtml::error +snippet yherr + echo CHtml::error(${1:model}, '${2:attribute}'); + +#Yii CHtml::passwordField +snippet yhpf + echo CHtml::passwordField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::hiddenField +snippet yhhf + echo CHtml::hiddenField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::cdata +snippet yhc + echo CHtml::cdata(${1:text}); + +#Yii CHtml::link +snippet yhlink + echo CHtml::link('${1:text}',array(${2}),array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::errorSummary +snippet yherrs + echo CHtml::errorSummary(${1:model},'${2:headerHtml}','${3:footerHtml}'); + +#Yii CHtml::tag +snippet yht + echo CHtml::tag('${1:tag}',array('${2:optionName}'=>${3:optionValue}),${4:false},${5:true}); + +#Yii CHtml::ajaxLink +snippet yhajl + echo CHtml::ajaxLink('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); + +#Yii CHtml::label +snippet yhlabel + echo CHtml::label('${1:label}', '${2:for}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeName +snippet yhan + echo CHtml::activeName(${1:model}, '${2:attribute}'); + +#Yii CHtml::statefulForm +snippet yhsform + echo CHtml::statefulForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::fileField +snippet yhff + echo CHtml::fileField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeTextField +snippet yhatf + echo CHtml::activeTextField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::css +snippet yhcss + echo CHtml::css('${1:test}','${2:media}'); + +#Yii CHtml::imageButton +snippet yhimgb + echo CHtml::imageButton('${1:src}',array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::ajaxSubmitButton +snippet yhajsb + echo CHtml::ajaxSubmitButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue})); + +#Yii CHtml::button +snippet yhb + echo CHtml::button('${1:label}',array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::listOptions +snippet yhlo + echo CHtml::listOptions('${1:selection}', array(${2}), array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeCheckBoxList +snippet yhacbl + echo CHtml::activeCheckBoxList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::openTag +snippet yhot + echo CHtml::openTag('${1:tag}', array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::checkBox +snippet yhcb + echo CHtml::checkBox('${1:name}', ${2:false}, array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::textArea +snippet yhta + echo CHtml::textArea('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::linkTag +snippet yhlinkt + echo CHtml::linkTag('${1:relation}', '${2:type}', '${3:href}', '${4:media}',array('${5:optionName}'=>${6:optionValue})); + +#Yii CHtml::resetButton +snippet yhrsb + echo CHtml::resetButton('${1:label}',array('${2:optionName}'=>${3:optionValue})); + +#Yii CHtml::activeRadioButtonList +snippet yharbl + echo CHtml::activeRadioButtonList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::checkBoxList +snippet yhcbl + echo CHtml::checkBoxList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::form +snippet yhform + echo CHtml::form(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::beginForm +snippet yhbeform + echo CHtml::beginForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue})); + ${5} + echo CHtml::endForm(); + +#Yii CHtml::activeDropDownList +snippet yhaddl + echo CHtml::activeDropDownList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue})); + +#Yii CHtml::activeRadioButton +snippet yharb + echo CHtml::activeRadioButton(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + +#Yii CHtml::activeLabel +snippet yhal + echo CHtml::activeLabel(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue})); + + diff --git a/snippets/yii.snippets b/snippets/yii.snippets new file mode 100644 index 0000000..9f29eaf --- /dev/null +++ b/snippets/yii.snippets @@ -0,0 +1,300 @@ +#Yii session offset +snippet yse + Yii::app()->session['${1}']; + +#Yii renderDynamic +snippet yrd + $this->renderDynamic('${1:callback}'); + +#Yii set cache +snippet ycas + Yii::app()->cache->set('${1:key}', ${2:value}, ${3:expire}, new C${4:}CacheDependency(${5})); + +#Yii Add cache +snippet ycad + Yii::app()->cache->add('${1:key}', ${2:value}, ${3:expire}, new C${4}CacheDependency(${5})); + +#Yii register CSS file +snippet yregcf + Yii::app()->clientScript->registerCssFile('${1:file}'); + +#Yii requestType +snippet yreqtype + Yii::app()->request->requestType + +#Yii isAjaxRequest +snippet yisajax + Yii::app()->request->isAjaxRequest + +#Yii translate +snippet yt + Yii::t('${1:category}', '${2:message}',array(${3})); + +#Yii register CSS +snippet yregc + Yii::app()->clientScript->registerCss('${1:id}', '${2}'); + +#Yii log +snippet ylog + Yii::log('${1:msg}', '${2:info}'); + +#Yii userHostAddress +snippet yuserip + YYii::app()->request->userHostAddress + +#Yii register script file +snippet yregsf + Yii::app()->clientScript->registerScriptFile('${1:scriptUrl}', CClientScript::POS_${2:END}); + +#Yii CLinkPager +snippet ylinkpager + $this->widget('CLinkPager', array('pages'=>$pages,'header'=>'${1}'})) + +#Yii CJSON::encode +snippet yjec + CJSON::encode(${1:text}); + +#CActiveDataProvider +snippet yadp + $dataProvider = new CActiveDataProvider('${1}', array( + 'criteria' => array( + 'condition' => '${2}', + 'order' => '${3}', + 'with' => array('${4}') + ), + //'pagination' => false, + 'pagination' => array( + 'pageSize'=>${5}, + ), + )); + ${6} + // $dataProvider->getData() will return a list of Post objects + +#Yii renderDynamic internal +snippet yrdi + $this->renderDynamic('${1:callback}', array('${2:key}'=>${3:value})); + +#Yii register script +snippet yregs + Yii::app()->clientScript->registerScript('${1:id}', '${2}', CClientScript::POS_${3:READY}); + +#Yii Flush cache +snippet ycaf + Yii::app()->cache->flush(); + +#Yii Yii::app()->request->cookies +snippet yco + Yii::app()->request->cookies['${1}'] + +#Yii user-> +snippet yuser + Yii::app()->user->${1} + +#Yii refresh +snippet yrf + $this->refresh(); + +#Yii import +snippet yimp + Yii::import('${1}'); + +#Yii trace +snippet ytrace + Yii::trace('${1:msg}'); + +#Yii params +snippet ypar + Yii::app()->params['${1}'] + +#Yii isPostRequest +snippet yispost + Yii::app()->request->isPostRequest + +#Yii IF isAjaxRequest +snippet yifisajax + if(Yii::app()->request->isAjaxRequest == TRUE) + { + ${1} + } + +#Yii Yii::app()->cache->delete +snippet ydelcache + Yii::app()->cache->delete('${1:key}'); + +#Yii render view +snippet yr + $this->render('${1:view}',array('${2:key}'=>${3:value})); + +#Yii redirect +snippet yre + $this->redirect(array('${1:controller}/${2:action}')); + +#Yii Get cache +snippet ycag + Yii::app()->cache->get('${1:key}'); + +#Yii render text +snippet yrt + $this->renderText('${1}'); + +#Yii render partial +snippet yrp + $this->renderPartial('${1:view}',array('${2:key}'=>${3:value})); + +#----------------Yii Model----------------------------- +#Yii Model count +snippet ycountm + ${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${4:value})); + +#Yii Model countBySql +snippet ycountbs + ${1:ModelName}::model()->countBySql(${2:sql},array('${3:key}'=>${4:value})); + +#Yii Model updateAll +snippet yupdatea + ${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${5:value})); + +#Yii Model updateByPk +snippet yupdatebp + ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${6:value})); + +#Yii Model deleteAll +snippet ydela + ${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${4:value})); + +#Yii Model deleteByPk +snippet ydelbp + ${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value})); + +#Yii Model find +snippet yfind + ${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${4:value})); + +#Yii Model findAll +snippet yfinda + ${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${4:value})); + +#Yii Model findByPk +snippet yfindbp + ${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value})); + +#Yii Model findAllByPk +snippet yfindabp + ${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${5:value})); + +#Yii Model findBySql +snippet yfindbs + ${1:ModelName}::model()->findBySql(${2:sql}, array('${3:key}'=>${4:value})); + +#Yii Model findAllByAttributes +snippet yfindaba + ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${6:value})); + +#Yii Model exists +snippet yexists + ${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${4:value})); + +#Yii Create model class +snippet ymodel + 'path.to.FilterClass', + 'propertyName'=>'propertyValue', + ), + ); + } + + public function actions() + { + // return external action classes, e.g.: + return array( + 'action1'=>'path.to.ActionClass', + 'action2'=>array( + 'class'=>'path.to.AnotherActionClass', + 'propertyName'=>'propertyValue', + ), + ); + } + */ + } + +#Yii Create controller action method +snippet yact + public function action${1:Index}(${2:params}) + { + ${3} + } + +