1
0
mirror of https://github.com/amix/vimrc synced 2025-07-12 22:24:59 +08:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Mirosław Pragłowski
2014-10-13 21:54:40 +02:00
266 changed files with 11284 additions and 3954 deletions

View File

@ -1,4 +1,4 @@
Snipmate & UltiSnip Snippets
snipMate & UltiSnip Snippets
============================
This repository contains snippets files for various programming languages.
@ -9,7 +9,7 @@ other improvements already.
Contents
--------
- `snippets/*`: snippets using snipmate format
- `snippets/*`: snippets using snipMate format
- `UltiSnips/*`: snippets using UltiSnips format
Snippet engines supporting vim-snippets
@ -28,8 +28,8 @@ snippets by typing the name of a snippet hitting the expansion mapping.
- [github.com/drmingdrmer/xptemplate](https://github.com/drmingdrmer/xptemplate):
Totally different syntax, does not read snippets contained in this file, but
it is also very powerful. It does not support vim-snippets (just listing it
here for completness)
here for completeness)
There tries to be a more comprehensive list (which still is incomplete) here:
http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html
@ -45,6 +45,18 @@ If you have VimL only (vim without python support) your best option is using
[garbas/vim-snipmate](https://github.com/garbas/vim-snipmate) and cope with the
minor bugs found in the engine.
Q: Should "snipMate be deprecated in favour of UltiSnips"?
A: No, because snipMate is VimL, and UltiSnips requires Python.
Some people want to use snippets without having to install Vim with Python
support. Yes - this sucks.
One solution would be: Use snippets if they are good enough, but allow overriding them
in UltiSnips. This would avoid most duplication while still serving most users.
AFAIK there is a nested-placeholder branch for snipMate too. snipMate is still
improved by Adnan Zafar. So maybe time is not ready to make a final decision yet.
[github issue/discussion](https://github.com/honza/vim-snippets/issues/363)
Installation
------------
@ -55,11 +67,11 @@ which is why Marc Weber thinks that it doesn't make sense to repeat the same
repetitive information everywhere.
*Recommended way:*
[vim-addon-manager](vim-addon-manager) (because Marc Weber wrote it for exactly
this reason, it supports simple dependency management). Eg you're done by this
line in your .vimrc:
[vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager) (because Marc Weber wrote it for exactly
this reason, it supports simple dependency management). E.g. you're done by this
line in your `.vimrc`:
```
```vim
" assuming you want to use snipmate snippet engine
ActivateAddons vim-snippets snipmate
```
@ -67,16 +79,17 @@ ActivateAddons vim-snippets snipmate
[vim-pi](https://bitbucket.org/vimcommunity/vim-pi/issue/90/we-really-need-a-web-interface)
Is the place to discuss plugin managers and repository resources.
About how to install snipate see [snipmate@garbas](https://github.com/garbas/vim-snipmate)
About how to install snipMate see [snipmate@garbas](https://github.com/garbas/vim-snipmate)
(Bundle, Pathogen, git clone - keywords to make people find this link by ctrl-f search)
I know that I should be reading the docs of the snippet engine, just let me copy paste into my .vmirc:
(See this pull request)[https://github.com/honza/vim-snippets/pull/307/files].
I know that I should be reading the docs of the snippet engine, just let me copy paste into my `.vimrc`:
[See this pull request](https://github.com/honza/vim-snippets/pull/307/files).
TROUBLE
=======
If you still have trouble getting this to work create a github ticket, ask on
irc or the mailinglist.
If you still have trouble getting this to work create a GitHub ticket, ask on
IRC or the mailing list.
Policies / for contributors
---------------------------
@ -92,7 +105,8 @@ el : else ..
wh : while (cond) ...
```
Don't add useless placeholder default texts like
Don't add useless placeholder default texts like:
```
if (${1:condition}){
${2:some code here}
@ -106,7 +120,7 @@ if (${1}){
}
```
Exception: Functions which are used less often, such as Vim's matchall(), matchstr()
Exception: Functions which are used less often, such as Vim's `matchall()`, `matchstr()`
functions which case hints may be helpful to remember order. In the VimL case
get vim-dev plugin which has function completion
@ -117,18 +131,26 @@ What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n ..
Which additional policies to add?
Discuss at: https://github.com/honza/vim-snippets/issues/230
*folding markers*:
Until further work is done on `vim-snipmate`, please don't add folding markers
into snippets. `vim-snipmate` has some comments about how to patch all snippets
on the fly adding those.
Currently all snippets from UltiSnips have been put into UltiSnips - some work
on merging should be done (dropping duplicates etc). Also see engines section above.
Related repositories
--------------------
We also encourage people to maintain sets of snippets for particular use cases
so that all users can benefit from them. People can list their snippet repositories here:
* https://github.com/rbonvall/snipmate-snippets-bib (snippets for BibTeX files)
* https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files)
* https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML)
* https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml)
* https://github.com/rbonvall/snipmate-snippets-bib (snippets for BibTeX files)
* https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files)
* https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML)
* https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml)
Installation using VAM: "github:rbonvall/snipmate-snippets-bib"
Installation using VAM: https://github.com/MarcWeber/vim-addon-manager
Future - ideas - examples
-------------------------
@ -136,7 +158,6 @@ Future - ideas - examples
[overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html)
If you have ideas you can add them to that list of "snippet engine features by example".
Historical notes
----------------
@ -146,15 +167,15 @@ unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a
Versions / dialects / ..
========================
There are some issues, such as newer language versions may require other
snippets than older. If this exists we currently recommend doing this:
add snippets/ruby.snippets (common snippets)
add snippets/ruby-1.8.snippets (1.8 only)
add snippets/ruby-1.9.snippets (1.9 only)
then configure github.com/garbas/vim-snipmate this way:
* add snippets/ruby.snippets (common snippets)
* add snippets/ruby-1.8.snippets (1.8 only)
* add snippets/ruby-1.9.snippets (1.9 only)
then configure https://github.com/garbas/vim-snipmate this way:
```vim
let g:snipMate = {}
@ -163,17 +184,18 @@ let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'
```
If it happens that you work on a project requiring ruby-1.8 snippets instead,
consider using vim-addon-local-vimrc and override the filetypes.
consider using `vim-addon-local-vimrc` and override the filetypes.
Well - of course it may not make sense to create a new file for each
ruby-library-version triplet. Sometimes postfixing a name such as
migrate_lib_20_down
migrate_lib_20_up
```
migrate_lib_20_down
migrate_lib_20_up
```
will do it then if syntax has changed.
Language maintainers
--------------------
@ -193,27 +215,12 @@ This list is kept up-to-date on a best effort basis.
* Falcon - [steveno](https://github.com/steveno)
* Elixir - [iurifq](https://github.com/iurifq)
Contributing notes
------------------
Until further work is done on `vim-snipmate`, please don't add folding markers
into snippets. `vim-snipmate` has some comments about how to patch all snippets
on the fly adding those.
Because UltiSnips reads snipmate-snippets too there is no need to duplicate all
snippets - only those snippets who use advanced UltiSnips features should be
duplicated in UltiSnips.
Currently all snippets from UltiSnips have been put into UltiSnips - some work
on merging should be done (dropping duplicates etc)
License
-------
Just as the original snipMate plugin, all the snippets are licensed under the
terms of the MIT license.
[1]: http://github.com/garbas/vim-snipmate
[2]: http://github.com/msanders
[3]: http://github.com/garbas

View File

@ -120,4 +120,14 @@ vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
endsnippet
##########################
# VIM MODELINE GENERATOR #
##########################
# See advice on `:help 'tabstop'` for why these values are set. Uses second
# modeline form ('set') to work in languages with comment terminators
# (/* like C */).
snippet modeline "Vim modeline"
vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'`
endsnippet
# vim:ft=snippets:

View File

@ -16,7 +16,7 @@ endsnippet
snippet #if "#if #endif" b
#if ${1:0}
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
${VISUAL}${0}
#endif
endsnippet
@ -40,7 +40,7 @@ endsnippet
snippet main "main() (main)"
int main(int argc, char *argv[])
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
return 0;
}
endsnippet
@ -48,14 +48,14 @@ endsnippet
snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
@ -74,10 +74,9 @@ else:
snip.rv = snip.c`}
#define $1
${0}
${VISUAL}${0}
#endif /* end of include guard: $1 */
endsnippet
snippet td "Typedef"
@ -86,13 +85,13 @@ endsnippet
snippet wh "while loop"
while(${1:/* condition */}) {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
snippet do "do...while loop (do)"
do {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
} while(${1:/* condition */});
endsnippet
@ -103,26 +102,26 @@ endsnippet
snippet if "if .. (if)"
if (${1:/* condition */})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
snippet el "else .. (else)"
else {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
snippet eli "else if .. (eli)"
else if (${1:/* condition */}) {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet
snippet ife "if .. else (ife)"
if (${1:/* condition */})
{
${2:/* code */}
${2}
}
else
{
@ -144,7 +143,7 @@ endsnippet
snippet fun "function" b
${1:void} ${2:function_name}(${3})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}
endsnippet

View File

@ -27,7 +27,7 @@ endsnippet
snippet ns "namespace .. (namespace)"
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
${VISUAL}${0}
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet

View File

@ -106,14 +106,14 @@ endsnippet
snippet if "if .. (if)"
if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0}
}
endsnippet
snippet ife "if .. else (ife)" b
if(${1:/*condition*/})
{
${2:/*code*/}
${2}
}
else
{
@ -124,14 +124,14 @@ endsnippet
snippet el "else (el)" b
else
{
${VISUAL}${1:/*code*/}
${VISUAL}${1}
}
endsnippet
snippet elif "else if (elif)" b
else if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0}
}
endsnippet
@ -139,10 +139,10 @@ snippet sw "switch (sw)"
switch(${1:/*var*/})
{
case ${2:/*value*/}:
${3:/*code*/}
${3}
break;
case ${4:/*value*/}:
${5:/*code*/}
${5}
break;
${7:/*more cases*/}
default:
@ -151,13 +151,13 @@ switch(${1:/*var*/})
endsnippet
snippet fsw "final switch (fsw)"
switch(${1:/*var*/})
final switch(${1:/*var*/})
{
case ${2:/*value*/}:
${3:/*code*/}
${3}
break;
case ${4:/*value*/}:
${5:/*code*/}
${5}
break;
${7:/*more cases*/}
}
@ -165,7 +165,7 @@ endsnippet
snippet case "case (case)" b
case ${1:/*value*/}:
${2:/*code*/}
${2}
break;
endsnippet
@ -178,42 +178,42 @@ endsnippet
snippet do "do while (do)" b
do
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
} while(${1:/*condition*/});
endsnippet
snippet wh "while (wh)" b
while(${1:/*condition*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
}
endsnippet
snippet for "for (for)" b
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0}
}
endsnippet
snippet forever "forever (forever)" b
for(;;)
{
${VISUAL}${0:/*code*/}
${VISUAL}${0}
}
endsnippet
snippet fore "foreach (fore)"
foreach(${1:/*elem*/}; ${2:/*range*/})
{
${VISUAL}${3:/*code*/}
${VISUAL}${3}
}
endsnippet
snippet forif "foreach if (forif)" b
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
{
${VISUAL}${4:/*code*/}
${VISUAL}${4}
}
endsnippet
@ -249,21 +249,21 @@ endsnippet
snippet fun "function definition (fun)"
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
{
${VISUAL}${5:/*code*/}
${VISUAL}${5}
}
endsnippet
snippet void "void function definition (void)"
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
{
${VISUAL}${4:/*code*/}
${VISUAL}${4}
}
endsnippet
snippet this "ctor (this)" w
this(${1:/*args*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
}
endsnippet
@ -295,7 +295,7 @@ endsnippet
snippet scope "scope (scope)" b
scope(${1:exit})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
}
endsnippet
@ -304,7 +304,7 @@ endsnippet
snippet with "with (with)"
with(${1})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
}
endsnippet
@ -405,14 +405,14 @@ endsnippet
snippet version "version (version)" b
version(${1:/*version name*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2}
}
endsnippet
snippet debug "debug" b
debug
{
${VISUAL}${1:/*code*/}
${VISUAL}${1}
}
endsnippet
@ -422,7 +422,7 @@ endsnippet
snippet temp "template (temp)" b
template ${2:/*name*/}(${1:/*args*/})
{
${3:/*code*/}
${3}
}
endsnippet
@ -440,7 +440,7 @@ endsnippet
snippet unittest "unittest (unittest)" b
unittest
{
${1:/*code*/}
${1}
}
endsnippet
@ -450,21 +450,21 @@ endsnippet
snippet opDis "opDispatch (opDis)" b
${1:/*return type*/} opDispatch(string s)()
{
${2:/*code*/};
${2};
}
endsnippet
snippet op= "opAssign (op=)" b
void opAssign(${1} rhs) ${2:@safe pure nothrow}
{
${2:/*code*/}
${2}
}
endsnippet
snippet opCmp "opCmp (opCmp)" b
int opCmp(${1} rhs) @safe const pure nothrow
{
${2:/*code*/}
${2}
}
endsnippet
@ -484,7 +484,7 @@ endsnippet
snippet toString "toString (toString)" b
string toString() @safe const pure nothrow
{
${1:/*code*/}
${1}
}
endsnippet

View File

@ -1,3 +1,5 @@
extends html
priority -50
# TextMate added these variables to cope with changes in ERB handling

View File

@ -52,6 +52,12 @@ for ${1:condition}${1/(.+)/ /}{
}
endsnippet
snippet fori "Integer for loop" b
for ${1:i} := 0; $1 < ${2:N}; $1++ {
${0:${VISUAL}}
}
endsnippet
snippet forr "For range loop" b
for ${2:name} := range ${1:collection} {
${0:${VISUAL}}

View File

@ -29,4 +29,9 @@ ${1:SubSubsection}:`!p snip.rv = sec_title(snip, t)`
$0
endsnippet
# For vim help, follow the same settings as the official docs.
snippet modeline "Vim help modeline"
`!v 'vim'`:tw=78:ts=8:ft=help:norl:
endsnippet
# vim:ft=snippets:

View File

@ -194,7 +194,7 @@ endsnippet
snippet head "XHTML <head>"
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"`!p x(snip)`>
<meta charset="utf-8">
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
$0
</head>
@ -253,6 +253,10 @@ snippet td "table cell" w
<td>$0</td>
endsnippet
snippet th "table header" w
<th>$0</th>
endsnippet
snippet tr "table row" w
<tr>$0</tr>
endsnippet

View File

@ -25,8 +25,13 @@ def getArgs(group):
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
if not word: return ''
return word[0].upper() + word[1:]
def mixedCase(word):
if not word: return ''
return word[0].lower() + word[1:]
endglobal
snippet sleep "try sleep catch" b
@ -55,7 +60,7 @@ abstract $0
endsnippet
snippet as "assert" b
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};
endsnippet
snippet at "assert true" b
@ -63,7 +68,7 @@ assertTrue(${1:actual});
endsnippet
snippet af "assert false" b
assertFalse(${1:actual});$0
assertFalse(${1:actual});
endsnippet
snippet ae "assert equals" b
@ -136,7 +141,7 @@ if len(args) > 0:
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
if len(args) == 0:
snip.rv += "\n"`
}
@ -173,15 +178,15 @@ default:
$0
endsnippet
snippet elif "else if" b
snippet elif "else if"
else if ($1)`!p nl(snip)`{
$0
$0${VISUAL}
}
endsnippet
snippet /el(se)?/ "else" br
snippet el "else" w
else`!p nl(snip)`{
$0
$0${VISUAL}
}
endsnippet
@ -209,7 +214,7 @@ endsnippet
snippet if "if" b
if ($1)`!p nl(snip)`{
$0
$0${VISUAL}
}
endsnippet
@ -219,7 +224,7 @@ $0
endsnippet
snippet im "import" b
import ${1:java}.${2:util}.$0
import ${1:java}.${2:util}.$0;
endsnippet
snippet in "interface" b
@ -264,7 +269,7 @@ if len(args) > 0:
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
if len(args) == 0:
snip.rv += "\n"`
}
@ -298,7 +303,7 @@ endsnippet
snippet try "try/catch" b
try {
$1
$1${VISUAL}
} catch(${2:Exception} ${3:e}){
${4:e.printStackTrace();}
}
@ -338,23 +343,23 @@ endsnippet
snippet /get(ter)?/ "getter" br
public ${1:String} get${2:Name}() {
return `!p snip.rv = t[2].lower()`;
return `!p snip.rv = mixedCase(t[2])`;
}
endsnippet
snippet /set(ter)?/ "setter" br
public void set${1:Name}(${2:String} $1) {
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
endsnippet
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
public $2 get$1() {
return `!p snip.rv = t[1].lower()`;
return `!p snip.rv = mixedCase(t[1])`;
}
endsnippet

View File

@ -79,6 +79,14 @@ setTimeout(function() {
}${2:.bind(${3:this})}, ${1:10});
endsnippet
snippet fi "for prop in obj using hasOwnProperty" b
for (${1:prop} in ${2:obj}){
if ($2.hasOwnProperty($1)) {
${VISUAL}$0
}
}
endsnippet
# Snippets for Console Debug Output
snippet ca "console.assert" b
@ -121,6 +129,10 @@ snippet cl "console.log" b
console.log(${1:"${2:value}"});
endsnippet
snippet cd "console.debug" b
console.debug(${1:"${2:value}"});
endsnippet
snippet cprof "console.profile" b
console.profile("${1:label}");
${VISUAL}$0

View File

@ -50,6 +50,10 @@ snippet ee "expect to equal (js)" b
expect(${1:target}).toEqual(${2:value});
endsnippet
snippet eb "expect to be (js)" b
expect(${1:target}).toBe(${2:value});
endsnippet
snippet em "expect to match (js)" b
expect(${1:target}).toMatch(${2:pattern});
endsnippet

View File

@ -2,7 +2,6 @@ priority -50
snippet t "Transaction" b
${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee}
${6:Expenses} \$${7:0.00}
${8:Assets:Checking}
$0
${6:Expenses} \$${7:0.00}
${8:Assets:Checking}$0
endsnippet

View File

@ -39,4 +39,15 @@ snippet img "Image"
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet
snippet ilc "Inline Code" i
\`$1\`$0
endsnippet
snippet cbl "Codeblock" b
\`\`\`
$1
\`\`\`
$0
endsnippet
# vim:ft=snippets:

View File

@ -129,4 +129,11 @@ while ($1) {
endsnippet
snippet until "until"
until ($1) {
${2:# body...}
}
endsnippet
# vim:ft=snippets:

View File

@ -14,7 +14,7 @@ endsnippet
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});"
} while (${1:/* condition */});
endsnippet
snippet doc_f "doc_f"
@ -67,6 +67,12 @@ if (${1:/* condition */}) {
}
endsnippet
snippet elif "elseif"
elseif (${1:/* condition */}) {
${2:// code...}
}
endsnippet
snippet inc "inc"
include '${1:file}';${2}
endsnippet
@ -120,19 +126,19 @@ endsnippet
snippet gs "PHP Class Getter Setter" b
/*
* Getter for ${1/(\w+)\s*;/$1/}
* Getter for $1
*/
public function get${1/(\w+)\s*;/\u$1/}()
public function get${1/\w+\s*/\u$0/}()
{
return $this->${1/(\w+)\s*;/$1/};$2
return $this->$1;$2
}
/*
* Setter for ${1/(\w+)\s*;/$1/}
* Setter for $1
*/
public function set${1/(\w+)\s*;/\u$1/}($${1/(\w+)\s*;/$1/})
public function set${1/\w+\s*/\u$0/}($$1)
{
$this->${1/(\w+)\s*;/$1/} = $${1/(\w+)\s*;/$1/};$3
$this->$1 = $$1;$3
${4:return $this;}
}
$0
@ -224,7 +230,7 @@ class $1
{
public function ${3:__construct}(${4:$options})
{
${4:// code}
${5:// code}
}
}
$0
@ -240,8 +246,8 @@ public function __construct(${1:$dependencies})
$0
endsnippet
snippet pr "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
snippet ve "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
endsnippet
snippet pc "Dumb debug helper in cli"

View File

@ -3,6 +3,28 @@
priority -50
snippet classn "Basic class with namespace snippet" b
namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
/**
* ${1:@author `whoami`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`$2
{
public function __construct(${3:$options})
{
${4:// code}
}$0
}
endsnippet
snippet contr "Symfony2 controller" b
namespace `!p
abspath = os.path.abspath(path)

View File

@ -34,13 +34,30 @@ global !p
NORMAL = 0x1
DOXYGEN = 0x2
SPHINX = 0x3
GOOGLE = 0x4
SINGLE_QUOTES = 0x1
DOUBLE_QUOTES = 0x2
class Arg(object):
def __init__(self, arg):
self.arg = arg
self.name = arg.split('=')[0].strip()
def __str__(self):
return self.name
def __unicode__(self):
return self.name
def is_kwarg(self):
return '=' in self.arg
def get_args(arglist):
args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg]
args = [arg for arg in args if arg and arg != "self"]
args = [Arg(arg) for arg in arglist.split(',') if arg]
args = [arg for arg in args if arg.name != 'self']
return args
@ -51,7 +68,7 @@ def get_quoting_style(snip):
return SINGLE_QUOTES
return DOUBLE_QUOTES
def tripple_quotes(snip):
def triple_quotes(snip):
if get_quoting_style(snip) == SINGLE_QUOTES:
return "'''"
return '"""'
@ -61,36 +78,65 @@ def get_style(snip):
if style == "doxygen": return DOXYGEN
elif style == "sphinx": return SPHINX
elif style == "google": return GOOGLE
else: return NORMAL
def format_arg(arg, style):
if style == DOXYGEN:
return "@param %s @todo" % arg
return "@param %s TODO" % arg
elif style == SPHINX:
return ":param %s: @todo" % arg
return ":param %s: TODO" % arg
elif style == NORMAL:
return ":%s: @todo" % arg
return ":%s: TODO" % arg
elif style == GOOGLE:
return "%s (TODO): TODO" % arg
def format_return(style):
if style == DOXYGEN:
return "@return: @todo"
return "@return: TODO"
elif style in (NORMAL, SPHINX):
return ":returns: @todo"
return ":returns: TODO"
elif style == GOOGLE:
return "Returns: TODO"
def write_docstring_args(args, snip):
if not args:
snip.rv += ' {0}'.format(tripple_quotes(snip))
snip.rv += ' {0}'.format(triple_quotes(snip))
return
snip.rv += '\n' + snip.mkline('', indent='')
style = get_style(snip)
for arg in args:
snip += format_arg(arg, style)
if style == GOOGLE:
write_google_docstring_args(args, snip)
else:
for arg in args:
snip += format_arg(arg, style)
def write_google_docstring_args(args, snip):
kwargs = [arg for arg in args if arg.is_kwarg()]
args = [arg for arg in args if not arg.is_kwarg()]
if args:
snip += "Args:"
snip.shift()
for arg in args:
snip += format_arg(arg, GOOGLE)
snip.unshift()
snip.rv += '\n' + snip.mkline('', indent='')
if kwargs:
snip += "Kwargs:"
snip.shift()
for kwarg in kwargs:
snip += format_arg(kwarg, GOOGLE)
snip.unshift()
snip.rv += '\n' + snip.mkline('', indent='')
def write_init_body(args, parents, snip):
@ -120,10 +166,10 @@ endglobal
snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
def __init__(self$4):
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined1.}`!p
`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p
snip.rv = ""
snip >> 2
@ -132,7 +178,7 @@ args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += '{0}'.format(tripple_quotes(snip))
snip += '{0}'.format(triple_quotes(snip))
write_init_body(args, t[2], snip)
`
@ -143,7 +189,7 @@ endsnippet
snippet slotclass "class with slots and docstrings" b
class ${1:MyClass}(${2:object}):
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
`!p
snip >> 1
args = get_args(t[4])
@ -151,7 +197,7 @@ write_slots_args(args, snip)
`
def __init__(self$4):
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined.}`!p
`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p
snip.rv = ""
snip >> 2
@ -160,7 +206,7 @@ args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += tripple_quotes(snip)
snip += triple_quotes(snip)
write_init_body(args, t[2], snip)
`
@ -353,7 +399,7 @@ snippet def "function with docstrings" b
def ${1:function}(`!p
if snip.indent:
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = tripple_quotes(snip)`${4:@todo: Docstring for $1.}`!p
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
snip.rv = ""
snip >> 1
@ -364,7 +410,7 @@ if args:
style = get_style(snip)
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += tripple_quotes(snip) `
snip += triple_quotes(snip) `
${0:pass}
endsnippet
@ -390,8 +436,8 @@ endsnippet
snippet rwprop "Read write property" b
def ${1:name}():
`!p snip.rv = tripple_quotes(snip) if t[2] else ''
`${2:@todo: Docstring for $1.}`!p
`!p snip.rv = triple_quotes(snip) if t[2] else ''
`${2:TODO: Docstring for $1.}`!p
if t[2]:
snip >> 1
@ -399,7 +445,7 @@ if t[2]:
snip.rv += '\n' + snip.mkline('', indent='')
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += tripple_quotes(snip)
snip += triple_quotes(snip)
else:
snip.rv = ""`
def fget(self):
@ -514,11 +560,18 @@ snippet ar "Assert raises" b
self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments})
endsnippet
snippet an "Assert is None" b
self.assertIsNone(${0:expression})
endsnippet
snippet ann "Assert is not None" b
self.assertIsNotNone(${0:expression})
endsnippet
snippet testcase "pyunit testcase" b
class Test${1:Class}(${2:unittest.TestCase}):
`!p snip.rv = tripple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = tripple_quotes(snip)`
`!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)`
def setUp(self):
${4:pass}

View File

@ -12,6 +12,8 @@ from string import Template
import re
from collections import Counter
from vimsnippets import complete
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
@ -40,18 +42,9 @@ INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def has_cjk(s):
"""Detect if s contains CJK characters."""
return CJK_RE.search(s) is not None
def real_filename(filename):
"""pealeextension name off if possible
@ -72,15 +65,17 @@ def check_file_exist(rst_path, relative_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
try:
rst_char_len = vim.strwidth # Requires Vim 7.3+
except AttributeError:
from unicodedata import east_asian_width
def rst_char_len(s):
"""Return the required over-/underline length for s."""
result = 0
for c in s:
result += 2 if east_asian_width(c) in ('W', 'F') else 1
return result
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
@ -92,7 +87,7 @@ def make_items(times, leading='+'):
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
for x in range(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
@ -130,68 +125,47 @@ def get_popular_code_type():
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
def complete(t, opts):
"""
get options that start with t
:param t: query string
:param opts: list that needs to be completed
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
endglobal
snippet part "Part" b
`!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name}
${1:${VISUAL:Part name}}
`!p snip.rv = rst_char_len(t[1])*'#'`
$0
endsnippet
snippet sec "Section" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet chap "Chapter" b
`!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name}
${1:${VISUAL:Chapter name}}
`!p snip.rv = rst_char_len(t[1])*'*'`
$0
endsnippet
snippet sec "Section" b
${1:${VISUAL:Section name}}
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:${VISUAL:Subsection name}}
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:${VISUAL:Subsubsection name}}
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet para "Paragraph" b
${1:Paragraph name}
${1:${VISUAL:Paragraph name}}
`!p snip.rv = rst_char_len(t[1])*'"'`
$0
@ -199,7 +173,7 @@ endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
# dirty but works with CJK character detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
@ -243,7 +217,7 @@ endsnippet
snippet cb "Code Block" b
.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code}
${2:${VISUAL:code}}
$0
endsnippet
@ -266,7 +240,10 @@ if di == 'fi':
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
..`!p snip.rv = " %s" % link if link else ""` $1`!p
snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)
`:: ${2:${VISUAL:file}}`!p
if content:
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
@ -280,7 +257,7 @@ endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
${3:${VISUAL:Content}}
$0
endsnippet
@ -292,7 +269,7 @@ endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
${2:${VISUAL:Content}}
$0
endsnippet
@ -311,6 +288,6 @@ endsnippet
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
${2:${VISUAL:SideBar Content}}
endsnippet
# vim:ft=snippets:

View File

@ -1,54 +1,56 @@
extends css
priority -50
snippet /@?imp/ "@import '...';" br
snippet imp "@import '...';" b
@import '${1:file}';
endsnippet
snippet /@?inc/ "@include mixin(...);" br
snippet inc "@include mixin(...);" b
@include ${1:mixin}(${2:arguments});
endsnippet
snippet /@?ext?/ "@extend %placeholder;" br
snippet ext "@extend %placeholder;" b
@extend %${1:placeholder};
endsnippet
snippet /@?mixin/ "@mixin (...) { ... }" br
snippet mixin "@mixin (...) { ... }" b
@mixin ${1:name}(${2:arguments}) {
${VISUAL}$0
}
endsnippet
snippet /@?fun/ "@function (...) { ... }" br
snippet fun "@function (...) { ... }" b
@function ${1:name}(${2:arguments}) {
${VISUAL}$0
}
endsnippet
snippet /@?if/ "@if (...) { ... }" br
snippet if "@if (...) { ... }" b
@if ${1:condition} {
${VISUAL}$0
}
endsnippet
snippet /(} )?@?else/ "@else { ... }" br
snippet else "@else { ... }" b
@else ${1:condition} {
${VISUAL}$0
}
endsnippet
snippet /@?for/ "@for loop" br
snippet for "@for loop" b
@for ${1:$i} from ${2:1} through ${3:3} {
${VISUAL}$0
}
endsnippet
snippet /@?each/ "@each loop" br
snippet each "@each loop" b
@each ${1:$item} in ${2:item, item, item} {
${VISUAL}$0
}
endsnippet
snippet /@?while/ "@while loop" br
snippet while "@while loop" b
@while ${1:$i} ${2:>} ${3:0} {
${VISUAL}$0
}

View File

@ -8,7 +8,7 @@ snippet "b(egin)?" "begin{} / end{}" br
\end{$1}
endsnippet
snippet tab
snippet tab "tabular / array environment" b
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
$0${2/((?<=.)c|l|r)|./(?1: & )/g}
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}

View File

@ -3,58 +3,22 @@ priority -50
###########################################################################
# SnipMate Snippets #
###########################################################################
snippet header
" File: ${1:`!v expand('%:t')`}
" Author: ${2:`!v g:snips_author`}
" Description: ${3}
${4:" Last Modified: `!v strftime("%B %d, %Y")`}
$0
endsnippet
snippet gvar "Global / configuration variable"
snippet gvar "Global / configuration variable" b
if !exists("g:${1:MyUltraImportantVar}")
let g:$1 = ${2:"${3:<tab>}"}
endif
endsnippet
snippet guard
snippet guard "script reload guard" b
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
finish
endif
let $1 = 1${3}
endsnippet
snippet f
snippet f "function" b
fun ${1:function_name}(${2})
${3:" code}
endf
endsnippet
snippet for
for ${1:needle} in ${2:haystack}
${3:" code}
endfor
endsnippet
snippet wh
while ${1:condition}
${2:" code}
endw
endsnippet
snippet if
if ${1:condition}
${2:" code}
endif
endsnippet
snippet ife
if ${1:condition}
${2}
else
${3}
endif
endsnippet
# vim:ft=snippets:

View File

@ -84,6 +84,24 @@ snippet LGPL3
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
${0}
snippet AGPL3
${1:one line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:copyright holder}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
${0}
snippet BSD2
${1:one line to give the program's name and a brief description}

View File

@ -965,3 +965,23 @@ snippet z:a
z-index: auto;
snippet zoo
zoom: 1;
snippet :h
:hover
snippet :fc
:first-child
snippet :lc
:last-child
snippet :nc
:nth-child(${0})
snippet :nlc
:nth-last-child(${0})
snippet :oc
:only-child
snippet :a
:after
snippet :b
:before
snippet ::a
::after
snippet ::b
::before

View File

@ -10,6 +10,10 @@
snippet auto
${1:FIELDNAME} = models.AutoField(${0})
snippet bigint
${1:FIELDNAME} = models.BigIntegerField(${0})
snippet binary
${1:FIELDNAME} = models.BinaryField(${0})
snippet bool
${1:FIELDNAME} = models.BooleanField(${0:default=True})
snippet char
@ -80,7 +84,7 @@ snippet model
def __unicode__(self):
${5}
def save(self, force_insert=False, force_update=False):
def save(self, *args, **kwargs):
${6}
@models.permalink

View File

@ -6,122 +6,95 @@ snippet if if .. do .. end
if ${1} do
${0}
end
snippet if if .. do: ..
if ${1:condition}, do: ${0}
snippet ife if .. do .. else .. end
if ${1:condition} do
${2}
else
${0}
end
snippet ife if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${0}
snippet unless unless .. do .. end
unless ${1} do
${0}
end
snippet unless unless .. do: ..
unless ${1:condition}, do: ${0}
snippet unlesse unless .. do .. else .. end
unless ${1:condition} do
${2}
else
${0}
end
snippet unlesse unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${0}
snippet cond
cond do
${1} ->
${0}
end
snippet case
case ${1} do
${2} ->
${0}
end
snippet df
def ${1:name}, do: ${2}
snippet def
def ${1:name} do
${0}
end
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${0}
end
snippet defma
defmacro ${1:name} do
${0}
end
snippet defmo
defmodule ${1:module_name} do
${0}
end
snippet defp
defp ${1:name} do
${0}
end
snippet defpr
defprotocol ${1:name}, [${0:function}]
snippet defr
defrecord ${1:record_name}, ${0:fields}
snippet doc
@doc """
${0}
"""
snippet fn
fn(${1:args}) -> ${0} end
snippet fun
function do
${0}
end
function do
${0}
end
snippet mdoc
@moduledoc """
${0}
"""
snippet rec
receive do
${1} ->
${0}
end
snippet req
require ${0:module_name}
snippet imp
import ${0:module_name}
snippet ali
alias ${0:module_name}
snippet test
test "${1:test_name}" do
${0}
end
snippet try try .. rescue .. end
try do
${1}

View File

@ -120,8 +120,12 @@ snippet gen_server
]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-export([init/1,
handle_call/3,
handle_cast/2,
handle_info/2,
terminate/2,
code_change/3]).
-define(SERVER, ?MODULE).
@ -157,6 +161,320 @@ snippet gen_server
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%%%===================================================================
%%% Internal functions
%%%===================================================================
# OTP gen_fsm
snippet gen_fsm
-module(${0:`vim_snippets#Filename('', 'my')`}).
-behaviour(gen_fsm).
%% API
-export([start_link/0]).
%% gen_fsm callbacks
-export([init/1,
state_name/2,
state_name/3,
handle_event/3,
handle_sync_event/4,
handle_info/3,
terminate/3,
code_change/4]).
-record(state, {}).
%%%===================================================================
%%% API
%%%===================================================================
%%--------------------------------------------------------------------
%% @doc
%% Creates a gen_fsm process which calls Module:init/1 to
%% initialize. To ensure a synchronized start-up procedure, this
%% function does not return until Module:init/1 has returned.
%%
%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
%% @end
%%--------------------------------------------------------------------
start_link() ->
gen_fsm:start_link({local, ?MODULE}, ?MODULE, [], []).
%%%===================================================================
%%% gen_fsm callbacks
%%%===================================================================
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever a gen_fsm is started using gen_fsm:start/[3,4] or
%% gen_fsm:start_link/[3,4], this function is called by the new
%% process to initialize.
%%
%% @spec init(Args) -> {ok, StateName, State} |
%% {ok, StateName, State, Timeout} |
%% ignore |
%% {stop, StopReason}
%% @end
%%--------------------------------------------------------------------
init([]) ->
{ok, state_name, #state{}}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% There should be one instance of this function for each possible
%% state name. Whenever a gen_fsm receives an event sent using
%% gen_fsm:send_event/2, the instance of this function with the same
%% name as the current state name StateName is called to handle
%% the event. It is also called if a timeout occurs.
%%
%% @spec state_name(Event, State) ->
%% {next_state, NextStateName, NextState} |
%% {next_state, NextStateName, NextState, Timeout} |
%% {stop, Reason, NewState}
%% @end
%%--------------------------------------------------------------------
state_name(_Event, State) ->
{next_state, state_name, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% There should be one instance of this function for each possible
%% state name. Whenever a gen_fsm receives an event sent using
%% gen_fsm:sync_send_event/[2,3], the instance of this function with
%% the same name as the current state name StateName is called to
%% handle the event.
%%
%% @spec state_name(Event, From, State) ->
%% {next_state, NextStateName, NextState} |
%% {next_state, NextStateName, NextState, Timeout} |
%% {reply, Reply, NextStateName, NextState} |
%% {reply, Reply, NextStateName, NextState, Timeout} |
%% {stop, Reason, NewState} |
%% {stop, Reason, Reply, NewState}
%% @end
%%--------------------------------------------------------------------
state_name(_Event, _From, State) ->
Reply = ok,
{reply, Reply, state_name, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever a gen_fsm receives an event sent using
%% gen_fsm:send_all_state_event/2, this function is called to handle
%% the event.
%%
%% @spec handle_event(Event, StateName, State) ->
%% {next_state, NextStateName, NextState} |
%% {next_state, NextStateName, NextState, Timeout} |
%% {stop, Reason, NewState}
%% @end
%%--------------------------------------------------------------------
handle_event(_Event, StateName, State) ->
{next_state, StateName, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever a gen_fsm receives an event sent using
%% gen_fsm:sync_send_all_state_event/[2,3], this function is called
%% to handle the event.
%%
%% @spec handle_sync_event(Event, From, StateName, State) ->
%% {next_state, NextStateName, NextState} |
%% {next_state, NextStateName, NextState, Timeout} |
%% {reply, Reply, NextStateName, NextState} |
%% {reply, Reply, NextStateName, NextState, Timeout} |
%% {stop, Reason, NewState} |
%% {stop, Reason, Reply, NewState}
%% @end
%%--------------------------------------------------------------------
handle_sync_event(_Event, _From, StateName, State) ->
Reply = ok,
{reply, Reply, StateName, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% This function is called by a gen_fsm when it receives any
%% message other than a synchronous or asynchronous event
%% (or a system message).
%%
%% @spec handle_info(Info,StateName,State)->
%% {next_state, NextStateName, NextState} |
%% {next_state, NextStateName, NextState, Timeout} |
%% {stop, Reason, NewState}
%% @end
%%--------------------------------------------------------------------
handle_info(_Info, StateName, State) ->
{next_state, StateName, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% This function is called by a gen_fsm when it is about to
%% terminate. It should be the opposite of Module:init/1 and do any
%% necessary cleaning up. When it returns, the gen_fsm terminates with
%% Reason. The return value is ignored.
%%
%% @spec terminate(Reason, StateName, State) -> void()
%% @end
%%--------------------------------------------------------------------
terminate(_Reason, _StateName, _State) ->
ok.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Convert process state when code is changed
%%
%% @spec code_change(OldVsn, StateName, State, Extra) ->
%% {ok, StateName, NewState}
%% @end
%%--------------------------------------------------------------------
code_change(_OldVsn, StateName, State, _Extra) ->
{ok, StateName, State}.
%%%===================================================================
%%% Internal functions
%%%===================================================================
# OTP gen_event
snippet gen_event
-module(${0:`vim_snippets#Filename('', 'my')`}).
-behaviour(gen_event).
%% API
-export([start_link/0,
add_handler/2]).
%% gen_event callbacks
-export([init/1,
handle_event/2,
handle_call/2,
handle_info/2,
terminate/2,
code_change/3]).
-record(state, {}).
%%%===================================================================
%%% gen_event callbacks
%%%===================================================================
%%--------------------------------------------------------------------
%% @doc
%% Creates an event manager
%%
%% @spec start_link() -> {ok, Pid} | {error, Error}
%% @end
%%--------------------------------------------------------------------
start_link() ->
gen_event:start_link({local, ?MODULE}).
%%--------------------------------------------------------------------
%% @doc
%% Adds an event handler
%%
%% @spec add_handler(Handler, Args) -> ok | {'EXIT', Reason} | term()
%% @end
%%--------------------------------------------------------------------
add_handler(Handler, Args) ->
gen_event:add_handler(?MODULE, Handler, Args).
%%%===================================================================
%%% gen_event callbacks
%%%===================================================================
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever a new event handler is added to an event manager,
%% this function is called to initialize the event handler.
%%
%% @spec init(Args) -> {ok, State}
%% @end
%%--------------------------------------------------------------------
init([]) ->
{ok, #state{}}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever an event manager receives an event sent using
%% gen_event:notify/2 or gen_event:sync_notify/2, this function is
%% called for each installed event handler to handle the event.
%%
%% @spec handle_event(Event, State) ->
%% {ok, State} |
%% {swap_handler, Args1, State1, Mod2, Args2} |
%% remove_handler
%% @end
%%--------------------------------------------------------------------
handle_event(_Event, State) ->
{ok, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever an event manager receives a request sent using
%% gen_event:call/3,4, this function is called for the specified
%% event handler to handle the request.
%%
%% @spec handle_call(Request, State) ->
%% {ok, Reply, State} |
%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |
%% {remove_handler, Reply}
%% @end
%%--------------------------------------------------------------------
handle_call(_Request, State) ->
Reply = ok,
{ok, Reply, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% This function is called for each installed event handler when
%% an event manager receives any other message than an event or a
%% synchronous request (or a system message).
%%
%% @spec handle_info(Info, State) ->
%% {ok, State} |
%% {swap_handler, Args1, State1, Mod2, Args2} |
%% remove_handler
%% @end
%%--------------------------------------------------------------------
handle_info(_Info, State) ->
{ok, State}.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Whenever an event handler is deleted from an event manager, this
%% function is called. It should be the opposite of Module:init/1 and
%% do any necessary cleaning up.
%%
%% @spec terminate(Reason, State) -> void()
%% @end
%%--------------------------------------------------------------------
terminate(_Reason, _State) ->
ok.
%%--------------------------------------------------------------------
%% @private
%% @doc
%% Convert process state when code is changed
%%
%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}
%% @end
%%--------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%%%===================================================================
%%% Internal functions
%%%===================================================================

View File

@ -107,6 +107,8 @@ snippet ntc
<%= number_to_currency(${1}) %>
snippet ofcfs
<%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${0:selected_value} %>
snippet ofs
<%= options_for_select ${1:collection}, ${2:value_method} %>
snippet rf
<%= render :file => "${1:file}"${0} %>
snippet rt

View File

@ -230,3 +230,15 @@ snippet ga
go func(${1} ${2:type}) {
${3:/* code */}
}(${0})
snippet test test function
func Test${1:name}(t *testing.T) {
${2}
}
${0}
snippet bench benchmark function
func Benchmark${1:name}(b *testing.B) {
for i := 0; i < b.N; i++ {
${2}
}
}
${0}

View File

@ -1,5 +1,7 @@
snippet lang
{-# LANGUAGE ${0:OverloadedStrings} #-}
snippet haddock
{-# OPTIONS_HADDOCK ${0:hide} #-}
snippet info
-- |
-- Module : ${1:Module.Namespace}

View File

@ -47,6 +47,9 @@ snippet backspace
# ⎋
snippet esc
&#x238B;
# comment
snippet //
<!-- ${1} -->${0}
# Generic Doctype
snippet doctype HTML 4.01 Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
@ -147,6 +150,8 @@ snippet a:ext
<a href="http://${1:example.com}">${0:$1}</a>
snippet a:mail
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${0:email me}</a>
snippet ac
<a href="`@+`">${0:`@+`}</a>
snippet abbr
<abbr title="${1}">${0}</abbr>
snippet address
@ -325,7 +330,7 @@ snippet dt+
snippet em
<em>${0}</em>
snippet embed
<embed src=${1} type="${0} />
<embed src="${1}" type="${0}" />
snippet fieldset
<fieldset>
${0}
@ -348,6 +353,14 @@ snippet figcaption
<figcaption>${0}</figcaption>
snippet figure
<figure>${0}</figure>
snippet figure#
<figure id="${1}">
${0}
</figure>
snippet figure.
<figure class="${1}">
${0}
</figure>
snippet footer
<footer>
${0}
@ -449,9 +462,23 @@ snippet html5
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${2:meta}
${2:link}
</head>
<body>
${0:body}
</body>
</html>
snippet html5l
<!DOCTYPE html>
<html lang="${1:es}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>${2:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
${3:link}
</head>
<body>
${0:body}
@ -555,6 +582,8 @@ snippet link
<link rel="${1}" href="${2}" title="${3}" type="${4}" />
snippet link:atom
<link rel="alternate" href="${1:atom.xml}" title="Atom" type="application/atom+xml" />
snippet link:s
<link rel="stylesheet" href="${1:style.css}" />
snippet link:css
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />
snippet link:favicon
@ -595,6 +624,10 @@ snippet menu:t
</menu>
snippet meta
<meta http-equiv="${1}" content="${2}" />
snippet meta:s
<meta ${0} />
snippet meta:d
<meta name="description" content="${0}" />
snippet meta:compat
<meta http-equiv="X-UA-Compatible" content="IE=${1:7,8,edge}" />
snippet meta:refresh
@ -626,7 +659,7 @@ snippet object
# Embed QT Movie
snippet movie
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="$1" />
<param name="controller" value="$4" />
<param name="autoplay" value="$5" />
@ -697,6 +730,12 @@ snippet script
<script type="text/javascript" charset="utf-8">
${0}
</script>
snippet scripts
<script src="${0}.js"></script>
snippet scriptt
<script type="${1}" id="${2}">
${0}
</script>
snippet scriptsrc
<script src="${0}.js" type="text/javascript" charset="utf-8"></script>
snippet section
@ -774,7 +813,7 @@ snippet td+
<td>${1}</td>
td+${0}
snippet textarea
<textarea name="${1}" id=${2:$1} rows="${3:8}" cols="${4:40}">${5}</textarea>
<textarea name="${1}" id="${2:$1}" rows="${3:8}" cols="${4:40}">${5}</textarea>
snippet tfoot
<tfoot>
${0}

View File

@ -1,10 +1,10 @@
## Access Modifiers
snippet po
protected
protected ${0}
snippet pu
public
public ${0}
snippet pr
private
private ${0}
##
## Annotations
snippet before
@ -25,7 +25,7 @@ snippet oo
##
## Basic Java packages and import
snippet im
import
import ${0}
snippet j.b
java.beans.
snippet j.i
@ -39,17 +39,19 @@ snippet j.u
##
## Class
snippet cl
class ${1:`vim_snippets#Filename("", "untitled")`} ${0}
class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
snippet pcl
public class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
snippet in
interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent}
interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent}
snippet tc
public class ${1:`vim_snippets#Filename()`} extends ${0:TestCase}
public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase}
##
## Class Enhancements
snippet ext
extends
extends ${0}
snippet imp
implements
implements ${0}
##
## Comments
snippet /*
@ -89,15 +91,40 @@ snippet m
snippet v
${1:String} ${2:var}${3: = null}${4};
##
## Declaration for ArrayList
snippet d.al
List<${1:Object}> ${2:list} = new ArrayList<$1>();${0}
## Declaration for HashMap
snippet d.hm
Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0}
## Declaration for HashSet
snippet d.hs
Set<${1:Object}> ${2:set} = new HashSet<$1>();${0}
## Declaration for Stack
snippet d.st
Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
##
## Singleton Pattern
snippet singlet
private static class Holder {
private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1();
}
private $1() { }
public static $1 getInstance() {
return Holder.INSTANCE;
}
##
## Enhancements to Methods, variables, classes, etc.
snippet ab
abstract
abstract ${0}
snippet fi
final
final ${0}
snippet st
static
static ${0}
snippet sy
synchronized
synchronized ${0}
##
## Error Methods
snippet err
@ -110,12 +137,30 @@ snippet errln
## Exception Handling
snippet as
assert ${1:test} : "${2:Failure message}";
snippet ae
assertEquals("${1:Failure message}", ${2:expected}, ${3:actual});
snippet aae
assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals});
snippet af
assertFalse("${1:Failure message}", ${2:condition});
snippet at
assertTrue("${1:Failure message}", ${2:condition});
snippet an
assertNull("${1:Failure message}", ${2:object});
snippet ann
assertNotNull("${1:Failure message}", ${2:object});
snippet ass
assertSame("${1:Failure message}", ${2:expected}, ${3:actual});
snippet asns
assertNotSame("${1:Failure message}", ${2:expected}, ${3:actual});
snippet fa
fail("${1:Failure message}");
snippet ca
catch(${1:Exception} ${2:e}) ${0}
snippet thr
throw
throw ${0}
snippet ths
throws
throws ${0}
snippet try
try {
${0}
@ -144,7 +189,7 @@ snippet @au
snippet @br
@brief ${0:Description}
snippet @fi
@file ${0:`vim_snippets#Filename()`}.java
@file ${0:`vim_snippets#Filename("$1")`}.java
snippet @pa
@param ${0:param}
snippet @re
@ -206,7 +251,7 @@ snippet get
##
## Terminate Methods or Loops
snippet re
return
return ${0}
snippet br
break;
##

View File

@ -1,22 +1,26 @@
# Prototype
# prototype
snippet proto
${1:class_name}.prototype.${2:method_name} =
function(${3:first_argument}) {
${0:// body...}
${1:class_name}.prototype.${2:method_name} = function(${3}) {
${0}
};
# Function
snippet fun
function ${1:function_name}(${2:argument}) {
${0:// body...}
function ${1:function_name}(${2}) {
${0}
}
# Anonymous Function
snippet f
function (${1}) {
function(${1}) {
${0}
}${2:;}
}
# Function assigned to variable
snippet vf
var ${1:function_name} = function $1(${2}) {
${0}
};
# Immediate function
snippet (f
(function (${1}) {
(function(${1}) {
${0}
}(${2}));
# if
@ -94,6 +98,9 @@ snippet gett
# console.log (Firebug)
snippet cl
console.log(${0});
# console.debug (Firebug)
snippet cd
console.debug(${0});
# return
snippet ret
return ${0:result}

View File

@ -349,3 +349,11 @@ snippet debug_trace
require Carp; Carp::confess
};
snippet dump
use Data::Dump qw(dump);
warn dump ${1:variable}
snippet subtest
subtest '${1: test_name}' => sub {
${2}
};

View File

@ -40,7 +40,7 @@ snippet i
snippet t.
$this->
snippet f
function ${1:foo}(${2:array }${3:$bar})
function ${1}(${3})
{
${0}
}
@ -347,6 +347,10 @@ snippet vd
var_dump(${0});
snippet vdd
var_dump(${1}); die(${0:});
snippet pr
print_r(${0});
snippet prs
print_r(${0}, 1);
snippet vdf
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');
snippet http_redirect

View File

@ -1,5 +1,6 @@
snippet #!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
snippet imp
import ${0:module}
snippet uni
@ -200,3 +201,10 @@ snippet epydoc
@raise e: ${0: Description}
"""
snippet dol
def ${1:__init__}(self, *args, **kwargs):
super(${0:ClassName}, self).$1(*args, **kwargs)
snippet kwg
self.${1:var_name} = kwargs.get('$1', ${2:None})
snippet lkwg
${1:var_name} = kwargs.get('$1', ${2:None})

View File

@ -23,9 +23,19 @@ snippet ei
${0}
}
# loops
snippet wh
while(${1}) {
${2}
}
snippet for
for (${1:item} in ${2:list}) {
${3}
}
# functions
snippet fun
${1:name} = function (${2:variables}) {
${1:name} <- function (${2:variables}) {
${0}
}
snippet ret
@ -39,7 +49,7 @@ snippet c
snippet li
list(${0:items})
snippet mat
matrix(${1:data}, nrow=${2:rows}, ncol=${0:cols})
matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
# apply functions
snippet apply
@ -100,7 +110,7 @@ snippet pl
snippet ggp
ggplot(${1:data}, aes(${0:aesthetics}))
snippet img
${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}")
${1:(jpeg,bmp,png,tiff)}(filename = '${2:filename}', width = ${3}, height = ${4}, unit = '${5}')
${0:plot}
dev.off()

View File

@ -1,7 +1,3 @@
########################################
# Ruby snippets - for Rails, see below #
########################################
# encoding for Ruby 1.9
snippet enc
# encoding: utf-8
@ -35,9 +31,9 @@ snippet beg
end
snippet req require
require "${1}"
require '${1}'
snippet reqr
require_relative "${1}"
require_relative '${1}'
snippet #
# =>
snippet end
@ -61,7 +57,7 @@ snippet deft
snippet descendants
class Class
def descendants
ObjectSpace.each_object(::Class).select {|klass| klass < self }
ObjectSpace.each_object(::Class).select { |klass| klass < self }
end
end
snippet if
@ -232,13 +228,13 @@ snippet array
snippet hash
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${0} }
snippet file File.foreach() { |line| .. }
File.foreach(${1:"path/to/file"}) { |${2:line}| ${0} }
File.foreach(${1:'path/to/file'}) { |${2:line}| ${0} }
snippet file File.read()
File.read(${1:"path/to/file"})
File.read(${1:'path/to/file'})
snippet Dir Dir.global() { |file| .. }
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${0} }
Dir.glob(${1:'dir/glob/*'}) { |${2:file}| ${0} }
snippet Dir Dir[".."]
Dir[${1:"glob/**/*.rb"}]
Dir[${1:'glob/**/*.rb'}]
snippet dir
Filename.dirname(__FILE__)
snippet deli
@ -247,7 +243,7 @@ snippet fil
fill(${1:range}) { |${2:i}| ${0} }
# flatten_once()
snippet flao
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}
reduce(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2) }
snippet zip
zip(${1:enums}) { |${2:row}| ${0} }
# downto(0) { |n| .. }
@ -419,6 +415,10 @@ snippet seld
end
snippet lam
lambda { |${1:args}| ${0} }
snippet ->
-> { ${0} }
snippet ->a
->(${1:args}) { ${0} }
# I'm pretty sure that ruby users expect do to expand to do .. end
snippet do
do
@ -432,12 +432,12 @@ snippet dov
${2}
end
snippet :
:${1:key} => ${2:"value"}
${1:key}: ${2:'value'}
snippet ope
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${0} }
open('${1:path/or/url/or/pipe}', '${2:w}') { |${3:io}| ${0} }
# path_from_here()
snippet fpath
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])
File.join(File.dirname(__FILE__), *['${1:rel path here}'])
# unix_filter {}
snippet unif
ARGF.each_line${1} do |${2:line}|
@ -445,21 +445,21 @@ snippet unif
end
# option_parse {}
snippet optp
require "optparse"
require 'optparse'
options = {${0:default => "args"}}
options = { ${0:default: 'args'} }
ARGV.options do |opts|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}"
end
snippet opt
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
"${4:Option description.}") do |${5:opt}|
opts.on('-${1:o}', '--${2:long-option-name}', ${3:String}, '${4:Option description.}') do |${5:opt}|
${0}
end
snippet tc
require "test/unit"
require 'test/unit'
require "${1:library_file_name}"
require '${1:library_file_name}'
class Test${2:$1} < Test::Unit::TestCase
def test_${3:case_name}
@ -467,18 +467,20 @@ snippet tc
end
end
snippet ts
require "test/unit"
require 'test/unit'
require "tc_${1:test_case_file}"
require "tc_${2:test_case_file}"
require 'tc_${1:test_case_file}'
require 'tc_${2:test_case_file}'
snippet as
assert ${1:test}, "${2:Failure message.}"
assert ${1:test}, '${2:Failure message.}'
snippet ase
assert_equal ${1:expected}, ${2:actual}
snippet asne
assert_not_equal ${1:unexpected}, ${2:actual}
snippet asid
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2 ** -20}
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2**-20}
snippet asi
assert_includes ${1:collection}, ${2:object}
snippet asio
assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}
snippet asko
@ -488,9 +490,9 @@ snippet asn
snippet asnn
assert_not_nil ${1:instance}
snippet asm
assert_match /${1:expected_pattern}/, ${2:actual_string}
assert_match(/${1:expected_pattern}/, ${2:actual_string})
snippet asnm
assert_no_match /${1:unexpected_pattern}/, ${2:actual_string}
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})
snippet aso
assert_operator ${1:left}, :${2:operator}, ${3:right}
snippet asr
@ -514,7 +516,7 @@ snippet ass assert_send(..)
snippet asns
assert_not_same ${1:unexpected}, ${2:actual}
snippet ast
assert_throws :${1:expected} { ${0} }
assert_throws :${1:expected}, -> { ${0} }
snippet astd
assert_throws :${1:expected} do
${0}
@ -526,7 +528,7 @@ snippet asntd
${0}
end
snippet fl
flunk "${1:Failure message.}"
flunk '${1:Failure message.}'
# Benchmark.bmbm do .. end
snippet bm-
TESTS = ${1:10_000}
@ -534,31 +536,31 @@ snippet bm-
${0}
end
snippet rep
results.report("${1:name}:") { TESTS.times { ${0} }}
results.report('${1:name}:') { TESTS.times { ${0} } }
# Marshal.dump(.., file)
snippet Md
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }
File.open('${1:path/to/file.dump}', 'wb') { |${2:file}| Marshal.dump(${3:obj}, $2) }
# Mashal.load(obj)
snippet Ml
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }
File.open('${1:path/to/file.dump}', 'rb') { |${2:file}| Marshal.load($2) }
# deep_copy(..)
snippet deec
Marshal.load(Marshal.dump(${1:obj_to_copy}))
snippet Pn-
PStore.new(${1:"file_name.pstore"})
PStore.new('${1:file_name.pstore}')
snippet tra
transaction(${1:true}) { ${0} }
# xmlread(..)
snippet xml-
REXML::Document.new(File.read(${1:"path/to/file"}))
REXML::Document.new(File.read('${1:path/to/file}'))
# xpath(..) { .. }
snippet xpa
elements.each(${1:"//Xpath"}) do |${2:node}|
elements.each('${1://Xpath}') do |${2:node}|
${0}
end
# class_from_name()
snippet clafn
split("::").inject(Object) { |par, const| par.const_get(const) }
split('::').inject(Object) { |par, const| par.const_get(const) }
# singleton_class()
snippet sinc
class << self; self end
@ -567,8 +569,8 @@ snippet nam
${0}
end
snippet tas
desc "${1:Task description}"
task :${2:task_name => [:dependent, :tasks]} do
desc '${1:Task description}'
task ${2:task_name: [:dependent, :tasks]} do
${0}
end
# block
@ -576,7 +578,7 @@ snippet b
{ |${1:var}| ${0} }
snippet begin
begin
raise 'A test exception.'
fail 'A test exception.'
rescue Exception => e
puts e.message
puts e.backtrace.inspect
@ -588,381 +590,76 @@ snippet begin
#debugging
snippet debug
require 'ruby-debug'; debugger; true;
require 'byebug'; byebug
snippet debug19
require 'debugger'; debugger
snippet debug18
require 'ruby-debug'; debugger
snippet pry
require 'pry'; binding.pry
snippet strf
strftime("${1:%Y-%m-%d %H:%M:%S %z}")${0}
#############################################
# Rails snippets - for pure Ruby, see above #
#############################################
snippet art
assert_redirected_to ${1::action => "${2:index}"}
snippet artnp
assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1}, ${0:@$2})
snippet artnpp
assert_redirected_to ${1:parent}_${2:child}_path(${0:@$1})
snippet artp
assert_redirected_to ${1:model}_path(${0:@$1})
snippet artpp
assert_redirected_to ${0:model}s_path
snippet asd
assert_difference "${1:Model}.${2:count}", ${3:1} do
${0}
end
snippet asnd
assert_no_difference "${1:Model}.${2:count}" do
${0}
end
snippet asre
assert_response :${1:success}, @response.body
snippet asrj
assert_rjs :${1:replace}, "${0:dom id}"
snippet ass assert_select(..)
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
snippet ba
before_action :${0:method}
snippet bf
before_filter :${0:method}
snippet bt
belongs_to :${0:association}
snippet btp
belongs_to :${1:association}, :polymorphic => true
snippet crw
cattr_accessor :${0:attr_names}
snippet defcreate
def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
respond_to do |format|
if @$1.save
flash[:notice] = '$2 was successfully created.'
format.html { redirect_to(@$1) }
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
else
format.html { render :action => "new" }
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end
end
end
snippet defdestroy
def destroy
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
@$1.destroy
respond_to do |format|
format.html { redirect_to($1s_url) }
format.xml { head :ok }
end
end
snippet defedit
def edit
@${1:model_class_name} = ${0:ModelClassName}.find(params[:id])
end
snippet defindex
def index
@${1:model_class_name} = ${2:ModelClassName}.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @$1s }
end
end
snippet defnew
def new
@${1:model_class_name} = ${2:ModelClassName}.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @$1 }
end
end
snippet defshow
def show
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @$1 }
end
end
snippet defupdate
def update
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |format|
if @$1.update_attributes(params[:$1])
flash[:notice] = '$2 was successfully updated.'
format.html { redirect_to(@$1) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
end
end
end
snippet dele delegate .. to
delegate :${1:methods}, :to => :${0:object}
snippet dele delegate .. to .. prefix .. allow_nil
delegate :${1:methods}, :to => :${2:object}, :prefix => :${3:prefix}, :allow_nil => ${0:allow_nil}
snippet flash
flash[:${1:notice}] = "${0}"
snippet habtm
has_and_belongs_to_many :${1:object}, :join_table => "${2:table_name}", :foreign_key => "${3}_id"
snippet hm
has_many :${0:object}
snippet hmd
has_many :${1:other}s, :class_name => "${2:$1}", :foreign_key => "${3:$1}_id", :dependent => :destroy
snippet hmt
has_many :${1:object}, :through => :${0:object}
snippet ho
has_one :${0:object}
snippet hod
has_one :${1:object}, dependent: :${0:destroy}
snippet i18
I18n.t('${1:type.key}')
snippet ist
<%= image_submit_tag("${1:agree.png}", :id => "${2:id}"${0} %>
snippet log
Rails.logger.${1:debug} ${0}
snippet log2
RAILS_DEFAULT_LOGGER.${1:debug} ${0}
snippet logd
logger.debug { "${1:message}" }
snippet loge
logger.error { "${1:message}" }
snippet logf
logger.fatal { "${1:message}" }
snippet logi
logger.info { "${1:message}" }
snippet logw
logger.warn { "${1:message}" }
snippet mapc
${1:map}.${2:connect} '${0:controller/:action/:id}'
snippet mapca
${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"
snippet mapr
${1:map}.resource :${0:resource}
snippet maprs
${1:map}.resources :${0:resource}
snippet mapwo
${1:map}.with_options :${2:controller} => '${3:thing}' do |$3|
${0}
end
snippet mbs
before_save :${0:method}
snippet mcht
change_table :${1:table_name} do |t|
${0}
end
snippet mp
map(&:${0:id})
snippet mrw
mattr_accessor :${0:attr_names}
snippet oa
order("${0:field}")
snippet od
order("${0:field} DESC")
snippet pa
params[:${1:id}]
snippet ra
render :action => "${0:action}"
snippet ral
render :action => "${1:action}", :layout => "${0:layoutname}"
snippet rest
respond_to do |format|
format.${1:html} { ${0} }
end
snippet rf
render :file => "${0:filepath}"
snippet rfu
render :file => "${1:filepath}", :use_full_path => ${0:false}
snippet ri
render :inline => "${0:<%= 'hello' %>}"
snippet ril
render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"${0} }
snippet rit
render :inline => "${1:<%= 'hello' %>}", :type => ${0::rxml}
snippet rjson
render :json => ${0:text to render}
snippet rl
render :layout => "${0:layoutname}"
snippet rn
render :nothing => ${0:true}
snippet rns
render :nothing => ${1:true}, :status => ${0:401}
snippet rp
render :partial => "${0:item}"
snippet rpc
render :partial => "${1:item}", :collection => ${0:@$1s}
snippet rpl
render :partial => "${1:item}", :locals => { :${2:$1} => ${0:@$1}
snippet rpo
render :partial => "${1:item}", :object => ${0:@$1}
snippet rps
render :partial => "${1:item}", :status => ${0:500}
snippet rt
render :text => "${0:text to render}"
snippet rtl
render :text => "${1:text to render}", :layout => "${0:layoutname}"
snippet rtlt
render :text => "${1:text to render}", :layout => ${0:true}
snippet rts
render :text => "${1:text to render}", :status => ${0:401}
snippet ru
render :update do |${1:page}|
$1.${0}
end
snippet rxml
render :xml => ${0:text to render}
snippet sc
scope :${1:name}, -> { where(${2:field}: ${0:value}) }
snippet sl
scope :${1:name}, lambda do |${2:value}|
where("${3:field = ?}", ${0:bind var})
end
snippet sha1
Digest::SHA1.hexdigest(${0:string})
snippet sweeper
class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper
observe $1
def after_save(${0:model_class_name})
expire_cache($2)
end
def after_destroy($2)
expire_cache($2)
end
def expire_cache($2)
expire_page
end
end
snippet va validates_associated
validates_associated :${0:attribute}
snippet va validates .., :acceptance => true
validates :${0:terms}, :acceptance => true
snippet vc
validates :${0:attribute}, :confirmation => true
snippet ve
validates :${1:attribute}, :exclusion => { :in => ${0:%w( mov avi )} }
snippet vf
validates :${1:attribute}, :format => { :with => /${0:regex}/ }
snippet vi
validates :${1:attribute}, :inclusion => { :in => %w(${0: mov avi }) }
snippet vl
validates :${1:attribute}, :length => { :in => ${2:3}..${0:20} }
snippet vn
validates :${0:attribute}, :numericality => true
snippet vp
validates :${0:attribute}, :presence => true
snippet vu
validates :${0:attribute}, :uniqueness => true
snippet format
format.${1:js|xml|html} { ${0} }
snippet wc
where(${1:"conditions"}${0:, bind_var})
snippet wf
where(${1:field} => ${0:value})
snippet xdelete
xhr :delete, :${1:destroy}, :id => ${2:1}
snippet xget
xhr :get, :${1:show}, :id => ${2:1}
snippet xpost
xhr :post, :${1:create}, :${2:object} => { ${0} }
snippet xput
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }
snippet test
test "should ${1:do something}" do
${0}
end
###########################
# migrations snippets #
###########################
snippet mac
add_column :${1:table_name}, :${2:column_name}, :${0:data_type}
snippet mai
add_index :${1:table_name}, :${0:column_name}
snippet mrc
remove_column :${1:table_name}, :${0:column_name}
snippet mrnc
rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}
snippet mcc
change_column :${1:table}, :${2:column}, :${0:type}
snippet mnc
t.${1:string} :${2:title}${3:, null: false}
snippet mct
create_table :${1:table_name} do |t|
${0}
end
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
class ${1:class_name} < ActiveRecord::Migration
def up
${0}
end
def down
end
end
snippet migration class .. < ActiveRecord::Migration .. def change .. end
class ${1:class_name} < ActiveRecord::Migration
def change
${0}
end
end
snippet trc
t.remove :${0:column}
snippet tre
t.rename :${1:old_column_name}, :${2:new_column_name}
${0}
snippet tref
t.references :${0:model}
snippet tcb
t.boolean :${1:title}
${0}
snippet tcbi
t.binary :${1:title}, :limit => ${2:2}.megabytes
${0}
snippet tcd
t.decimal :${1:title}, :precision => ${2:10}, :scale => ${3:2}
${0}
snippet tcda
t.date :${1:title}
${0}
snippet tcdt
t.datetime :${1:title}
${0}
snippet tcf
t.float :${1:title}
${0}
snippet tch
t.change :${1:name}, :${2:string}, :${3:limit} => ${4:80}
${0}
snippet tci
t.integer :${1:title}
${0}
snippet tcl
t.integer :lock_version, :null => false, :default => 0
${0}
snippet tcr
t.references :${1:taggable}, :polymorphic => { :default => '${2:Photo}' }
${0}
snippet tcs
t.string :${1:title}
${0}
snippet tct
t.text :${1:title}
${0}
snippet tcti
t.time :${1:title}
${0}
snippet tcts
t.timestamp :${1:title}
${0}
snippet tctss
t.timestamps
${0}
strftime('${1:%Y-%m-%d %H:%M:%S %z}')${0}
#
# Minitest snippets
#
snippet mb
must_be ${0}
snippet wb
wont_be ${0}
snippet mbe
must_be_empty
snippet wbe
wont_be_empty
snippet mbio
must_be_instance_of ${0:Class}
snippet wbio
wont_be_instance_of ${0:Class}
snippet mbko
must_be_kind_of ${0:Class}
snippet wbko
wont_be_kind_of ${0:Class}
snippet mbn
must_be_nil
snippet wbn
wont_be_nil
snippet mbsa
must_be_same_as ${0:other}
snippet wbsa
wont_be_same_as ${0:other}
snippet mbsi
-> { ${0} }.must_be_silent
snippet mbwd
must_be_within_delta ${1:0.1}, ${2:0.1}
snippet wbwd
wont_be_within_delta ${1:0.1}, ${2:0.1}
snippet mbwe
must_be_within_epsilon ${1:0.1}, ${2:0.1}
snippet wbwe
wont_be_within_epsilon ${1:0.1}, ${2:0.1}
snippet me
must_equal ${0:other}
snippet we
wont_equal ${0:other}
snippet mi
must_include ${0:what}
snippet wi
wont_include ${0:what}
snippet mm
must_match /${0:regex}/
snippet wm
wont_match /${0:regex}/
snippet mout
-> { ${1} }.must_output '${0}'
snippet mra
-> { ${1} }.must_raise ${0:Exception}
snippet mrt
must_respond_to :${0:method}
snippet wrt
wont_respond_to :${0:method}
snippet msend
must_send [ ${1:what}, :${2:method}, ${3:args} ]
snippet mthrow
-> { throw :${1:error} }.must_throw :${2:error}
##########################
# Rspec snippets #
##########################
@ -971,11 +668,11 @@ snippet desc
${0}
end
snippet descm
describe "${1:#method}" do
${0:pending "Not implemented"}
describe '${1:#method}' do
${0:pending 'Not implemented'}
end
snippet cont
context "${1:message}" do
context '${1:message}' do
${0}
end
snippet bef
@ -987,9 +684,9 @@ snippet aft
${0}
end
snippet let
let(:${1:object}) ${0}
let(:${1:object}) { ${0} }
snippet let!
let!(:${1:object}) ${0}
let!(:${1:object}) { ${0} }
snippet subj
subject { ${0} }
snippet s.
@ -1003,11 +700,11 @@ snippet expb
snippet experr
expect { ${1:object} }.to raise_error ${2:StandardError}, /${0:message_regex}/
snippet shared
shared_examples ${0:"shared examples name"}
shared_examples ${0:'shared examples name'}
snippet ibl
it_behaves_like ${0:"shared examples name"}
it_behaves_like ${0:'shared examples name'}
snippet it
it "${1:spec_name}" do
it '${1:spec_name}' do
${0}
end
snippet its
@ -1016,74 +713,3 @@ snippet is
it { should ${0} }
snippet isn
it { should_not ${0} }
#ShouldaMatchers#ActionController
snippet isfp
it { should filter_param :${0:key} }
snippet isrt
it { should redirect_to ${0:url} }
snippet isrtp
it { should render_template ${0} }
snippet isrwl
it { should render_with_layout ${0} }
snippet isrf
it { should rescue_from ${0:exception} }
snippet isrw
it { should respond_with ${0:status} }
snippet isr
it { should route(:${1:method}, '${0:path}') }
snippet isss
it { should set_session :${0:key} }
snippet issf
it { should set_the_flash('${0}') }
#ShouldaMatchers#ActiveModel
snippet isama
it { should allow_mass_assignment_of :${0} }
snippet isav
it { should allow_value(${1}).for :${0} }
snippet isee
it { should ensure_exclusion_of :${0} }
snippet isei
it { should ensure_inclusion_of :${0} }
snippet isel
it { should ensure_length_of :${0} }
snippet isva
it { should validate_acceptance_of :${0} }
snippet isvc
it { should validate_confirmation_of :${0} }
snippet isvn
it { should validate_numericality_of :${0} }
snippet isvp
it { should validate_presence_of :${0} }
snippet isvu
it { should validate_uniqueness_of :${0} }
#ShouldaMatchers#ActiveRecord
snippet isana
it { should accept_nested_attributes_for :${0} }
snippet isbt
it { should belong_to :${0} }
snippet isbtcc
it { should belong_to(:${1}).counter_cache ${0:true} }
snippet ishbtm
it { should have_and_belong_to_many :${0} }
snippet isbv
it { should be_valid }
snippet ishc
it { should have_db_column :${0} }
snippet ishi
it { should have_db_index :${0} }
snippet ishm
it { should have_many :${0} }
snippet ishmt
it { should have_many(:${1}).through :${0} }
snippet isho
it { should have_one :${0} }
snippet ishro
it { should have_readonly_attribute :${0} }
snippet iss
it { should serialize :${0} }
snippet isres
it { should respond_to :${0} }
snippet isresw
it { should respond_to(:${1}).with(${0}).arguments }
snippet super_call
${1:super_class}.instance_method(:${0:method}).bind(self).call

View File

@ -194,8 +194,9 @@ snippet mhmap
snippet as
${1:name}.asInstanceOf[${2:T}]
#isInstanceOf[]
snippet is
${1:name}.isInstanceOf[${2:T}]
#end
#collections methods
#scope() with one arg

View File

@ -81,7 +81,7 @@ snippet getopt
done
shift $(($OPTIND-1))
snippet root
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi
if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi
snippet fun
${1:function_name}() {
${0:#function_body}

View File

@ -1,215 +1,224 @@
#PREAMBLE
#newcommand
snippet nc
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
snippet nc \newcommand
\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
#usepackage
snippet up
snippet up \usepackage
\usepackage[${1:options}]{${2:package}} ${0}
#newunicodechar
snippet nuc
snippet nuc \newunicodechar
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${0}
#DeclareMathOperator
snippet dmo
snippet dmo \DeclareMathOperator
\DeclareMathOperator{${1}}{${2}} ${0}
#DOCUMENT
# \begin{}...\end{}
snippet begin
snippet begin \begin{} ... \end{} block
\begin{${1:env}}
${0}
\end{$1}
# Tabular
snippet tab
snippet tab tabular (or arbitrary) environment
\begin{${1:tabular}}{${2:c}}
${0}
${0}
\end{$1}
snippet thm
snippet thm thm (or arbitrary) environment with optional argument
\begin[${1:author}]{${2:thm}}
${0}
${0}
\end{$2}
snippet center
snippet center center environment
\begin{center}
${0}
\end{center}
# Align(ed)
snippet ali
snippet ali align(ed) environment
\begin{align${1:ed}}
\label{eq:${2}}
${0}
\end{align$1}
# Gather(ed)
snippet gat
snippet gat gather(ed) environment
\begin{gather${1:ed}}
${0}
\end{gather$1}
# Equation
snippet eq
snippet eq equation environment
\begin{equation}
\label{eq:${2}}
${0}
\end{equation}
# Equation
snippet eq*
snippet eq* unnumbered equation environment
\begin{equation*}
${0}
\end{equation*}
# Unnumbered Equation
snippet \
snippet \ unnumbered equation: \[ ... \]
\[
${0}
\]
# Equation array
snippet eqnarray
snippet eqnarray eqnarray environment
\begin{eqnarray}
${0}
\end{eqnarray}
# Label
snippet lab \label
\label{${1:eq:}${2:fig:}${3:tab:}${0}}
# Enumerate
snippet enum
snippet enum enumerate environment
\begin{enumerate}
\item ${0}
\end{enumerate}
# Itemize
snippet itemize
snippet itemize itemize environment
\begin{itemize}
\item ${0}
\end{itemize}
snippet item
snippet item \item
\item ${1}
# Description
snippet desc
snippet desc description environment
\begin{description}
\item[${1}] ${0}
\end{description}
# Endless new item
snippet ]i
snippet ]i \item (recursive)
\item ${1}
${0:]i}
${0:]i}
# Matrix
snippet mat
snippet mat smart matrix environment
\begin{${1:p/b/v/V/B/small}matrix}
${0}
\end{$1matrix}
# Cases
snippet cas
snippet cas cases environment
\begin{cases}
${1:equation}, &\text{ if }${2:case}\\
${0}
\end{cases}
# Split
snippet spl
snippet spl split environment
\begin{split}
${0}
\end{split}
# Part
snippet part
snippet part document \part
\part{${1:part name}} % (fold)
\label{prt:${2:$1}}
${0}
% part $2 (end)
# Chapter
snippet cha
snippet cha \chapter
\chapter{${1:chapter name}}
\label{cha:${2:$1}}
${0}
# Section
snippet sec
snippet sec \section
\section{${1:section name}}
\label{sec:${2:$1}}
${0}
# Section without number
snippet sec*
snippet sec* \section*
\section*{${1:section name}}
\label{sec:${2:$1}}
${0}
# Sub Section
snippet sub
snippet sub \subsection
\subsection{${1:subsection name}}
\label{sub:${2:$1}}
${0}
# Sub Section without number
snippet sub*
snippet sub* \subsection*
\subsection*{${1:subsection name}}
\label{sub:${2:$1}}
${0}
# Sub Sub Section
snippet subs
snippet subs \subsubsection
\subsubsection{${1:subsubsection name}}
\label{ssub:${2:$1}}
${0}
# Sub Sub Section without number
snippet subs*
snippet subs* \subsubsection*
\subsubsection*{${1:subsubsection name}}
\label{ssub:${2:$1}}
${0}
# Paragraph
snippet par
snippet par \paragraph
\paragraph{${1:paragraph name}}
\label{par:${2:$1}}
${0}
# Sub Paragraph
snippet subp
snippet subp \subparagraph
\subparagraph{${1:subparagraph name}}
\label{subp:${2:$1}}
${0}
snippet ni
snippet ni \noindent
\noindent
${0}
#References
snippet itd
snippet itd description \item
\item[${1:description}] ${0:item}
snippet figure
snippet figure reference to a figure
${1:Figure}~\ref{${2:fig:}}
snippet table
snippet table reference to a table
${1:Table}~\ref{${2:tab:}}
snippet listing
snippet listing reference to a listing
${1:Listing}~\ref{${2:list}}
snippet section
snippet section reference to a section
${1:Section}~\ref{sec:${2}} ${0}
snippet page
snippet page reference to a page
${1:page}~\pageref{${2}} ${0}
snippet index
snippet index \index
\index{${1:index}} ${0}
#Citations
snippet citen
\cite{$1} ${0}
# bibtex commands
snippet citep
\citep{$1} ${0}
snippet citet
\citet{$1} ${0}
snippet cite
snippet citen \citen
\citen{${1}} ${0}
# natbib citations
snippet citep \citep
\citep{${1}} ${0}
snippet citet \citet
\citet{${1}} ${0}
snippet cite \cite[]{}
\cite[${1}]{${2}} ${0}
snippet fcite
snippet citea \citeauthor
\citeauthor{${1}} ${0}
snippet citey \citeyear
\citeyear{${1}} ${0}
snippet fcite \footcite[]{}
\footcite[${1}]{${2}}${0}
#Formating text: italic, bold, underline, small capital, emphase ..
snippet it
snippet it italic text
\textit{${0:text}}
snippet bf
snippet bf bold face text
\textbf{${0:text}}
snippet under
snippet under underline text
\underline{${0:text}}
snippet emp
snippet emp emphasize text
\emph{${0:text}}
snippet sc
snippet sc small caps text
\textsc{${0:text}}
#Choosing font
snippet sf
snippet sf sans serife text
\textsf{${0:text}}
snippet rm
snippet rm roman font text
\textrm{${0:text}}
snippet tt
snippet tt typewriter (monospace) text
\texttt{${0:text}}
#misc
snippet ft
snippet ft \footnote
\footnote{${0:text}}
snippet fig
snippet fig figure environment (includegraphics)
\begin{figure}
\begin{center}
\includegraphics[scale=${1}]{Figures/${2}}
\includegraphics[scale=${1}]{Figures/${2}}
\end{center}
\caption{${3}}
\label{fig:${4}}
\end{figure}
${0}
snippet tikz
snippet tikz figure environment (tikzpicture)
\begin{figure}
\begin{center}
\begin{tikzpicture}[scale=${1:1}]
@ -221,33 +230,31 @@ snippet tikz
\end{figure}
${0}
#math
snippet stackrel
snippet stackrel \stackrel{}{}
\stackrel{${1:above}}{${2:below}} ${0}
snippet frac
snippet frac \frac{}{}
\frac{${1:num}}{${2:denom}} ${0}
snippet sum
snippet sum \sum^{}_{}
\sum^{${1:n}}_{${2:i=1}} ${0}
snippet lim
snippet lim \lim_{}
\lim_{${1:x \to +\infty}} ${0}
snippet frame
\begin{frame}[<+->]
\frametitle{${1:title}}
snippet frame frame environment
\begin{frame}[${1:t}]{${2:title}}
${0}
\end{frame}
snippet block
snippet block block environment
\begin{block}{${1:title}}
${0}
\end{block}
snippet alert
snippet alert alertblock environment
\begin{alertblock}{${1:title}}
${0}
\end{alertblock}
snippet example
snippet example exampleblock environment
\begin{exampleblock}{${1:title}}
${0}
\end{exampleblock}
snippet col2
snippet col2 two-column environment
\begin{columns}
\begin{column}{0.5\textwidth}
${1}
@ -256,3 +263,20 @@ snippet col2
${0}
\end{column}
\end{columns}
# Code listings
snippet lst
\begin{listing}[language=${1:language}]
${0}
\end{listing}
snippet lsi
\lstinline|${1}| ${0}
# Hyperlinks
snippet url
\url{${1}} ${0}
snippet href
\href{${1}}{${2}} ${0}
# URL from Clipboard.
snippet urlc
\url{`@+`} ${0}
snippet hrefc
\href{`@+`}{${1}} ${0}

View File

@ -1,50 +1,52 @@
snippet header
snippet header standard Vim script file header
" File: ${1:`expand('%:t')`}
" Author: ${2:`g:snips_author`}
" Description: ${3}
${0:" Last Modified: `strftime("%B %d, %Y")`}
snippet guard
snippet guard script reload guard
if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
finish
endif
let $1 = 1${0}
snippet f
snippet f function
fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3})
${0}
endf
snippet t
snippet t try ... catch statement
try
${1}
catch ${2}
${0}
endtry
snippet for
snippet for for ... in loop
for ${1} in ${2}
${0}
endfor
snippet forkv
snippet forkv for [key, value] in loop
for [${1},${2}] in items(${3})
${0}
unlet $1 $2
endfor
snippet wh
snippet wh while loop
while ${1}
${0}
endw
snippet if
snippet if if statement
if ${1}
${0}
endif
snippet ife
snippet ife if ... else statement
if ${1}
${2}
else
${0}
endif
snippet au
snippet au augroup ... autocmd block
augroup ${1:AU_NAME}
" this one is which you're most likely to use?
autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|<buffer[=N]>} ${0}
augroup end
snippet bun
Bundle '${0}'
snippet bun Vundle.vim Plugin definition
Plugin '${0}'
snippet plug Vundle.vim Plugin definition
Plugin '${0}'

View File

@ -13,14 +13,14 @@ snippet ife
${0:# statements}
fi
snippet eif
elif ${1:condition} ; then
elif ${1:condition}; then
${0:# statements}
snippet for
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
${0:# statements}
done
snippet fori
for ${1:needle} in ${2:haystack} ; do
for ${1:needle} in ${2:haystack}; do
${0:#statements}
done
snippet fore
@ -57,6 +57,10 @@ snippet [
snippet always
{ ${1:try} } always { ${0:always} }
snippet fun
function ${1:name} (${2:args}) {
${0:# body}
${1:function_name}() {
${0:# function_body}
}
snippet ffun
function ${1:function_name}() {
${0:# function_body}
}