Merge branch 'master' into my-js-snippets

This commit is contained in:
Gui Lin 2013-03-06 12:18:16 +08:00
commit 849d541bc8
30 changed files with 1842 additions and 246 deletions

View File

@ -1,3 +1,4 @@
Aaron Broder
Adam Folmert
Alberto Pose
Angel Alonso
@ -36,3 +37,4 @@ Povilas Balzaravičius Pawka
Dmitry Dementev
Travis Holton
Chrisyue
Erik Westrup

View File

@ -1,15 +1,35 @@
IMPORTANT: comment on: [What about merging whith Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114)
Snipmate Snippets
=================
This repository contains snippets files for various programming languages for
the famous [snipMate][1] plugin for vim. This repository is
community-maintained and many people have contributed snippet files and other
improvements already.
This repository contains snippets files for various programming languages.
It was originally written for the the famous [snipMate][1] plugin for vim.
However today there are at least 3 plugins which can make use of this snippet repository:
1) [snipMate][1]
2) [Shougo's neosnippet][5] has a compatible mode allowing
to reuse most snippets.
3) [ultisnip][6] (stable enough to be used, branch master previously snipmate-merge)
This code is subject to change. Take it as preview. That branch
has additional notes for Snipmate users. at the bottom.
In the long run ultisnip will have its own set of snippets, because it is
more powerful cause it supports nested snippets.
It is community-maintained and many people have contributed snippet files and other
improvements already. Not sure whether it implements all features such as
guards - does anybody know?
[vim-snipmate][1] was originally started by [Michael Sanders][2] who has now
unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a
[fork][4] of the project in hopes of improving the existing code base.
Language maintainers
--------------------
@ -27,7 +47,8 @@ Contributing notes
------------------
Until further work is done on `vim-snipmate`, please don't add folding markers
into snippets.
into snippets. `vim-snipmate` has some comments about how to patch all snippets
on the fly adding those.
Authors
-------
@ -45,3 +66,5 @@ terms of the MIT license.
[2]: http://github.com/msanders
[3]: http://github.com/garbas
[4]: http://github.com/garbas/vim-snipmate
[5]: https://github.com/Shougo/neosnippet
[6]: https://github.com/MarcWeber/UltiSnips/tree/snipmate-merge

View File

@ -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"
}

View File

@ -216,12 +216,25 @@ snippet APACHE
${3}
snippet BEERWARE
${1:one line to give the program's name and a brief description}
Copyright `strftime("%Y")` ${2:copyright holder}
${2:one line to give the program's name and a brief description}
Copyright `strftime("%Y")` ${3:copyright holder}
Licensed under the "THE BEER-WARE LICENSE" (Revision 42):
${1:`g:snips_author`} wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer or coffee in return
${3}
${4}
snippet WTFPL
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright `strftime("%Y")` ${1:copyright holder}
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

View File

@ -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 */}
}

View File

@ -1,38 +1,45 @@
# main()
## Main
# main
snippet main
int main(int argc, const char *argv[])
{
${1}
return 0;
}
# main(void)
snippet mainn
int main(void)
{
${1}
return 0;
}
##
## Preprocessor
# #include <...>
snippet inc
#include <${1:stdio}.h>${2}
# #include "..."
snippet Inc
#include "${1:`Filename("$1.h")`}"${2}
# #ifndef ... #define ... #endif
snippet Def
# ifndef...define...endif
snippet ndef
#ifndef $1
#define ${1:SYMBOL} ${2:value}
#endif${3}
# define
snippet def
#define
# ifdef...endif
snippet ifdef
#ifdef ${1:FOO}
${2:#define }
#endif
#endif${3}
# if
snippet #if
#if ${1:FOO}
${2}
#endif
# Header Include-Guard
# header include guard
snippet once
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
@ -41,73 +48,167 @@ snippet once
${2}
#endif /* end of include guard: $1 */
# If Condition
##
## Control Statements
# if
snippet if
if (${1:/* condition */}) {
${2:/* code */}
}
}${3}
# else
snippet el
else {
${1}
}
# Ternary conditional
}${3}
# else if
snippet elif
else if (${1:/* condition */}) {
${2:/* code */}
}${3}
# ternary
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}
# Do While Loop
snippet do
do {
${2:/* code */}
} while (${1:/* condition */});
# While Loop
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
}
# For Loop
# switch
snippet switch
switch (${1:/* variable */}) {
case ${2:/* variable case */}:
${3}
${4:break;}${5}
default:
${6}
}${7}
# switch without default
snippet switchndef
switch (${1:/* variable */}) {
case ${2:/* variable case */}:
${3}
${4:break;}${5}
}${6}
# case
snippet case
case ${1:/* variable case */}:
${2}
${3:break;}${4}
##
## Loops
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
}
# Custom For Loop
}${5}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */}
}
# Function
}${6}
# while
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
}${3}
# do... while
snippet do
do {
${2:/* code */}
} while (${1:/* condition */});${3}
##
## Functions
# function definition
snippet fun
${1:void} ${2:function_name}(${3})
{
${4:/* code */}
}
# Function Declaration
}${5}
# function declaration
snippet fund
${1:void} ${2:function_name}(${3});${4}
# Typedef
##
## Types
# typedef
snippet td
typedef ${1:int} ${2:MyCustomType};${3}
# Struct
# struct
snippet st
struct ${1:`Filename('$1_t', 'name')`} {
${2:/* data */}
}${3: /* optional variable list */};${4}
# Typedef struct
# typedef struct
snippet tds
typedef struct ${2:_$1 }{
${3:/* data */}
} ${1:`Filename('$1_t', 'name')`};
# Typdef enum
} ${1:`Filename('$1_t', 'name')`};${4}
# typedef enum
snippet tde
typedef enum {
${1:/* data */}
} ${2:foo};
} ${2:foo};${3}
##
## Input/Output
# printf
# unfortunately version this isn't as nice as TextMates's, given the lack of a
# dynamic `...`
snippet pr
printf("${1:%s}\n"${2});${3}
# fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
# getopt
snippet getopt
int choice;
while (1)
{
static struct option long_options[] =
{
/* Use flags like so:
{"verbose", no_argument, &verbose_flag, 'V'}*/
/* Argument styles: no_argument, required_argument, optional_argument */
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
${1}
{0,0,0,0}
};
int option_index = 0;
/* Argument parameters:
no_argument: " "
required_argument: ":"
optional_argument: "::" */
choice = getopt_long( argc, argv, "vh",
long_options, &option_index);
if (choice == -1)
break;
switch( choice )
{
case 'v':
${2}
break;
case 'h':
${3}
break;
case '?':
/* getopt_long will have already printed an error */
break;
default:
/* Not sure how to get here... */
return EXIT_FAILURE;
}
}
/* Deal with non-option arguments here */
if ( optind < argc )
{
while ( optind < argc )
{
${4}
}
}
##
## Miscellaneous
# This is kind of convenient
snippet .
[${1}]${2}

View File

@ -1,3 +1,8 @@
# Closure loop
snippet forindo
for ${1:name} in ${2:array}
do ($1) ->
${3:// body}
# Array comprehension
snippet fora
for ${1:name} in ${2:array}
@ -85,3 +90,6 @@ snippet try
# Require
snippet req
${2:$1} = require '${1:sys}'${3}
# Export
snippet exp
${1:root} = exports ? this

View File

@ -1,29 +1,73 @@
# Read File Into Vector
snippet readfile
std::vector<char> v;
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
char buf[1024];
while (size_t len = fread(buf, 1, sizeof(buf), $2))
v.insert(v.end(), buf, buf + len);
fclose($2);
}${3}
# std::map
snippet map
std::map<${1:key}, ${2:value}> ${3};
## STL Collections
# std::array
snippet array
std::array<${1:T}, ${2:N}> ${3};${4}
# std::vector
snippet vector
std::vector<${1:char}> ${2};
# Namespace
snippet ns
namespace ${1:`Filename('', 'my')`} {
${2}
} /* namespace $1 */
# Class
snippet class
std::vector<${1:T}> ${2};${3}
# std::deque
snippet deque
std::deque<${1:T}> ${2};${3}
# std::forward_list
snippet flist
std::forward_list<${1:T}> ${2};${3}
# std::list
snippet list
std::list<${1:T}> ${2};${3}
# std::set
snippet set
std::set<${1:T}> ${2};${3}
# std::map
snippet map
std::map<${1:Key}, ${2:T}> ${3};${4}
# std::multiset
snippet mset
std::multiset<${1:T}> ${2};${3}
# std::multimap
snippet mmap
std::multimap<${1:Key}, ${2:T}> ${3};${4}
# std::unordered_set
snippet uset
std::unordered_set<${1:T}> ${2};${3}
# std::unordered_map
snippet umap
std::unordered_map<${1:Key}, ${2:T}> ${3};${4}
# std::unordered_multiset
snippet umset
std::unordered_multiset<${1:T}> ${2};${3}
# std::unordered_multimap
snippet ummap
std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4}
# std::stack
snippet stack
std::stack<${1:T}> ${2};${3}
# std::queue
snippet queue
std::queue<${1:T}> ${2};${3}
# std::priority_queue
snippet pqueue
std::priority_queue<${1:T}> ${2};${3}
##
## Access Modifiers
# private
snippet pri
private
# protected
snippet pro
protected
# public
snippet pub
public
# friend
snippet fr
friend
# mutable
snippet mu
mutable
##
## Class
# class
snippet cl
class ${1:`Filename('$1', 'name')`}
{
public:
@ -33,34 +77,55 @@ snippet class
private:
${3:/* data */}
};
# member function implementation
snippet mfun
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5:/* code */}
}
# namespace
snippet ns
namespace ${1:`Filename('', 'my')`} {
${2}
} /* namespace $1 */
##
## Input/Output
# std::cout
snippet cout
std::cout << ${1} << std::endl;${2}
# std::cin
snippet cin
std::cin >> ${1};${2}
##
## Iteration
# for i
snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
}
}${5}
# foreach
snippet fore
for (${1:auto} ${2:i} : ${3:container}) {
${4:/* code */}
}${5}
# iterator
snippet iter
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
${6}
}${7}
# auto iterator
snippet itera
for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {
${2:std::cout << *$1 << std::endl;}
}
# iterator
snippet iter
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
${6}
}
# member function implementations
snippet mfun
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5:return};
}
snippet scout
std::cout << ${1} << std::endl;
snippet cout
cout << ${1} << endl;
snippet scin
std::cin >> ${1};
snippet cin
cin >> ${1};
}${3}
##
## Lambdas
# lamda (one line)
snippet ld
[${1}](${2}){${3:/* code */}}${4}
# lambda (multi-line)
snippet lld
[${1}](${2}){
${3:/* code */}
}${4}

View File

@ -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

View File

@ -67,7 +67,7 @@ snippet i
snippet im
import (
"${1:package}"
)
)${2}
# interface
snippet in
interface{}
@ -80,12 +80,12 @@ snippet inf
snippet if
if ${1:/* condition */} {
${2:/* code */}
}
}${2}
# else snippet
snippet el
else {
${1}
}
}${2}
# error snippet
snippet ir
if err != nil {
@ -114,26 +114,37 @@ snippet ie
} else {
${3}
}
${4}
# for loop
snippet fo
for ${2:i} = 0; $2 < ${1:count}; $2${3:++} {
${4:/* code */}
}
${5}
# for range loop
snippet fr
for ${1:k}, ${2:v} := range ${3} {
${4:/* code */}
}
${5}
# function simple
snippet fun
func ${1:funcName}(${2}) ${3:os.Error} {
func ${1:funcName}(${2}) ${3:error} {
${4:/* code */}
}
${5}
# function on receiver
snippet fum
func (self ${1:type}) ${2:funcName}(${3}) ${4:os.Error} {
func (self ${1:type}) ${2:funcName}(${3}) ${4:error} {
${5:/* code */}
}
${6}
# log printf
snippet lf
log.Printf("%${1:s}", ${2:var})${3}
# log printf
snippet lp
log.Println("${1}")${2}
# make
snippet mk
make(${1:[]string}, ${2:0})
@ -145,6 +156,7 @@ snippet main
func main() {
${1:/* code */}
}
${2}
# new
snippet nw
new(${1:type})
@ -153,7 +165,7 @@ snippet pn
panic("${1:msg}")
# print
snippet pr
fmt.Printf("${1:%s}\n", ${2:var})${3}
fmt.Printf("%${1:s}\n", ${2:var})${3}
# range
snippet rn
range ${1}
@ -180,7 +192,8 @@ snippet sr
snippet st
struct ${1:name} {
${2:/* data */}
}${4}
}
${3}
# switch
snippet sw
switch ${1:var} {
@ -192,7 +205,7 @@ snippet sw
${6:/* code */}
}
snippet sp
fmt.Sprintf("${1:%s}", ${2:var})${3}
fmt.Sprintf("%${1:s}", ${2:var})${3}
# true
snippet t
true

View File

@ -353,11 +353,11 @@ snippet footer
${1}
</footer>
snippet footer.
<footer class="${1}>
<footer class="${1}">
${2}
</footer>
snippet footer#
<footer id="${1}>
<footer id="${1}">
${2}
</footer>
snippet form
@ -445,6 +445,18 @@ snippet xhtml
<html xmlns="http://www.w3.org/1999/xhtml">
${1}
</html>
snippet html5
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2:meta}
</head>
<body>
${3:body}
</body>
</html>
snippet i
<i>${1}</i>
snippet iframe
@ -544,7 +556,7 @@ snippet link
snippet link:atom
<link rel="alternate" href="${1:atom.xml}" title="Atom" type="application/atom+xml" />${2}
snippet link:css
<link rel="stylesheet" href="${2:style.css}" type="text/css" media="${3:all}" />${4}
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />${3}
snippet link:favicon
<link rel="shortcut icon" href="${1:favicon.ico}" type="image/x-icon" />${2}
snippet link:rss
@ -777,7 +789,7 @@ snippet thead
${1}
</thead>
snippet time
<time datetime="${1}" pubdate="${2:$1}>${3:$1}</time>
<time datetime="${1}" pubdate="${2:$1}">${3:$1}</time>
snippet title
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
snippet tr

View File

@ -50,6 +50,9 @@ snippet if
snippet else
{% else %}
${1}
snippet elif
{% elif ${1} %}
${2}
snippet ifchanged
{% ifchanged %}${1}{% endifchanged %}
snippet ifequal
@ -80,6 +83,8 @@ snippet widthratio
{% widthratio ${1:this_value} ${2:max_value} ${3:100} %}
snippet with
{% with ${1} as ${2} %}
${3}
{% endwith %}
# Template Filters

View File

@ -140,7 +140,7 @@ snippet /**
* ${1}
*/
snippet @au
@author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")`
@author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5 | cut -d \",\" -f1")`
snippet @br
@brief ${1:Description}
snippet @fi
@ -176,9 +176,9 @@ snippet main
##
## Print Methods
snippet print
System.out.print("${1:Message");
System.out.print("${1:Message}");
snippet printf
System.out.printf("${1:Message", ${2:args});
System.out.printf("${1:Message}", ${2:args});
snippet println
System.out.println(${1});
##

View File

@ -11,12 +11,12 @@ snippet fun
}
# Anonymous Function
snippet f
function(${1}) {
function (${1}) {
${3}
}${2:;}
# Immediate function
snippet (f
(function(${1}) {
(function (${1}) {
${3:/* code */}
}(${2}));
# if
@ -32,11 +32,11 @@ snippet ife
${3}
}
# tertiary conditional
snippet t
snippet ter
${1:/* condition */} ? ${2:a} : ${3:b}
# switch
snippet switch
switch(${1:expression}) {
switch (${1:expression}) {
case '${3:case}':
${4:// code}
break;
@ -69,7 +69,7 @@ snippet wh
snippet try
try {
${1:/* code */}
} catch(${2:e}) {
} catch (${2:e}) {
${3:/* handle error */}
}
# do...while
@ -79,12 +79,12 @@ snippet do
} while (${1:/* condition */});
# Object Method
snippet :f
${1:method_name}: function(${2:attribute}) {
${1:method_name}: function (${2:attribute}) {
${4}
}${3:,}
# setTimeout function
snippet timeout
setTimeout(function() {${3}}${2}, ${1:10});
setTimeout(function () {${3}}${2}, ${1:10});
# Get Elements
snippet get
getElementsBy${1:TagName}('${2}')${3}

View File

@ -0,0 +1 @@
javascript-jquery.snippets

5
snippets/ledger.snippets Normal file
View File

@ -0,0 +1,5 @@
# Ledger <http://ledger-cli.org/>
snippet ent
`strftime("%Y/%m/%d")` ${1:transaction}
${2:account} ${3:value}
${4:account}

View File

@ -79,48 +79,54 @@ snippet for
snippet fore
${1:expression} foreach @${2:array};${3}
# Package
snippet cl
package ${1:ClassName};
snippet package
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`};
use base qw(${2:ParentClass});
${2}
sub new {
my $class = shift;
$class = ref $class if ref $class;
my $self = bless {}, $class;
$self;
}
1;
1;${3}
__END__
# Package syntax perl >= 5.14
snippet packagev514
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
${3}
1;
__END__
#moose
snippet moose
use Moose;
use namespace::autoclean;
${1:#}BEGIN {extends '${2:ParentClass}'};
${3}
# parent
snippet parent
use parent qw(${1:Parent Class});
# Read File
snippet slurp
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
${3}
# strict warnings
snippet strwar
use strict;
use warnings;
# standard versioning with perlcritic bypass
# older versioning with perlcritic bypass
snippet vers
## no critic
our $VERSION = '${1:version}';
eval $VERSION;
## use critic
# new 'switch' like feature
snippet switch
use feature 'switch';
# Anonymous subroutine
snippet asub
sub {
sub {
${1:# body }
}
@ -133,19 +139,19 @@ snippet begin
}
# call package function with some parameter
snippet pkgmv
snippet pkgmv
__PACKAGE__->${1:package_method}(${2:var})
# call package function without a parameter
snippet pkgm
snippet pkgm
__PACKAGE__->${1:package_method}()
# call package "get_" function without a parameter
snippet pkget
snippet pkget
__PACKAGE__->get_${1:package_method}()
# call package function with a parameter
snippet pkgetv
snippet pkgetv
__PACKAGE__->get_${1:package_method}(${2:var})
# complex regex
@ -160,10 +166,10 @@ snippet qr/
#given
snippet given
given ($${1:var}) {
given ($${1:var}) {
${2:# cases}
${3:# default}
}
}
# switch-like case
snippet when
@ -176,7 +182,6 @@ snippet hslice
@{ ${1:hash} }{ ${2:array} }
# map
snippet map
map { ${2: body } } ${1: @array } ;
@ -190,7 +195,7 @@ snippet ppod
${1:ClassName} - ${2:ShortDesc}
=head1 SYNOPSIS
use $1;
${3:# synopsis...}
@ -202,7 +207,7 @@ snippet ppod
=head1 INTERFACE
=head1 DEPENDENCIES
@ -223,8 +228,17 @@ snippet psubi
=cut
# inline documented subroutine
snippet subpod
=head2 $1
Summary of $1
=cut
sub ${1:subroutine_name} {
${2:# body...}
}
# Subroutine signature
snippet parg
=over 2
@ -232,7 +246,7 @@ snippet parg
=item
Arguments
=over 3
=item
@ -255,47 +269,21 @@ snippet parg
=back
=back
# Moose package
snippet moosecl
package ${1:ClassName};
use Moose;
#extends '${2:# ParentClass}';
${6:# body of class}
1;
__END__
=head1 NAME
$1 - ${3:ShortDesc}
=head1 SYNOPSIS
${4:# synopsis...}
=head1 DESCRIPTION
${5:# longer description...}
# Moose has
snippet has
has ${1:attribute} => (
is => '${2:ro|rw}',
is => '${2:ro|rw}',
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
default => ${4:defaultvalue}
,${5:# other attributes}
default => sub {
${4:defaultvalue}
},
${5:# other attributes}
);
@ -303,14 +291,14 @@ snippet has
snippet override
override ${1:attribute} => sub {
${2:# my $self = shift;};
${3:# my ($self,$args) = @_;};
${3:# my ($self, $args) = @_;};
};
# use test classes
snippet tuse
use Test::More;
use Test::Deep ();
use Test::Deep; # (); # uncomment to stop prototype errors
use Test::Exception;
# local test lib
@ -331,7 +319,7 @@ snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift;
${4:# body}
}
# Test::Routine-style test
@ -347,6 +335,7 @@ snippet tprep
my $self = shift;
${4:# body}
}
# cause failures to print stack trace
snippet debug_trace
use Carp; # 'verbose';

View File

@ -39,23 +39,30 @@ snippet m
${7}
}
# setter method
# I think vim's functions will not be called at the snipMate's runtime
# but `compile` time
# so `tolower` here won't work
# but it would be wonderful if we could make the property and parameter to lower case
snippet sm
${1:public} function set${2:Foo}(${3:$2 }$${4:`tolower('$2')`})
/**
* Sets the value of ${1:foo}
*
* @param ${2:$1} $$1 ${3:description}
*
* @return ${4:`Filename()`}
*/
${5:public} function set${6:$2}(${7:$2 }$$1)
{
$this->${5:$4} = $$4;
${6}
$this->${8:$1} = $$1;
return $this;
}
}${9}
# getter method
snippet gm
${1:public} function get${2:Foo}()
/**
* Gets the value of ${1:foo}
*
* @return ${2:$1}
*/
${3:public} function get${4:$2}()
{
return $this->${3:$2};
}
return $this->${5:$1};
}${6}
#setter
snippet $s
${1:$foo}->set${2:Bar}(${3});
@ -195,7 +202,7 @@ snippet interface
* @package ${3:default}
* @author ${4:`g:snips_author`}
*/
interface ${1:}
interface ${1:`Filename()`}
{
${5}
}
@ -204,7 +211,7 @@ snippet class
/**
* ${1}
*/
class ${2:ClassName}
class ${2:`Filename()`}
{
${3}
/**
@ -322,25 +329,46 @@ snippet http_redirect
header ("Location: ".URL);
exit();
# Getters & Setters
snippet getset
snippet gs
/**
* Gets the value of ${1:}
* Gets the value of ${1:foo}
*
* @return ${2}
* @return ${2:$1}
*/
public function get$1()
public function get${3:$2}()
{
return $this->$1;
return $this->${4:$1};
}
/**
* Sets the value of $1
*
* @param mixed $$1 ${3}
* @param $2 $$1 ${5:description}
*
* @return ${6:`Filename()`}
*/
public function set$1($$1)
public function set$3(${7:$2 }$$1)
{
$this->$1 = $$1;
$this->$4 = $$1;
return $this;
}${8}
# anotation, get, and set, useful for doctrine
snippet ags
/**
* ${1:description}
*
* @${7}
*/
${2:protected} $${3:foo};
public function get${4:$3}()
{
return $this->$3;
}
public function set$4(${5:$4 }$${6:$3})
{
$this->$3 = $$6;
return $this;
}
snippet rett

109
snippets/plsql.snippets Normal file
View File

@ -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;

View File

@ -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}():
@ -51,20 +51,24 @@ snippet property
${3:return self._$1}
def fset(self, value):
${4:self._$1 = value}
def fdel(self):
${5:del self._$1}
return locals()
$1 = property(**$1())
# 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 +83,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 +134,29 @@ snippet "
# test function/method
snippet test
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
${3:pass}
${3:# TODO: write code...}
# test case
snippet testcase
class ${1:ExampleCase}(unittest.TestCase):
def test_${2:description}(self):
${3:pass}
${3:# TODO: write code...}
snippet fut
from __future__ import ${1}
#getopt
snippet getopt
try:
# Short option syntax: "hv:"
# Long option syntax: "help" or "verbose="
opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])
except getopt.GetoptError, err:
# Print debug info
print str(err)
${3:error_action}
for option, argument in opts:
if option in ("-h", "--help"):
${4}
elif option in ("-v", "--verbose"):
verbose = argument

121
snippets/r.snippets Normal file
View File

@ -0,0 +1,121 @@
snippet #!
#!/usr/bin/env Rscript
# includes
snippet lib
library(${1:package})
snippet req
require(${1:package})
snippet source
source('${1:file}')
# conditionals
snippet if
if (${1:condition}) {
${2:code}
}
snippet el
else {
${1:code}
}
snippet ei
else if (${1:condition}) {
${2:code}
}
# functions
snippet fun
${1:name} = function (${2:variables}) {
${3:code}
}
snippet ret
return(${1:code})
# dataframes, lists, etc
snippet df
${1:name}[${2:rows}, ${3:cols}]
snippet c
c(${1:items})
snippet li
list(${1:items})
snippet mat
matrix(${1:data}, nrow=${2:rows}, ncol=${3:cols})
# apply functions
snippet apply
apply(${1:array}, ${2:margin}, ${3:function})
snippet lapply
lapply(${1:list}, ${2:function})
snippet sapply
lapply(${1:list}, ${2:function})
snippet vapply
vapply(${1:list}, ${2:function}, ${3:type})
snippet mapply
mapply(${1:function}, ${2:...})
snippet tapply
tapply(${1:vector}, ${2:index}, ${3:function})
snippet rapply
rapply(${1:list}, ${2:function})
# plyr functions
snippet dd
ddply(${1:frame}, ${2:variables}, ${3:function})
snippet dl
dlply(${1:frame}, ${2:variables}, ${3:function})
snippet da
daply(${1:frame}, ${2:variables}, ${3:function})
snippet d_
d_ply(${1:frame}, ${2:variables}, ${3:function})
snippet ad
adply(${1:array}, ${2:margin}, ${3:function})
snippet al
alply(${1:array}, ${2:margin}, ${3:function})
snippet aa
aaply(${1:array}, ${2:margin}, ${3:function})
snippet a_
a_ply(${1:array}, ${2:margin}, ${3:function})
snippet ld
ldply(${1:list}, ${2:function})
snippet ll
llply(${1:list}, ${2:function})
snippet la
laply(${1:list}, ${2:function})
snippet l_
l_ply(${1:list}, ${2:function})
snippet md
mdply(${1:matrix}, ${2:function})
snippet ml
mlply(${1:matrix}, ${2:function})
snippet ma
maply(${1:matrix}, ${2:function})
snippet m_
m_ply(${1:matrix}, ${2:function})
# plot functions
snippet pl
plot(${1:x}, ${2:y})
snippet ggp
ggplot(${1:data}, aes(${2:aesthetics}))
snippet img
${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}")
${6:plot}
dev.off()
# statistical test functions
snippet fis
fisher.test(${1:x}, ${2:y})
snippet chi
chisq.test(${1:x}, ${2:y})
snippet tt
t.test(${1:x}, ${2:y})
snippet wil
wilcox.test(${1:x}, ${2:y})
snippet cor
cor.test(${1:x}, ${2:y})
snippet fte
var.test(${1:x}, ${2:y})
snippet kvt
kv.test(${1:x}, ${2:y})

View File

@ -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:=}

View File

@ -2,6 +2,10 @@
# Ruby snippets - for Rails, see below #
########################################
# encoding for Ruby 1.9
snippet enc
# encoding: utf-8
# #!/usr/bin/env ruby
snippet #!
#!/usr/bin/env ruby
@ -22,7 +26,7 @@ snippet beg
rescue ${1:Exception} => ${2:e}
end
snippet req
snippet req require
require "${1}"${2}
snippet #
# =>
@ -282,9 +286,15 @@ snippet eavd
snippet eawi
each_with_index { |${1:e}, ${2:i}| ${3} }
snippet eawid
each_with_index do |${1:e},${2:i}|
each_with_index do |${1:e}, ${2:i}|
${3}
end
snippet eawo
each_with_object(${1:init}) { |${2:e}, ${3:var}| ${4} }
snippet eawod
each_with_object(${1:init}) do |${2:e}, ${3:var}|
${4}
end
snippet reve
reverse_each { |${1:e}| ${2} }
snippet reved
@ -390,7 +400,7 @@ snippet :
snippet ope
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
# path_from_here()
snippet patfh
snippet fpath
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
# unix_filter {}
snippet unif
@ -571,7 +581,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}
@ -650,6 +660,10 @@ snippet defupdate
end
end
end${3}
snippet dele delegate .. to
delegate :${1:methods}, :to => :${2:object}
snippet dele delegate .. to .. prefix .. allow_nil
delegate :${1:methods}, :to => :${2:object}, :prefix => :${3:prefix}, :allow_nil => ${4:allow_nil}
snippet flash
flash[:${1:notice}] = "${2}"
snippet habtm
@ -865,7 +879,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}
@ -907,6 +920,8 @@ snippet it
snippet itp
it "${1:spec_name}"
${2}
snippet its
its(:${1:method}) { should ${2} }
snippet desc
describe ${1:class_name} do
${2}
@ -923,3 +938,19 @@ snippet aft
after :${1:each} do
${2}
end
snippet let
let(:${1:method}) { ${2} }
snippet subj
subject { ${1} }
snippet spec
specify { subject.${1} }
snippet exp
expect(${1:object}).to ${2}
snippet btr
be_true
snippet bfa
be_false
snippet shared
shared_examples "${1:shared examples name}" ${2}
snippet itb
it_behaves_like "${1:shared examples name}"${2}

349
snippets/scala.snippets Normal file
View File

@ -0,0 +1,349 @@
################################################################
# © Copyright 2011 Konstantin Gorodinskiy. All Rights Reserved.#
# Do What The Fuck You Want To Public License, Version 2. #
# See http://sam.zoy.org/wtfpl/COPYING for more details. #
################################################################
# Scala lang
#if
snippet if
if(${1:obj}) {
${2:/* code */}
}
#if not
snippet ifn
if(!${1:obj}) {
${2:/* code */}
}
#if-else
snippet ifel
if(${1:obj}) {
${2:/* code */}
} else {
${3:/* code */}
}
#if-else-if
snippet ifelif
if(${1:obj}) {
${2:/* code */}
} else if(${3:obj}) {
${4:/* code */}
}
#while loop
snippet while
while (${1:obj}) {
${2:/* code */}
}
#for loop(classic)
snippet for
for (${1:item} <- ${2:obj}) {
${3:/* code */}
}
#for loop(indexed)
snippet fori
for (${1:i} <- ${2:0} to ${3:obj}.length) {
${4:/* code */}
}
#exceptions
snippet try
try {
${1:/* code */}
} catch {
case e: FileNotFoundException => ${2:/* code */}
case e: IOException => ${3:/* code */}
} finally {
${4:/* code */}
}
#match
snippet match
${1: obj} match {
case ${2:e} => ${3:/* code */}
case _ => ${4:/* code */}
}
#case
snippet case
case ${1:value} => ${2:/* code */}
############################
# methods and arguments
#
#arg
snippet arg
${1:a}: ${2:T}${3:, arg}
#args
snippet args
${1:args}: ${2:T}*
#def
snippet def
def ${1:name}(${2:arg}) = ${3:}
#private def
snippet prdef
private def ${1:name}(${2:arg}) = ${3:}
#override def
snippet ovdef
override def ${1:name}(${2:arg}) = ${3:}
#first class function(see scalabook p 188)
snippet fcf
(${1:a}: ${2:T}) => $1 ${3:/* code */}
snippet =>
${1:name} => ${2:/* code */}
#recursion
snippet rec
def ${1:name}(${2:arg}) =
if($2) $2
else $1($2)
#curried method
snippet crdef
def ${1:name}(${2:arg})(${3:arg}) = ${4:}
#main method
#check validity of T
snippet main
def main(args: Array[String]):${1:T} = ${2:}
############################
# basic types(general purpose)
# you might want to use basic types snippets
#1
snippet T Double
dbl
#2
snippet T Int
int
#3
snippet T Long
lng
#4
snippet T Char
chr
#5
snippet T String
str
#6
snippet T Array
arr
#7
snippet T Buffer
buf
#8
snippet T List
list
#9
snippet T Tuple
tpl
#10
snippet T Set
set
#11
snippet T Map
map
#12
snippet T HashSet
hset
#13
snippet T HashMap
hmap
#14
snippet T Boolean
bool
#end
#named snippets for types
snippet bool
Boolean
snippet anyr
AnyRef
snippet dbl
Double
snippet int
Int
snippet str
String
snippet chr
Char
snippet lng
Long
snippet arr
Array${1:[T]}${2:()}
snippet buf
Buffer${1:[T]}${2:()}
snippet list
List${1:[T]}${2:()}
snippet tpl
Tuple${1:2}[${2:T},${3:T}]
snippet set
Set${1:[T]}${2:()}
snippet hset
HashSet${1:[T]}${2:()}
snippet mhset
mutable.HashSet${1:[T]}${2:()}
#for maps
snippet keyval
${1:key}->${2:val}${3:, keyval}
snippet map
Map[${1:T},${2:T}]${3:(keyval)}
snippet hmap
HashMap[${1:T},${2:T}]${3:(keyval)}
snippet mmap
mutable.Map[${1:T},${2:T}]${3:(keyval)}
snippet mhmap
mutable.HashMap[${1:T},${2:T}]${3:(keyval)}
#TODO add TreeMap and TreeSet
#asInstanceOf[]
snippet as
${1:name}.asInstanceOf[${2:T}]
#isInstanceOf[]
${1:name}.isInstanceOf[${2:T}]
#end
#collections methods
#scope() with one arg
snippet (a
(${1:a} => ${2:/* code */})
#scope() with two args
snippet {(
{(${1:a},${2:b}) =>
${3:/* code */}
}
#filter
snippet filter
${1:name}.filter (a
#map function
snippet mapf
${1:name}.map (a
#flatmap
snippet flatmap
${1:name}.flatMap${2:[T]}(a
#fold left
snippet fldl
${1:name}.foldLeft(${2:first}) {(
#fold right
snippet fldr
${1:name}.foldRight(${2:first}) {(
#fold left operator(if u wanna reduce readability of ur code)
#use wildcard symbols
snippet /:
(${1:first}/:${2:name})(${3:/* code */})
#fold right operator
snippet :\
(${1:first}:\${2:name})(${3:/* code */})
#reduce left
snippet redl
${1:name}.reduceLeft[${2:T}] {(
#reduce right
snippet redr
${1:name}.reduceRight[${2:T}] {(
#zipWithIndex(safe way).
#see http://daily-scala.blogspot.com/2010/05/zipwithindex.html
snippet zipwi
${1:name}.view.zipWithIndex
#split
snippet spl
${1:name}.split("${2:,}")
#end
snippet val
val ${1:name}${2:: T} = ${3:value}
snippet var
var ${1:name}${2:: T} = ${3:value}
############################
# classes
#
#extends
snippet extends
extends ${1:what}
#with
snippet with
with ${1:what}${2: with}
#auxiliary constructor(a. this)
snippet athis
def this(arg) = this(arg)
#abstract class
snippet abstract
abstract class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"}
${6:/* code */}
}
#class
snippet class
class ${1:name}${2:(arg)}${3: extends }${4: with} {
${5:override def toString = "$1"}
${6:/* code */}
}
#object
snippet object
object ${1:name}${2:(arg)}${3: extends }${4: with} ${5:}
#trait
snippet trait
trait ${1:name}${2: extends }${3: with} {
${4:}
}
#class with trait Ordered(page 265)
snippet ordered
class ${1:name}${2:(arg)} extends Ordered[$1] ${3: with} {
${4:override def toString = "$1"}
def compare(that: $1) = ${5:this - that}
${6:/* code */}
}
#case class
snippet casecl
case class ${1:name}${2:(arg)}${3: extends }${4: with} ${5:}
############################
# testing
#
#scalatest imports
snippet scalatest
${1:import org.scalatest.Suite}
${2:import org.scalatest.FunSuite}
#assert
snippet assert
assert(${1:a}==${2:b})
#ensuring(p 296)
snippet ensuring
ifel ensuring(${1:a}==${2:b})
#expect
snippet expect
expect(${1:what}) {
#intercept
snippet intercept
intercept[${1:IllegalArgumentException}] {
#test
snippet test
test("${1:description}") {
#suite
snippet suite
class ${1:name} extends Suite {
def test() {
}
#funsuite
snippet fsuite
class ${1:name} extends FunSuite {
test("${2:description}") {
}
############################
# SBT
#
snippet webproject
import sbt._
class ${1:Name}(info: ProjectInfo) extends DefaultWebProject(info) {
val liftVersion = "${2:2.3}"
override def libraryDependencies = Set(
) ++ super.libraryDependencies
val snapshots = ScalaToolsSnapshots
}
#depencies
snippet liftjar
"net.liftweb" %% "${1:lib}" % liftVersion % "compile->default",
snippet jettyjar
"org.mortbay.jetty" % "jetty" % "${1:version}" % "test->default",
############################
# Lift
#
#lift imports
snippet liftimports
import _root_.net.liftweb.http._
import S._
import _root_.net.liftweb.util._
import Helpers._
import _root_.scala.xml._
#TODO LIFT,SBT,WEB.XML,HTML snippets

View File

@ -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))

26
snippets/sql.snippets Normal file
View File

@ -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}

View File

@ -1,5 +1,3 @@
# recomendation: change the fold marker from {{{,}}} to (fold),(end) ; tex uses "{" and "}" a lot
#PREAMBLE
#newcommand
snippet nc
@ -97,40 +95,34 @@ snippet part
% part $2 (end)
# Chapter
snippet cha
\chapter{${1:chapter name}} % (fold)
\chapter{${1:chapter name}}
\label{cha:${2:$1}}
${3}
% chapter $2 (end)
# Section
snippet sec
\section{${1:section name}} % (fold)
\section{${1:section name}}
\label{sec:${2:$1}}
${3}
% section $2 (end)
# Sub Section
snippet sub
\subsection{${1:subsection name}} % (fold)
\subsection{${1:subsection name}}
\label{sub:${2:$1}}
${3}
% subsection $2 (end)
# Sub Sub Section
snippet subs
\subsubsection{${1:subsubsection name}} % (fold)
\subsubsection{${1:subsubsection name}}
\label{ssub:${2:$1}}
${3}
% subsubsection $2 (end)
# Paragraph
snippet par
\paragraph{${1:paragraph name}} % (fold)
\paragraph{${1:paragraph name}}
\label{par:${2:$1}}
${3}
% paragraph $2 (end)
# Sub Paragraph
snippet subp
\subparagraph{${1:subparagraph name}} % (fold)
\subparagraph{${1:subparagraph name}}
\label{subp:${2:$1}}
${3}
% subparagraph $2 (end)
#References
snippet itd
\item[${1:description}] ${2:item}
@ -146,9 +138,11 @@ snippet page
${1:page}~\pageref{${2}}${3}
snippet index
\index{${1:index}}${2}
#cite
#Citations
snippet cite
\cite{${1}}${2}
\cite[${1}]{${2}}${3}
snippet fcite
\footcite[${1}]{${2}}${3}
#Formating text: italic, bold, underline, small capital, emphase ..
snippet it
\textit{${1:text}}

97
snippets/xslt.snippets Normal file
View File

@ -0,0 +1,97 @@
snippet apply-templates with-param
<xsl:apply-templates select="${1:*}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:apply-templates>${5}
snippet apply-templates sort-by
<xsl:apply-templates select="${1:*}">
<xsl:sort select="${2:node}" order="${3:ascending}" data-type="${4:text}">${5}
</xsl:apply-templates>${6}
snippet apply-templates plain
<xsl:apply-templates select="${1:*}" />${2}
snippet attribute blank
<xsl:attribute name="${1:name}">${2}</xsl:attribute>${3}
snippet attribute value-of
<xsl:attribute name="${1:name}">
<xsl:value-of select="${2:*}" />
</xsl:attribute>${3}
snippet call-template
<xsl:call-template name="${1:template}" />
snippet call-template with-param
<xsl:call-template name="${1:template}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:call-template>${5}
snippet choose
<xsl:choose>
<xsl:when test="${1:value}">
${2}
</xsl:when>${3}
</xsl:choose>
snippet copy-of
<xsl:copy-of select="${1:*}" />${2}
snippet for-each
<xsl:for-each select="${1:*}">${2}
</xsl:for-each>${3}
snippet if
<xsl:if test="${1:test}">${2}
</xsl:if>${3}
snippet import
<xsl:import href="${1:stylesheet}" />${2}
snippet include
<xsl:include href="${1:stylesheet}" />${2}
snippet otherwise
<xsl:otherwise>${1}
</xsl:otherwise>
snippet param
<xsl:param name="${1:name}">${2}
</xsl:param>${3}
snippet stylesheet
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${1}
</xsl:stylesheet>
snippet template
<xsl:template match="${1:*}">${3}
</xsl:template>
snippet template named
<xsl:template name="${1:name}">${2}
</xsl:template>
snippet text
<xsl:text>${1}</xsl:text>
snippet value-of
<xsl:value-of select="${1:*}" />${2}
snippet variable blank
<xsl:variable name="${1:name}">${2}
</xsl:variable>
snippet variable select
<xsl:variable select="${1:*}" />${2}
snippet when
<xsl:when test="${1:test}">${2}
</xsl:when>
snippet with-param
<xsl:with-param name="${1:name}">${2}</xsl:with-param>
snippet with-param select
<xsl:with-param name="${1:name}" select="${2:*}" />

248
snippets/yii-chtml.snippets Normal file
View File

@ -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}));

300
snippets/yii.snippets Normal file
View File

@ -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
<?php
class ${1:ModelName} extends ${2:CActiveRecord}
{
/**
* Returns the static model of the specified AR class.
* @return CActiveRecord the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return '${3:table_name}';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
);
}
/**
* @return array relational rules.
*/
public function relations()
{
return array(
);
}
/**
* @return array customized attribute labels (name=&gt;label)
*/
public function attributeLabels()
{
return array(
);
}
}
#------------Yii Controller------------------------------------
#Yii Create controller class
snippet ycontroller
<?php
/**
* ${1:}
*/
class ${2:Site}Controller extends ${3:CController}
{
public function action${4:Index}()
{
${5}
}
// -----------------------------------------------------------
// Uncomment the following methods and override them if needed
/*
public function filters()
{
// return the filter configuration for this controller, e.g.:
return array(
'inlineFilterName',
array(
'class'=>'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}
}