new policies for if, eif, el

What about wh(ile)?
drop some placeholder comments which don't add (enough) value to keep
for patterns used very often.
This commit is contained in:
Marc Weber 2013-06-23 02:30:26 +02:00
parent eaa01e7254
commit 344ac6ea2c
27 changed files with 177 additions and 120 deletions

View File

@ -50,6 +50,43 @@ of the snippets by setting the "always_use_first_snippet" option to 1.
If you have VimL only (vim without python support) your best option is using
garbas/vim-snipmate and cope with the minor bugs found in the engine.
Policies / for contributors
===========================
some snippets are useful for all languages, so let's try to have the same
triggers for all languages:
```
if : if without else
ife: if $1 else $2
eif : else if ($1) { .. }
el : else ..
```
If you're not satisfied with these defaults, open a ticket that we implement
aliasing. Then you can remap "else" to "el" or the like.
Don't add stupid placeholder default texts like
```
if (${1:condition){
${2:some code here}
}
```
instead use:
```
if (${1){
${2}
}
```
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
Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
Related repositories
====================
We also encourage people to maintain sets of snippets for particular use cases

View File

@ -22,7 +22,7 @@ else
${3:# body...}
endsnippet
snippet elif "Else if" b
snippet eif "Else if" b
else if ${1:condition}
${0:# body...}
endsnippet

View File

@ -126,7 +126,7 @@ else
}
endsnippet
snippet elif "else if (elif)" b
snippet eif "else if (elif)" b
else if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}

View File

@ -76,7 +76,7 @@ snippet if
{% endif %}
endsnippet
snippet else
snippet el
{% else %}
${1}
endsnippet

View File

@ -263,7 +263,7 @@ snippet st "submit_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet else "else (ERB)"
snippet el "else (ERB)"
<% else %>
endsnippet

View File

@ -1,13 +1,13 @@
snippet if "if ... then ... else ..."
snippet ife "if ... then ... else ..."
if ${1:condition}
then ${2:expression}
else ${3:expression}
endsnippet
snippet case "case ... of ..."
case ${1:expression} of
${2:pattern} -> ${3:expression}
${4:pattern} -> ${5:expression}
case ${1} of
${2} -> ${3}
${4} -> ${5}
endsnippet
snippet :: "Type signature"

View File

@ -59,7 +59,7 @@ default:
$0
endsnippet
snippet elif "else if" b
snippet eif "else if" b
else if ($1)`!p nl(snip)`{
$0
}

View File

@ -50,12 +50,19 @@ function ${1:function_name} (${2:argument}) {
}
endsnippet
# for one line if .. else you usually use a ? b : c
snippet ife "if ___ else"
if (${1:true}) {$0} else{};
if (${1}) {
{$2}
} else {
{$3}
};
endsnippet
snippet if "if"
if (${1:true}) {$0};
if (${1}) {
{$2}
};
endsnippet
snippet timeout "setTimeout function"

View File

@ -4,17 +4,17 @@ endsnippet
snippet open "open"
let open ${1:module} in
${2:e}
${2}
endsnippet
snippet try "try"
try ${1:e}
try ${1}
with ${2:Not_found} -> ${3:()}
endsnippet
snippet ref "ref"
let ${1:name} = ref ${2:val} in
${3:e}
let ${1} = ref ${2} in
${3}
endsnippet
snippet matchl "pattern match on a list"
@ -24,88 +24,83 @@ match ${1:list} with
endsnippet
snippet matcho "pattern match on an option type"
match ${1:x} with
| Some(${2:y}) -> ${3:()}
match ${1} with
| Some(${2}) -> ${3:()}
| None -> ${4:()}
endsnippet
snippet fun "anonymous function"
(fun ${1:x} -> ${2:x})
(fun ${1} -> ${2})
endsnippet
snippet cc "commment"
(* ${1:comment} *)
(* ${1} *)
endsnippet
snippet let "let .. in binding"
let ${1:x} = ${2:v} in
${3:e}
let ${1} = ${2} in
${3}
endsnippet
snippet lr "let rec"
let rec ${1:f} =
${2:expr}
let rec ${1} =
${2}
endsnippet
snippet if "if"
if ${1:(* condition *)} then
${2:(* A *)}
snippet ife "if"
if ${1} then
${2}
else
${3:(* B *)}
${3}
endsnippet
snippet If "If"
if ${1:(* condition *)} then
${2:(* A *)}
snippet if "If"
if ${1} then
${2}
endsnippet
snippet while "while"
while ${1:(* condition *)} do
${2:(* A *)}
while ${1} do
${2}
done
endsnippet
snippet for "for"
for ${1:i} = ${2:1} to ${3:10} do
${4:(* BODY *)}
${4}
done
endsnippet
snippet match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet
snippet Match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
match ${1} with
| ${2} -> ${3}
endsnippet
snippet class "class"
class ${1:name} = object
${2:methods}
${2}
end
endsnippet
snippet obj "obj"
object
${2:methods}
${2}
end
endsnippet
snippet Obj "object"
object (self)
${2:methods}
${2}
end
endsnippet
snippet {{ "object functional update"
{< ${1:x} = ${2:y} >}
{< ${1} = ${2} >}
endsnippet
snippet beg "beg"
begin
${1:block}
${1}${VISUAL}
end
endsnippet
@ -115,19 +110,19 @@ endsnippet
snippet mod "module - no signature"
module ${1:(* Name *)} = struct
${2:(* BODY *)}
${2}
end
endsnippet
snippet Mod "module with signature"
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
${3:(* BODY *)}
${3}
end
endsnippet
snippet sig "anonymous signature"
sig
${2:(* BODY *)}
${2}
end
endsnippet
@ -137,32 +132,32 @@ endsnippet
snippet func "define functor - no signature"
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
${4:(* BODY *)}
${4}
end
endsnippet
snippet Func "define functor - with signature"
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
${5:(* BODY *)}
${5}
end
endsnippet
snippet mot "Declare module signature"
module type ${1:(* Name *)} = sig
${2:(* BODY *)}
${2}
end
endsnippet
snippet module "Module with anonymous signature"
module ${1:(* Name *)} : sig
${2:(* SIGNATURE *)}
${2}
end = struct
${3:(* BODY *)}
${3}
end
endsnippet
snippet oo "odoc"
(** ${1:odoc} *)
(** ${1} *)
endsnippet
snippet qt "inline qtest"

View File

@ -11,8 +11,8 @@ endsnippet
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});"
${2}
} while (${1});"
endsnippet
snippet doc_f "doc_f"
@ -37,21 +37,21 @@ interface ${1:someClass}
} // END interface $1"
endsnippet
snippet else "else"
snippet el "else"
else {
${1:// code...}
${1}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
${4}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
${4:// code...}
${4}
}
endsnippet
@ -60,8 +60,8 @@ $_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
if (${1}) {
${2}
}
endsnippet
@ -210,9 +210,9 @@ endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
${2}
} else {
${3:// code...}
${3}
}
$0
endsnippet
@ -227,7 +227,7 @@ class $1
{
public function ${3:__construct}(${4:$options})
{
${4:// code}
${4}
}
}
$0

View File

@ -16,14 +16,14 @@ foreach ${1:var} ${2:\$list} {
endsnippet
snippet if "if... (if)" b
if {${1:condition}} {
if {${1}} {
${2}
}
endsnippet
snippet proc "proc... (proc)" b
proc ${1:name} {${2:args}} \
proc ${1} {${2}} \
{
${3}
}
@ -41,7 +41,7 @@ switch ${1:-exact} -- ${2:\$var} {
endsnippet
snippet while "while... (while)" b
while {${1:condition}} {
while {${1}} {
${2}
}

View File

@ -25,30 +25,30 @@ endsnippet
snippet f
fun ${1:function_name}(${2})
${3:" code}
${3}
endf
endsnippet
snippet for
for ${1:needle} in ${2:haystack}
${3:" code}
for ${1} in ${2}
${3}
endfor
endsnippet
snippet wh
while ${1:condition}
${2:" code}
while ${1}
${2}
endw
endsnippet
snippet if
if ${1:condition}
${2:" code}
if ${1}
${2}
endif
endsnippet
snippet ife
if ${1:condition}
if ${1}
${2}
else
${3}

View File

@ -5,17 +5,17 @@ snippet if
snippet el
Else
${1}
snippet elif
snippet eif
ElseIf ${1:condition} Then
${2:; True code}
# If/Else block
snippet ifel
snippet ife
If ${1:condition} Then
${2:; True code}
Else
${3:; Else code}
EndIf
# If/ElseIf/Else block
# If/ElseIf/Else block - because there is eif this is not really neccessary
snippet ifelif
If ${1:condition 1} Then
${2:; True code}

View File

@ -63,7 +63,7 @@ snippet ife
else
${3:# body...}
# Else if
snippet elif
snippet eif
else if ${1:condition}
${2:# body...}
# Ternary If

View File

@ -32,7 +32,7 @@ snippet ife
end
# If else if
snippet elif
snippet eif
elif ${1:condition}
${2}

View File

@ -47,10 +47,10 @@ snippet if
{% if ${1} %}
${2}
{% endif %}
snippet else
snippet el
{% else %}
${1}
snippet elif
snippet eif
{% elif ${1} %}
${2}
snippet ifchanged

View File

@ -27,9 +27,9 @@ snippet if
{% if ${1:condition} %}
${2}
{% end %}
snippet elif
snippet eif
{% elif ${1:condition} %}
snippet else
snippet el
{% else %}
snippet import
{% import ${1:module} %}

View File

@ -72,7 +72,7 @@ snippet def
${2}
snippet el
else
snippet elif
snippet eif
else if (${1}) ${2}
snippet if
if (${1}) ${2}

View File

@ -22,7 +22,7 @@ snippet if if
% if ${1:condition}:
${2:}
% endif
snippet if if/else
snippet ife if/else
% if ${1:condition}:
${2:}
% else:

View File

@ -8,31 +8,35 @@ snippet .
# Function
snippet sub
sub ${1:function_name} {
${2:#body ...}
${2}
}
# Conditional
snippet if
if (${1}) {
${2:# body...}
${2}
}
# Conditional if..else
snippet ife
if (${1}) {
${2:# body...}
${2}
}
else {
${3:# else...}
${3}
}
# Conditional if..elsif..else
snippet ifee
if (${1}) {
${2:# body...}
${2}
}
elsif (${3}) {
${4:# elsif...}
}
else {
${5:# else...}
${5}
}
snippet eif
elsif (${1}) {
${2}
}
# Conditional One-line
snippet xif
@ -40,7 +44,7 @@ snippet xif
# Unless conditional
snippet unless
unless (${1}) {
${2:# body...}
${2}
}
# Unless conditional One-line
snippet xunless
@ -57,7 +61,7 @@ snippet eval
# While Loop
snippet wh
while (${1}) {
${2:# body...}
${2}
}
# While Loop One-line
snippet xwh
@ -65,7 +69,7 @@ snippet xwh
# C-style For Loop
snippet cfor
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:# body...}
${4}
}
# For loop one-line
snippet xfor
@ -73,7 +77,7 @@ snippet xfor
# Foreach Loop
snippet for
foreach my $${1:x} (@${2:array}) {
${3:# body...}
${3}
}
# Foreach Loop One-line
snippet fore
@ -127,7 +131,7 @@ snippet switch
# Anonymous subroutine
snippet asub
sub {
${1:# body }
${1}
}
@ -135,7 +139,7 @@ snippet asub
# Begin block
snippet begin
BEGIN {
${1:# begin body}
${1}
}
# call package function with some parameter
@ -174,7 +178,7 @@ snippet given
# switch-like case
snippet when
when (${1:case}) {
${2:# body}
${2}
}
# hash slice
@ -237,7 +241,7 @@ snippet subpod
=cut
sub ${1:subroutine_name} {
${2:# body...}
${2}
}
# Subroutine signature
snippet parg
@ -318,7 +322,7 @@ snippet trunner
snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift;
${4:# body}
${4}
}
@ -333,7 +337,7 @@ snippet trsub
snippet tprep
sub prep${1:number}_${2:test_case} :Test(startup) {
my $self = shift;
${4:# body}
${4}
}
# cause failures to print stack trace

View File

@ -278,11 +278,11 @@ snippet ifeil
${3:<!-- html... -->}
<?php endif; ?>
${4}
snippet else
snippet el
else {
${1}
}
snippet elseif
snippet eif
elseif (${1:/* condition */}) {
${2}
}

View File

@ -26,7 +26,7 @@ snippet if
if $${1:variable} {
${2}
}
snippet else
snippet el
else {
${1}
}

View File

@ -68,7 +68,7 @@ snippet ife
else
${3}
end
snippet elsif
snippet eif
elsif ${1:condition}
${2}
snippet unless

View File

@ -15,7 +15,7 @@ snippet ifn
${2}
}
#if-else
snippet ifel
snippet ife
if(${1:obj}) {
${2}
} else {
@ -28,6 +28,10 @@ snippet ifelif
} else if(${3:obj}) {
${4}
}
snippet eif
else if(${3:obj}) {
${4}
}
#while loop
snippet while
while (${1:obj}) {

View File

@ -5,7 +5,7 @@ snippet #!
# Process
snippet pro
proc ${1:function_name} {${2:args}} {
${3:#body ...}
${3}
}
#xif
snippet xif
@ -13,19 +13,23 @@ snippet xif
# Conditional
snippet if
if {${1}} {
${2:# body...}
${2}
}
# Conditional if..else
snippet ife
if {${1}} {
${2:# body...}
${2}
} else {
${3:# else...}
}
snippet eif
elseif {${1}} {
${2}
}
# Conditional if..elsif..else
snippet ifee
if {${1}} {
${2:# body...}
${2}
} elseif {${3}} {
${4:# elsif...}
} else {
@ -42,17 +46,17 @@ snippet catch
# While Loop
snippet wh
while {${1}} {
${2:# body...}
${2}
}
# For Loop
snippet for
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
${4:# body...}
${4}
}
# Foreach Loop
snippet fore
foreach ${1:x} {${2:#list}} {
${3:# body...}
${3}
}
# after ms script...
snippet af

View File

@ -19,19 +19,25 @@ snippet t
${3}
endtry
snippet for
for ${1:needle} in ${2:haystack}
for ${1} in ${2}
${3}
endfor
snippet forkv
for [a,b] in items({2})
${3}
unlet a b
endfor
snippet wh
while ${1:condition}
while ${1}
${2}
endw
snippet if
if ${1:condition}
if ${1}
${2}
endif
snippet ife
if ${1:condition}
if ${1}
${2}
else
${3}

View File

@ -12,7 +12,7 @@ snippet ife
else
${3:# statements}
fi
snippet elif
snippet eif
elif ${1:condition} ; then
${2:# statements}
snippet for