From f5b8c378e729f4d8682a684ab320366a951164ad Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 08:09:49 +1200 Subject: [PATCH 01/73] use parent instead of base --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 4ba985d..0037cc3 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,7 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - use base qw(${2:ParentClass}); + use parent qw(${2:ParentClass}); sub new { my $class = shift; From fab29b6279ac835fe08fee4ade15bc4a8fc82fc6 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 18:21:55 +1200 Subject: [PATCH 02/73] experimenting with a couple new package constructs --- snippets/perl.snippets | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 0037cc3..d77d748 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,16 +82,30 @@ snippet fore snippet cl package ${1:ClassName}; - use parent qw(${2:ParentClass}); + #use parent qw(${2:ParentClass}); - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } 1;${3} + + __END__ + +# Package block syntax +snippet package + package ${1:ClassName} ${2:version} { + + ${3:#}use Moose; + + ${4:#}use parent qw(${5:ParentClass}); + ${3:#}extends qw(${5:ParentClass}); + + ${6:#...} + + } + + 1; + + __END__ + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; From 75598b4fee28a149d92f4a809a3911ececd3b441 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 20:32:53 +1200 Subject: [PATCH 03/73] experimenting with some new perl features --- snippets/perl.snippets | 86 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index d77d748..2796658 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -83,29 +83,51 @@ snippet cl package ${1:ClassName}; #use parent qw(${2:ParentClass}); - - - 1;${3} - - __END__ - -# Package block syntax -snippet package - package ${1:ClassName} ${2:version} { - - ${3:#}use Moose; - - ${4:#}use parent qw(${5:ParentClass}); - ${3:#}extends qw(${5:ParentClass}); - - ${6:#...} - - } + + ${3:#...} 1; __END__ +# Moose package +snippet moosecl + package ${1:ClassName}; + + use Moose; + #extends '${2:# ParentClass}'; + + ${3:#...} + + 1; + + + __END__ + + +# Package syntax perl >= 5.12.0 +snippet package + package ${1:ClassName} ${2:0.99}; + + ${3:#...} + + 1; + + __END__ + + +#moose +snippet moose + use Moose; + +# moose extends +snippet extends + extends qw(${1:Parent Class}); + +# parent +snippet parent + use parent qw(${1:Parent Class}); + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; @@ -190,7 +212,6 @@ snippet hslice @{ ${1:hash} }{ ${2:array} } - # map snippet map map { ${2: body } } ${1: @array } ; @@ -276,33 +297,6 @@ snippet parg -# 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} => ( From a5362402b819b01793ae7cbc5f5f1a467657f313 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 22:05:44 +1200 Subject: [PATCH 04/73] make package definitions more generic --- snippets/perl.snippets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 2796658..8164130 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,9 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - #use parent qw(${2:ParentClass}); - - ${3:#...} + ${2:#...} 1; @@ -93,7 +91,7 @@ snippet cl # Moose package snippet moosecl package ${1:ClassName}; - + use Moose; #extends '${2:# ParentClass}'; From 02160ecee14d759297b3e4db2fdbad7a1caffd30 Mon Sep 17 00:00:00 2001 From: Stephen Tudor Date: Thu, 31 May 2012 11:23:21 -0400 Subject: [PATCH 05/73] JS whitespace style --- snippets/javascript.snippets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/snippets/javascript.snippets b/snippets/javascript.snippets index de50a0c..1282f73 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 @@ -36,7 +36,7 @@ snippet t ${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} From dac0f8a7a68fc68e622acc965722e564a6bfc515 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:27:09 +1200 Subject: [PATCH 06/73] changing package template and a few others --- snippets/perl.snippets | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 8164130..ef30667 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -79,7 +79,7 @@ snippet for snippet fore ${1:expression} foreach @${2:array};${3} # Package -snippet cl +snippet package package ${1:ClassName}; ${2:#...} @@ -88,23 +88,9 @@ snippet cl __END__ -# Moose package -snippet moosecl - package ${1:ClassName}; - - use Moose; - #extends '${2:# ParentClass}'; - - ${3:#...} - - 1; - - - __END__ - # Package syntax perl >= 5.12.0 -snippet package +snippet packagev512 package ${1:ClassName} ${2:0.99}; ${3:#...} @@ -117,6 +103,8 @@ snippet package #moose snippet moose use Moose; + use namespace::autoclean; + #extends '${2:# ParentClass}'; # moose extends snippet extends @@ -298,10 +286,12 @@ snippet parg # 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} ); @@ -309,14 +299,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 @@ -353,6 +343,7 @@ snippet tprep my $self = shift; ${4:# body} } + # cause failures to print stack trace snippet debug_trace use Carp; # 'verbose'; From cdacf7c3df67163b4bf9ce8ca863af84c1d72ee9 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:37:23 +1200 Subject: [PATCH 07/73] experimenting with file name in package snippet --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index ef30667..9afdee6 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -91,7 +91,7 @@ snippet package # Package syntax perl >= 5.12.0 snippet packagev512 - package ${1:ClassName} ${2:0.99}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; ${3:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - #extends '${2:# ParentClass}'; + ${1:#}extends '${2:# ParentClass}'; # moose extends snippet extends From f46672c1cf2e71f570ee6fec770a211b8e451daa Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:43:24 +1200 Subject: [PATCH 08/73] substitute regular package name --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 9afdee6..79462fc 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -80,7 +80,7 @@ snippet fore ${1:expression} foreach @${2:array};${3} # Package snippet package - package ${1:ClassName}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; ${2:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:# ParentClass}'; + ${1:#}extends '${2:ParentClass}'; # moose extends snippet extends From c59a7f2c49bcf0b7eb91498cb4184b09818a9149 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 08:09:49 +1200 Subject: [PATCH 09/73] use parent instead of base --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 4ba985d..0037cc3 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,7 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - use base qw(${2:ParentClass}); + use parent qw(${2:ParentClass}); sub new { my $class = shift; From 79b4377ee3caf2060b4ffdcc3ccf39fbcdde5ded Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 18:21:55 +1200 Subject: [PATCH 10/73] experimenting with a couple new package constructs --- snippets/perl.snippets | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 0037cc3..d77d748 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,16 +82,30 @@ snippet fore snippet cl package ${1:ClassName}; - use parent qw(${2:ParentClass}); + #use parent qw(${2:ParentClass}); - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } 1;${3} + + __END__ + +# Package block syntax +snippet package + package ${1:ClassName} ${2:version} { + + ${3:#}use Moose; + + ${4:#}use parent qw(${5:ParentClass}); + ${3:#}extends qw(${5:ParentClass}); + + ${6:#...} + + } + + 1; + + __END__ + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; From b272f87f1f05ed81e57fc4356507a38892b5f8b8 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 20:32:53 +1200 Subject: [PATCH 11/73] experimenting with some new perl features --- snippets/perl.snippets | 86 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index d77d748..2796658 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -83,29 +83,51 @@ snippet cl package ${1:ClassName}; #use parent qw(${2:ParentClass}); - - - 1;${3} - - __END__ - -# Package block syntax -snippet package - package ${1:ClassName} ${2:version} { - - ${3:#}use Moose; - - ${4:#}use parent qw(${5:ParentClass}); - ${3:#}extends qw(${5:ParentClass}); - - ${6:#...} - - } + + ${3:#...} 1; __END__ +# Moose package +snippet moosecl + package ${1:ClassName}; + + use Moose; + #extends '${2:# ParentClass}'; + + ${3:#...} + + 1; + + + __END__ + + +# Package syntax perl >= 5.12.0 +snippet package + package ${1:ClassName} ${2:0.99}; + + ${3:#...} + + 1; + + __END__ + + +#moose +snippet moose + use Moose; + +# moose extends +snippet extends + extends qw(${1:Parent Class}); + +# parent +snippet parent + use parent qw(${1:Parent Class}); + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; @@ -190,7 +212,6 @@ snippet hslice @{ ${1:hash} }{ ${2:array} } - # map snippet map map { ${2: body } } ${1: @array } ; @@ -276,33 +297,6 @@ snippet parg -# 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} => ( From 313ec98d836305ae913344a4ba71a8926e3440f3 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 22:05:44 +1200 Subject: [PATCH 12/73] make package definitions more generic --- snippets/perl.snippets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 2796658..8164130 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,9 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - #use parent qw(${2:ParentClass}); - - ${3:#...} + ${2:#...} 1; @@ -93,7 +91,7 @@ snippet cl # Moose package snippet moosecl package ${1:ClassName}; - + use Moose; #extends '${2:# ParentClass}'; From af4851445519c4ee7df3c1f31f1d000e22e0ef88 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:27:09 +1200 Subject: [PATCH 13/73] changing package template and a few others --- snippets/perl.snippets | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 8164130..ef30667 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -79,7 +79,7 @@ snippet for snippet fore ${1:expression} foreach @${2:array};${3} # Package -snippet cl +snippet package package ${1:ClassName}; ${2:#...} @@ -88,23 +88,9 @@ snippet cl __END__ -# Moose package -snippet moosecl - package ${1:ClassName}; - - use Moose; - #extends '${2:# ParentClass}'; - - ${3:#...} - - 1; - - - __END__ - # Package syntax perl >= 5.12.0 -snippet package +snippet packagev512 package ${1:ClassName} ${2:0.99}; ${3:#...} @@ -117,6 +103,8 @@ snippet package #moose snippet moose use Moose; + use namespace::autoclean; + #extends '${2:# ParentClass}'; # moose extends snippet extends @@ -298,10 +286,12 @@ snippet parg # 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} ); @@ -309,14 +299,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 @@ -353,6 +343,7 @@ snippet tprep my $self = shift; ${4:# body} } + # cause failures to print stack trace snippet debug_trace use Carp; # 'verbose'; From 2abf84e6b90d9fb2c38929048bff2da1cb968b40 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:37:23 +1200 Subject: [PATCH 14/73] experimenting with file name in package snippet --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index ef30667..9afdee6 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -91,7 +91,7 @@ snippet package # Package syntax perl >= 5.12.0 snippet packagev512 - package ${1:ClassName} ${2:0.99}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; ${3:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - #extends '${2:# ParentClass}'; + ${1:#}extends '${2:# ParentClass}'; # moose extends snippet extends From a42eb6a320285a522847b04e678804850beb6c48 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:43:24 +1200 Subject: [PATCH 15/73] substitute regular package name --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 9afdee6..79462fc 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -80,7 +80,7 @@ snippet fore ${1:expression} foreach @${2:array};${3} # Package snippet package - package ${1:ClassName}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; ${2:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:# ParentClass}'; + ${1:#}extends '${2:ParentClass}'; # moose extends snippet extends From 2f701a905899aac4b364943d0803ddee84b955e2 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 09:57:26 +1200 Subject: [PATCH 16/73] put extends in a BEGIN block --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 79462fc..dbe9288 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:ParentClass}'; + ${1:#}BEGIN {extends '${2:ParentClass}}'; # moose extends snippet extends From 0d5ecadc576ad095bcdf33c010340ac1e79d1040 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 16:07:33 +1200 Subject: [PATCH 17/73] fix quote on moose snippet --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index dbe9288..024aee1 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}BEGIN {extends '${2:ParentClass}}'; + ${1:#}BEGIN {extends '${2:ParentClass}'}; # moose extends snippet extends From c805b4f24131b05ee85e2a77187a444a260f9639 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 16:08:11 +1200 Subject: [PATCH 18/73] put in a goto point to jump to --- snippets/perl.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 024aee1..6416180 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -105,6 +105,7 @@ snippet moose use Moose; use namespace::autoclean; ${1:#}BEGIN {extends '${2:ParentClass}'}; + ${3} # moose extends snippet extends From 4987a54300a90f9d2e35e32a31846bf6f74c1887 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Thu, 26 Jul 2012 21:35:03 +1200 Subject: [PATCH 19/73] took some whitespace out removed some redundant snippets --- snippets/perl.snippets | 52 ++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 6416180..e8de8fb 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,68 +82,51 @@ snippet fore snippet package package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; - ${2:#...} + ${2} 1; __END__ - - -# Package syntax perl >= 5.12.0 -snippet packagev512 +# Package syntax perl >= 5.14 +snippet packagev514 package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; - ${3:#...} + ${3} 1; __END__ - - #moose snippet moose use Moose; use namespace::autoclean; ${1:#}BEGIN {extends '${2:ParentClass}'}; + ${3} - -# moose extends -snippet extends - extends qw(${1:Parent Class}); - # 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 } } @@ -156,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 @@ -183,10 +166,10 @@ snippet qr/ #given snippet given - given ($${1:var}) { + given ($${1:var}) { ${2:# cases} ${3:# default} - } + } # switch-like case snippet when @@ -212,7 +195,7 @@ snippet ppod ${1:ClassName} - ${2:ShortDesc} =head1 SYNOPSIS - + use $1; ${3:# synopsis...} @@ -224,7 +207,7 @@ snippet ppod =head1 INTERFACE - + =head1 DEPENDENCIES @@ -254,7 +237,7 @@ snippet parg =item Arguments - + =over 3 =item @@ -277,7 +260,6 @@ snippet parg =back - =back @@ -328,7 +310,7 @@ snippet tsub sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) { my $self = shift; ${4:# body} - + } # Test::Routine-style test From 8e6b144f68de6aa449c08264cd1f4f31a5b45534 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Thu, 26 Jul 2012 21:41:52 +1200 Subject: [PATCH 20/73] create an inline documented subroutine --- snippets/perl.snippets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index e8de8fb..bbc9e30 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -228,8 +228,17 @@ snippet psubi =cut +# inline documented subroutine +snippet subpod + =head2 $1 + Summarry of $1 + =cut + + sub ${1:subroutine_name} { + ${2:# body...} + } # Subroutine signature snippet parg =over 2 From b5bb673ee3aa8e74efe16e50cf3009c3098d9c7e Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Thu, 26 Jul 2012 21:44:58 +1200 Subject: [PATCH 21/73] corrected spelling mistake --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index bbc9e30..9cebede 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -232,7 +232,7 @@ snippet psubi snippet subpod =head2 $1 - Summarry of $1 + Summary of $1 =cut From 6bbe8b5598c12bee7b49b0d45cb32feeba3b1ca4 Mon Sep 17 00:00:00 2001 From: Josh Bode Date: Fri, 10 Aug 2012 23:58:38 +1000 Subject: [PATCH 22/73] Added R snippets --- snippets/r.snippets | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 snippets/r.snippets diff --git a/snippets/r.snippets b/snippets/r.snippets new file mode 100644 index 0000000..44a2b9b --- /dev/null +++ b/snippets/r.snippets @@ -0,0 +1,32 @@ +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 else + 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}) From b554adc78d95389b38a472232f40ec56ea1ec734 Mon Sep 17 00:00:00 2001 From: Josh Bode Date: Sat, 11 Aug 2012 00:44:45 +1000 Subject: [PATCH 23/73] Added *apply, **ply functions and array types. --- snippets/r.snippets | 65 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/snippets/r.snippets b/snippets/r.snippets index 44a2b9b..909e70d 100644 --- a/snippets/r.snippets +++ b/snippets/r.snippets @@ -14,7 +14,7 @@ snippet if if (${1:condition}) { ${2:code} } -snippet else +snippet el else { ${1:code} } @@ -30,3 +30,66 @@ snippet fun } 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}) From db791bcc6fd40c719ffd45cb234189db4f58322d Mon Sep 17 00:00:00 2001 From: Camilo Payan Date: Wed, 15 Aug 2012 20:47:17 -0400 Subject: [PATCH 24/73] Added xslt snippets. Still going to work on it as time goes.w --- snippets/xslt.snippets | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 snippets/xslt.snippets diff --git a/snippets/xslt.snippets b/snippets/xslt.snippets new file mode 100644 index 0000000..d61a547 --- /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 + ${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 + + From a2f6b10a43c2a9661a8a6d3beca61256c9e338cb Mon Sep 17 00:00:00 2001 From: Camilo Payan Date: Wed, 15 Aug 2012 22:48:32 -0400 Subject: [PATCH 25/73] Caught a mistake in the attribute with value-of. Value-of wasn't self-closed. --- snippets/xslt.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/xslt.snippets b/snippets/xslt.snippets index d61a547..892e9db 100644 --- a/snippets/xslt.snippets +++ b/snippets/xslt.snippets @@ -16,7 +16,7 @@ snippet attribute blank snippet attribute value-of - + ${3} snippet call-template From 7d39c38115187869a2a826d7d00b5629d3949682 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 22 Aug 2012 00:03:10 -0400 Subject: [PATCH 26/73] fixing duplicate numbering in BEERWARE snippet. --- snippets/_.snippets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/_.snippets b/snippets/_.snippets index 081db1c..b3570a6 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -216,12 +216,12 @@ 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} From f5d6c75d482a650e17c432ea278265ced36186a3 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Fri, 24 Aug 2012 12:28:08 +0200 Subject: [PATCH 27/73] Add comment argument to cite snippet --- snippets/tex.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/tex.snippets b/snippets/tex.snippets index 511a4c9..34893f5 100644 --- a/snippets/tex.snippets +++ b/snippets/tex.snippets @@ -146,9 +146,9 @@ snippet page ${1:page}~\pageref{${2}}${3} snippet index \index{${1:index}}${2} -#cite +#Citations snippet cite - \cite{${1}}${2} + \cite[${1}]{${2}}${3} #Formating text: italic, bold, underline, small capital, emphase .. snippet it \textit{${1:text}} From 494243d248a500bb703ac8e6bb749c700ec5f2a7 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Fri, 24 Aug 2012 12:32:36 +0200 Subject: [PATCH 28/73] Add snippet for footnote citations with biblatex --- snippets/tex.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/tex.snippets b/snippets/tex.snippets index 34893f5..6631c02 100644 --- a/snippets/tex.snippets +++ b/snippets/tex.snippets @@ -149,6 +149,8 @@ snippet index #Citations snippet cite \cite[${1}]{${2}}${3} +snippet fcite + \footcite[${1}]{${2}}${3} #Formating text: italic, bold, underline, small capital, emphase .. snippet it \textit{${1:text}} From 0e91c0589bd221d3eaf60715a6c23d71f51301eb Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Fri, 24 Aug 2012 14:56:49 +0200 Subject: [PATCH 29/73] Remove fold markers from tex snippets tex.vim supports syntactic folding out of the box, set "let g:tex_fold_enabled=1" --- snippets/tex.snippets | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/snippets/tex.snippets b/snippets/tex.snippets index 511a4c9..8836d65 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} From 8108ecd9808a69d397cfc8d5f3258734f1243ea5 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Mon, 27 Aug 2012 14:01:57 -0700 Subject: [PATCH 30/73] [cpp] Added C++11-style foreach snippet. --- snippets/cpp.snippets | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index c177a15..40e9253 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -64,3 +64,8 @@ snippet scin std::cin >> ${1}; snippet cin cin >> ${1}; +# foreach +snippet fore + for (${1:auto} ${2:i} : ${3:container}) { + ${4:/* code */} + } From 7fe10931b2ace47daa2356ea6c013f407ce6a4c3 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Mon, 27 Aug 2012 14:10:27 -0700 Subject: [PATCH 31/73] [cpp] Reorganized snippets for consistency. Added comments to snippets that didn't have any. Reordered snippets so relevant snippets were close together. Removed cout/cin snippets for consistency with other snippets in std namespace. --- snippets/cpp.snippets | 86 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 40e9253..52a8c4b 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,28 +1,17 @@ -# 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::vector +snippet vector + std::vector<${1:char}> ${2}; # 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 +# std::cout +snippet cout + std::cout << ${1} << std::endl; +# std::cin +snippet cin + std::cin >> ${1}; +# class snippet class class ${1:`Filename('$1', 'name')`} { @@ -34,38 +23,47 @@ snippet class ${3:/* data */} }; +# member function implementations +snippet mfun + ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { + ${5:return}; + } +# namespace +snippet ns + namespace ${1:`Filename('', 'my')`} { + ${2} + } /* namespace $1 */ + +# for i loop snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} } +# foreach +snippet fore + for (${1:auto} ${2:i} : ${3:container}) { + ${4:/* code */} + } +# iterator +snippet iter + for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) { + ${6} + } + # 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} - } +# 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} -# 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}; -# foreach -snippet fore - for (${1:auto} ${2:i} : ${3:container}) { - ${4:/* code */} - } From bc0e5b9301d8f6cbbabfde30cea7bdbe81b64c15 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Mon, 27 Aug 2012 19:03:58 -0700 Subject: [PATCH 32/73] Added myself to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 30c65d9..1063d97 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ +Aaron Broder Adam Folmert Alberto Pose Angel Alonso From 32eef65402161c76bf92b97a17ea644416148070 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Mon, 27 Aug 2012 21:24:47 -0700 Subject: [PATCH 33/73] Finished STL container snippets --- snippets/cpp.snippets | 48 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 52a8c4b..f6c19f5 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,10 +1,52 @@ +## STL Collections +# std::array +snippet array + std::array<${1:T}, ${2:N}> ${2};${3} # std::vector snippet vector - std::vector<${1:char}> ${2}; + 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:value}> ${3}; - + 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}> ${3};${4} +# 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} # std::cout snippet cout std::cout << ${1} << std::endl; From 3b952e73fad5b5d814d1bff57173c4ad3e9484d1 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 09:33:50 -0700 Subject: [PATCH 34/73] [cpp] Added access modifier snippets. --- snippets/cpp.snippets | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index f6c19f5..09d9998 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -47,6 +47,23 @@ snippet queue # std::priority_queue snippet pqueue std::priority_queue<${1:T}> ${2};${3} +## +## Access Modifiers +# private +snippet pr + private +# protected +snippet po + protected +# public +snippet pu + public +# friend +snippet fr + friend +# mutable +snippet mu + mutable # std::cout snippet cout std::cout << ${1} << std::endl; From 4700702ea54472cc37a42cf66e6798d625dd5415 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 09:41:16 -0700 Subject: [PATCH 35/73] [cpp] Created class section --- snippets/cpp.snippets | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 09d9998..ed7be50 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -64,14 +64,10 @@ snippet fr # mutable snippet mu mutable -# std::cout -snippet cout - std::cout << ${1} << std::endl; -# std::cin -snippet cin - std::cin >> ${1}; +## +## Class # class -snippet class +snippet cl class ${1:`Filename('$1', 'name')`} { public: @@ -81,8 +77,7 @@ snippet class private: ${3:/* data */} }; - -# member function implementations +# member function implementation snippet mfun ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { ${5:return}; @@ -92,7 +87,12 @@ snippet ns namespace ${1:`Filename('', 'my')`} { ${2} } /* namespace $1 */ - +# std::cout +snippet cout + std::cout << ${1} << std::endl; +# std::cin +snippet cin + std::cin >> ${1}; # for i loop snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { From 6518bba15ff54e61a5196b540219ec498bf999a7 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 09:43:20 -0700 Subject: [PATCH 36/73] [cpp] Created input/output section. --- snippets/cpp.snippets | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index ed7be50..1ccdc51 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -87,12 +87,24 @@ snippet ns namespace ${1:`Filename('', 'my')`} { ${2} } /* namespace $1 */ +## +## Input/Output # std::cout snippet cout std::cout << ${1} << std::endl; # std::cin snippet cin std::cin >> ${1}; +# 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} + # for i loop snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { @@ -116,13 +128,3 @@ snippet itera ${2:std::cout << *$1 << std::endl;} } -# 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} - From 260f24cccc271a551173854ac7fffb208844d669 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 09:44:24 -0700 Subject: [PATCH 37/73] [cpp] Added iteration section. --- snippets/cpp.snippets | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 1ccdc51..637b249 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -105,7 +105,9 @@ snippet readfile fclose($2); }${3} -# for i loop +## +## Iteration +# for i snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} From 06b2e3a1880a90978516024fcde40cc59870b87d Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 10:34:24 -0700 Subject: [PATCH 38/73] [c] Added 'elif' snippet. --- snippets/c.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/c.snippets b/snippets/c.snippets index 38e8d9e..e17d064 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -50,6 +50,10 @@ snippet el else { ${1} } +snippet elif + else if (${1:/* condition */}) { + ${2:/* code */} + } # Ternary conditional snippet t ${1:/* condition */} ? ${2:a} : ${3:b} From 5ea5d2893a55d71ac9379351cdae0c107830ae98 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 10:56:17 -0700 Subject: [PATCH 39/73] [cpp] Minor bug fixes Fixed broken sequences on a few STL container snippets. Renamed the access modifier snippets to avoid conflicts. --- snippets/cpp.snippets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 637b249..b14f3d9 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,7 +1,7 @@ ## STL Collections # std::array snippet array - std::array<${1:T}, ${2:N}> ${2};${3} + std::array<${1:T}, ${2:N}> ${3};${4} # std::vector snippet vector std::vector<${1:T}> ${2};${3} @@ -16,7 +16,7 @@ snippet list std::list<${1:T}> ${2};${3} # std::set snippet set - std::set<${1:T}> ${2};{$3} + std::set<${1:T}> ${2};${3} # std::map snippet map std::map<${1:Key}, ${2:T}> ${3};${4} @@ -34,7 +34,7 @@ snippet umap std::unordered_map<${1:Key}, ${2:T}> ${3};${4} # std::unordered_multiset snippet umset - std::unordered_multiset<${1:T}> ${3};${4} + std::unordered_multiset<${1:T}> ${2};${3} # std::unordered_multimap snippet ummap std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4} @@ -50,13 +50,13 @@ snippet pqueue ## ## Access Modifiers # private -snippet pr +snippet pri private # protected -snippet po +snippet pro protected # public -snippet pu +snippet pub public # friend snippet fr From 67c276b85dae8f3a16e7937312847b2c98283188 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 11:22:24 -0700 Subject: [PATCH 40/73] [c/cpp] Added postfix tab stop to most snippets This allows for people to quickly tab to the end of the snippet and continue writing code without having to exit insert mode. --- snippets/c.snippets | 24 ++++++++++++------------ snippets/cpp.snippets | 14 +++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/snippets/c.snippets b/snippets/c.snippets index e17d064..8169614 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -27,11 +27,11 @@ snippet def snippet ifdef #ifdef ${1:FOO} ${2:#define } - #endif + #endif${3} snippet #if #if ${1:FOO} ${2} - #endif + #endif${3} # Header Include-Guard snippet once #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} @@ -45,15 +45,15 @@ snippet once snippet if if (${1:/* condition */}) { ${2:/* code */} - } + }${3} snippet el else { ${1} - } + }${2} snippet elif else if (${1:/* condition */}) { ${2:/* code */} - } + }${3} # Ternary conditional snippet t ${1:/* condition */} ? ${2:a} : ${3:b} @@ -61,28 +61,28 @@ snippet t snippet do do { ${2:/* code */} - } while (${1:/* condition */}); + } while (${1:/* condition */});${3} # While Loop snippet wh while (${1:/* condition */}) { ${2:/* code */} - } + }${3} # For Loop snippet for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} - } + }${5} # Custom For Loop snippet forr for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { ${5:/* code */} - } + }${6} # Function snippet fun ${1:void} ${2:function_name}(${3}) { ${4:/* code */} - } + }${5} # Function Declaration snippet fund ${1:void} ${2:function_name}(${3});${4} @@ -98,12 +98,12 @@ snippet st snippet tds typedef struct ${2:_$1 }{ ${3:/* data */} - } ${1:`Filename('$1_t', 'name')`}; + } ${1:`Filename('$1_t', 'name')`};${4} # Typdef enum snippet tde typedef enum { ${1:/* data */} - } ${2:foo}; + } ${2:foo};${3} # printf # unfortunately version this isn't as nice as TextMates's, given the lack of a # dynamic `...` diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index b14f3d9..9aea849 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -80,7 +80,7 @@ snippet cl # member function implementation snippet mfun ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { - ${5:return}; + ${5:/* code */} } # namespace snippet ns @@ -91,10 +91,10 @@ snippet ns ## Input/Output # std::cout snippet cout - std::cout << ${1} << std::endl; + std::cout << ${1} << std::endl;${2} # std::cin snippet cin - std::cin >> ${1}; + std::cin >> ${1};${2} # read file into vector snippet readfile std::vector v; @@ -111,22 +111,22 @@ snippet readfile 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;} - } + }${3} From e7d5983bfcd8d0bb4234e7597ac3d97bad938a39 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 11:41:46 -0700 Subject: [PATCH 41/73] [c] Reorganized to match cpp snippets --- snippets/c.snippets | 75 ++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/snippets/c.snippets b/snippets/c.snippets index 8169614..35c87be 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${3} +# if snippet #if #if ${1:FOO} ${2} - #endif${3} -# Header Include-Guard + #endif +# header include guard snippet once #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} @@ -41,77 +48,89 @@ 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} - }${2} + }${3} +# else if snippet elif else if (${1:/* condition */}) { ${2:/* code */} }${3} -# Ternary conditional +# ternary snippet t ${1:/* condition */} ? ${2:a} : ${3:b} -# Do While Loop -snippet do - do { - ${2:/* code */} - } while (${1:/* condition */});${3} -# While Loop -snippet wh - while (${1:/* condition */}) { - ${2:/* code */} - }${3} -# For Loop +## +## Loops +# for snippet for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4:/* code */} }${5} -# Custom For Loop +# for (custom) snippet forr for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { ${5:/* code */} }${6} -# Function +# 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 */} }${5} -# Function Declaration +# 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')`};${4} -# Typdef enum +# typedef enum snippet tde typedef enum { ${1:/* data */} } ${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} +## +## Miscellaneous # This is kind of convenient snippet . [${1}]${2} From e80158c9985b2d1fe66669529a4bc65ad6057ad4 Mon Sep 17 00:00:00 2001 From: Eustaquio Rangel Date: Wed, 29 Aug 2012 09:14:08 -0300 Subject: [PATCH 42/73] Removed the newline after the test snippet --- snippets/ruby.snippets | 1 - 1 file changed, 1 deletion(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 26bdfa5..37826f3 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -865,7 +865,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} From a3e5bbed2bfbb26f35b1446e8130482221fb5227 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Fri, 31 Aug 2012 14:53:39 -0700 Subject: [PATCH 43/73] [cpp] Added C++11 lambda snippets --- snippets/cpp.snippets | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 9aea849..59c7749 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -129,4 +129,13 @@ snippet itera for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) { ${2:std::cout << *$1 << std::endl;} }${3} - +## +## Lambdas +# lamda (one line) +snippet ld + [${1}](${2}){${3:/* code */}}${4} +# lambda (multi-line) +snippet lld + [${1}](${2}){ + ${3:/* code */} + }${4} From 03b7d9e98be5723e26a4b2143d09720dfa8b42b4 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Fri, 31 Aug 2012 14:56:09 -0700 Subject: [PATCH 44/73] [cpp] Removed readfile snippet. The snippet doesn't use expected C++ practices for reading files and is more of a Textmate legacy. --- snippets/cpp.snippets | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 59c7749..c3e19fe 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -95,16 +95,6 @@ snippet cout # std::cin snippet cin std::cin >> ${1};${2} -# 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} - ## ## Iteration # for i From d451f3ebb10b2ef334b19f4d1bbdb2c7aef962ae Mon Sep 17 00:00:00 2001 From: Chipairon Date: Wed, 5 Sep 2012 15:35:08 +0200 Subject: [PATCH 45/73] Added missing " to footer. and footer# --- snippets/html.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/html.snippets b/snippets/html.snippets index be8b0f6..43ad84b 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -353,11 +353,11 @@ snippet footer ${1} snippet footer. -
${2}
snippet footer# -
${2}
snippet form From efeda76620b00f7e2000be6b005fa2e2e22e854f Mon Sep 17 00:00:00 2001 From: Erik Westrup Date: Fri, 7 Sep 2012 18:50:11 -0700 Subject: [PATCH 46/73] Did not consider Gecos field last time. --- AUTHORS | 1 + snippets/java.snippets | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 1063d97..1261dc8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,3 +37,4 @@ Povilas Balzaravičius Pawka Dmitry Dementev Travis Holton Chrisyue +Erik Westrup diff --git a/snippets/java.snippets b/snippets/java.snippets index fb27b9c..2d4568a 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 From e1e10b91617e8af4475b16464d0944777b6a6d89 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 25 Sep 2012 17:05:04 -0300 Subject: [PATCH 47/73] Added 'for in do' coffeescript snippet --- snippets/coffee.snippets | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snippets/coffee.snippets b/snippets/coffee.snippets index dfe3658..df537a9 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:name}) -> + ${3:// body} # Array comprehension snippet fora for ${1:name} in ${2:array} From 861b95272b9a7efb65dd628320798940fd8e3e9f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 25 Sep 2012 17:42:44 -0300 Subject: [PATCH 48/73] Fixed 'for in do' snippet to mirror the loop variable in the 'do' parameter --- snippets/coffee.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/coffee.snippets b/snippets/coffee.snippets index df537a9..1461cc6 100644 --- a/snippets/coffee.snippets +++ b/snippets/coffee.snippets @@ -1,7 +1,7 @@ # Closure loop snippet forindo for ${1:name} in ${2:array} - do (${1:name}) -> + do ($1) -> ${3:// body} # Array comprehension snippet fora From a1af06d5fa780264de8a8a11133e6b54a2c80015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Guimar=C3=A3es?= Date: Tue, 25 Sep 2012 20:03:18 -0300 Subject: [PATCH 49/73] Create a encoding snippet for Ruby 1.9 --- snippets/ruby.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 37826f3..f41f027 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 From 8fd3644f76a0d42574209ac4fe0adababe22857c Mon Sep 17 00:00:00 2001 From: Jeffrey Tratner Date: Thu, 27 Sep 2012 17:51:09 -0400 Subject: [PATCH 50/73] [coffee] added export snippet --- snippets/coffee.snippets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/coffee.snippets b/snippets/coffee.snippets index 1461cc6..83b77eb 100644 --- a/snippets/coffee.snippets +++ b/snippets/coffee.snippets @@ -90,3 +90,6 @@ snippet try # Require snippet req ${2:$1} = require '${1:sys}'${3} +# Export +snippet exp + ${1:root} = exports ? this From 9a08f7decdf5e2a5e77009dadb18a07d0e143bd7 Mon Sep 17 00:00:00 2001 From: HIRAKI Satoru Date: Sun, 30 Sep 2012 19:53:44 +0900 Subject: [PATCH 51/73] improved tertiary conditional & improved switch --- snippets/javascript.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/javascript.snippets b/snippets/javascript.snippets index de50a0c..5b1caf7 100644 --- a/snippets/javascript.snippets +++ b/snippets/javascript.snippets @@ -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; From 1c0e3ee7da1e5075a6463fad7792b509149f4dbb Mon Sep 17 00:00:00 2001 From: jonasac Date: Mon, 1 Oct 2012 00:04:56 +0200 Subject: [PATCH 52/73] Fix some typos in java print snippets --- snippets/java.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/java.snippets b/snippets/java.snippets index 2d4568a..854f14a 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -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}); ## From 7387b15ebf339418de25781c16a577a40de73643 Mon Sep 17 00:00:00 2001 From: theocrite Date: Fri, 12 Oct 2012 18:05:42 +0300 Subject: [PATCH 53/73] Added WTFPL licence. --- snippets/_.snippets | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/snippets/_.snippets b/snippets/_.snippets index b3570a6..fd249e7 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -225,3 +225,16 @@ snippet BEERWARE this stuff is worth it, you can buy me a beer or coffee in return ${4} + +snipper WTFPL + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + 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 From e3c5655b0ff11ad6c15e287b59e351b55c4a6c1b Mon Sep 17 00:00:00 2001 From: Kalinin Eugene Date: Fri, 12 Oct 2012 19:30:05 +0400 Subject: [PATCH 54/73] added sql/plsql snippets --- snippets/plsql.snippets | 109 ++++++++++++++++++++++++++++++++++++++++ snippets/sql.snippets | 26 ++++++++++ 2 files changed, 135 insertions(+) create mode 100644 snippets/plsql.snippets create mode 100644 snippets/sql.snippets 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/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} From 12ddfd362af05f038821e6bc582bbc8798889aee Mon Sep 17 00:00:00 2001 From: theocrite Date: Mon, 15 Oct 2012 12:55:37 +0300 Subject: [PATCH 55/73] Added WTFPL licence. --- snippets/_.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/_.snippets b/snippets/_.snippets index fd249e7..9d62d97 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -226,7 +226,7 @@ snippet BEERWARE ${4} -snipper WTFPL +snippet WTFPL DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 From 7b3fe9d9c64d2efe8b19b347a4ca66e443acc7fe Mon Sep 17 00:00:00 2001 From: theocrite Date: Mon, 15 Oct 2012 14:10:42 +0300 Subject: [PATCH 56/73] Added WTFPL licence. --- snippets/_.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/_.snippets b/snippets/_.snippets index 9d62d97..826ec9e 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -230,7 +230,7 @@ snippet WTFPL DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 - Copyright (C) 2004 Sam Hocevar +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 From 28ce3bb6f4ac2048366a88746000e91e2388942b Mon Sep 17 00:00:00 2001 From: Jack Stalnaker Date: Thu, 18 Oct 2012 16:27:02 -0500 Subject: [PATCH 57/73] added switch, switch with no default, and case snippets to c snippets --- snippets/c.snippets | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/snippets/c.snippets b/snippets/c.snippets index 35c87be..72ce3d0 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -68,6 +68,27 @@ snippet elif # ternary snippet t ${1:/* condition */} ? ${2:a} : ${3:b} +# 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 From d66eaaf88e674cde8081c564b2baa7e059b0e787 Mon Sep 17 00:00:00 2001 From: "David Deryl Downey - AKA Deryl R. Doucette" Date: Thu, 18 Oct 2012 23:21:11 -0300 Subject: [PATCH 58/73] Changed patfh to fpath. Makes sense due to context --- snippets/ruby.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index f41f027..63ec178 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -394,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 From d115300c98a039de5eeebe881aea04217d38e963 Mon Sep 17 00:00:00 2001 From: Jim Deville Date: Fri, 19 Oct 2012 12:16:48 -0700 Subject: [PATCH 59/73] Delete duplicate snippet --- snippets/eruby.snippets | 4 ---- 1 file changed, 4 deletions(-) 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 From 7b5f878886400232740cef073857138cb66edd45 Mon Sep 17 00:00:00 2001 From: theocrite Date: Wed, 24 Oct 2012 14:48:06 +0300 Subject: [PATCH 60/73] Adding a html5 snippet This html5 snippet would provide the minimum someone could expect in a html5 file. --- snippets/html.snippets | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/snippets/html.snippets b/snippets/html.snippets index 43ad84b..0f75efd 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -445,6 +445,18 @@ snippet xhtml ${1} +snippet html5 + + + + + ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} + ${2:meta} + + + ${3:body} + + snippet i ${1} snippet iframe From 699250051db16be18285bc190fa990a69dfd60cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Sun, 28 Oct 2012 02:07:13 -0400 Subject: [PATCH 61/73] Added descriptions for duplicated snippet names. This is to make the snippets a little more compatible with neosnippets. --- snippets/actionscript.snippets | 2 +- snippets/ruby.snippets | 4 ++-- snippets/xslt.snippets | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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/ruby.snippets b/snippets/ruby.snippets index 63ec178..0500aaa 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -26,7 +26,7 @@ snippet beg rescue ${1:Exception} => ${2:e} end -snippet req +snippet req require require "${1}"${2} snippet # # => @@ -575,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} diff --git a/snippets/xslt.snippets b/snippets/xslt.snippets index 892e9db..e7abdf3 100644 --- a/snippets/xslt.snippets +++ b/snippets/xslt.snippets @@ -8,7 +8,7 @@ snippet apply-templates sort-by ${5}
${6} -snippet apply-templates +snippet apply-templates plain ${2} snippet attribute blank From 9a63deb18a0886ae9547feb1f820404698e29558 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Sat, 3 Nov 2012 12:03:52 +0100 Subject: [PATCH 62/73] Use "# TODO: write code..." as code placeholder in Python snippets (#34) --- snippets/python.snippets | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/snippets/python.snippets b/snippets/python.snippets index b3b1e9b..7f58d98 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,12 @@ 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} From 4f236166c37a997f07d981bea9f1ab8dc3a795ad Mon Sep 17 00:00:00 2001 From: gk Date: Sat, 3 Nov 2012 15:52:52 +0400 Subject: [PATCH 63/73] fix for WTFPL --- snippets/_.snippets | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/snippets/_.snippets b/snippets/_.snippets index 826ec9e..d553449 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -227,14 +227,14 @@ snippet BEERWARE ${4} snippet WTFPL - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 -Copyright `strftime("%Y")` ${1:copyright holder} + 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. + 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 + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION From 8ee1805a66d9ed4ab2c49a49e5d0664b722ce4b1 Mon Sep 17 00:00:00 2001 From: Jean Jordaan Date: Sun, 11 Nov 2012 16:24:36 +0700 Subject: [PATCH 64/73] Make the default text for RST more descriptive. --- snippets/rst.snippets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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:=} From e7d5824daa242de5753feedee49ac1de712e7ca4 Mon Sep 17 00:00:00 2001 From: raydeal Date: Thu, 22 Nov 2012 22:25:28 +0100 Subject: [PATCH 65/73] add yii snippets --- snippets/yii-chtml.snippets | 248 +++++++++++++++++++++++++++++ snippets/yii.snippets | 300 ++++++++++++++++++++++++++++++++++++ 2 files changed, 548 insertions(+) create mode 100644 snippets/yii-chtml.snippets create mode 100644 snippets/yii.snippets 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} + } + + From e845b783d3b62b1c2cd8525b5317adaa7917d74a Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Sun, 25 Nov 2012 19:10:03 +0000 Subject: [PATCH 66/73] Add ledger snippet --- snippets/ledger.snippets | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 snippets/ledger.snippets 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} From ad850f303bb1d50ed8520a7b6b47e452e641c180 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 3 May 2012 00:12:10 +0200 Subject: [PATCH 67/73] add guard to the . python implementation --- snippets/python.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index 7f58d98..3a88b08 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -76,6 +76,7 @@ snippet cascii snippet ld ${1:var} = lambda ${2:vars} : ${3:action} snippet . +guard left =~ '^\s*$' self. snippet try Try/Except try: From 0522e91741f84a9a61e2af65e24c30d8004799ae Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 29 Nov 2012 11:33:15 +0100 Subject: [PATCH 68/73] reference neosnippet --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f1f8bac..17f1486 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,21 @@ 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 it appears that [Shougo's neosnippet][5] has a compatible mode allowing +to reuse most 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 +33,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 +52,4 @@ 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 From b68e7544b6775a347b16037925f103cf86c2dd3d Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Sun, 2 Dec 2012 10:00:34 +0100 Subject: [PATCH 69/73] referencing issue asking for a merge with UltiSnips --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 17f1486..90c682b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +IMPORTANT: comment on: [What about merging whith Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114) + Snipmate Snippets ================= From 373516590e69646a4c3190502c960119da70d0bc Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Mon, 3 Dec 2012 09:39:21 +0100 Subject: [PATCH 70/73] Revert "add guard to the . python implementation" reason: causes syntax problems to some people, and there may be bigger changes due to evaluating merging with ultisnips anyway. This reverts commit ad850f303bb1d50ed8520a7b6b47e452e641c180. --- snippets/python.snippets | 1 - 1 file changed, 1 deletion(-) diff --git a/snippets/python.snippets b/snippets/python.snippets index 3a88b08..7f58d98 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -76,7 +76,6 @@ snippet cascii snippet ld ${1:var} = lambda ${2:vars} : ${3:action} snippet . -guard left =~ '^\s*$' self. snippet try Try/Except try: From fe3b2d61ca0e9a611ef8986f97723160c9e657dc Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 7 Dec 2012 09:55:14 +0100 Subject: [PATCH 71/73] drop dependency snipmate, cause there are two engines which can use this pool of snippets now --- README.md | 15 +++++++++++++-- addon-info.json | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 90c682b..f08b6f2 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,18 @@ Snipmate Snippets This repository contains snippets files for various programming languages. It was originally written for the the famous [snipMate][1] plugin for vim. -However it appears that [Shougo's neosnippet][5] has a compatible mode allowing -to reuse most snippets. +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 @@ -55,3 +65,4 @@ terms of the MIT license. [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" } From 1e6bafdca28ab4d335e28643b40951765f6bc9e6 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 7 Dec 2012 10:02:28 +0100 Subject: [PATCH 72/73] need nls? --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f08b6f2..a242eca 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,10 @@ 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. From fabf19a0e309cf67601e662ec2a7bf4b1d28fad9 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 7 Dec 2012 09:11:55 -0500 Subject: [PATCH 73/73] Add code for getopt in C, python, and BASH --- snippets/c.snippets | 57 ++++++++++++++++++++++++++++++++++++++++ snippets/python.snippets | 17 ++++++++++++ snippets/sh.snippets | 40 ++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/snippets/c.snippets b/snippets/c.snippets index 72ce3d0..c476de4 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -150,6 +150,63 @@ snippet pr # 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 diff --git a/snippets/python.snippets b/snippets/python.snippets index 7f58d98..dd2e812 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -139,3 +139,20 @@ snippet testcase ${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/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)) +