ruby snippets:
use do dov for both engines drop #TODO comments changing defaults is bad, but I expect ruby folks to expect do to type do .. doo has the advantage to get a completion popup .. but its too long to type The UtiSnips do snippet didn't make sense: the nested placeholder still didn't remove the space after the "do" when deleting it - so it was written badly. Could be fixed, by why bother? Thus learn do and dov and be happy forever. Would Do be a better choice (upper case chars?) Don't know. This was used by UltiSnips. Comment on this commit if you don't like this choice.
This commit is contained in:
parent
80697bea6f
commit
533fe487a1
@ -25,7 +25,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet if "if <condition> ... end"
|
snippet if "if <condition> ... end"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2:# TODO}
|
${2}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -33,9 +33,9 @@ endsnippet
|
|||||||
|
|
||||||
snippet ife "if <condition> ... else ... end"
|
snippet ife "if <condition> ... else ... end"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2:# TODO}
|
${2}
|
||||||
else
|
else
|
||||||
${3:# TODO}
|
${3}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ endsnippet
|
|||||||
|
|
||||||
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
|
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2:# TODO}
|
${2}
|
||||||
elsif ${3:condition}
|
elsif ${3:condition}
|
||||||
${4:# TODO}
|
${4}
|
||||||
else
|
else
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet unless "unless <condition> ... end"
|
snippet unless "unless <condition> ... end"
|
||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -63,9 +63,9 @@ endsnippet
|
|||||||
|
|
||||||
snippet unlesse "unless <condition> ... else ... end"
|
snippet unlesse "unless <condition> ... else ... end"
|
||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${2:# TODO}
|
${2}
|
||||||
else
|
else
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -73,11 +73,11 @@ endsnippet
|
|||||||
|
|
||||||
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
|
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
|
||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${2:# TODO}
|
${2}
|
||||||
elsif ${3:condition}
|
elsif ${3:condition}
|
||||||
${4:# TODO}
|
${4}
|
||||||
else
|
else
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet "\b(de)?f" "def <name>..." r
|
snippet "\b(de)?f" "def <name>..." r
|
||||||
def ${1:function_name}${2: ${3:*args}}
|
def ${1:function_name}${2: ${3:*args}}
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet defi "def initialize ..."
|
snippet defi "def initialize ..."
|
||||||
def initialize${1: ${2:*args}}
|
def initialize${1: ${2:*args}}
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -101,23 +101,23 @@ endsnippet
|
|||||||
|
|
||||||
snippet defr "def <name> ... rescue ..."
|
snippet defr "def <name> ... rescue ..."
|
||||||
def ${1:function_name}${2: ${3:*args}}
|
def ${1:function_name}${2: ${3:*args}}
|
||||||
${4:# TODO}
|
${4}
|
||||||
rescue
|
rescue
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet For "(<from>..<to>).each { |<i>| <block> }"
|
snippet For "(<from>..<to>).each { |<i>| <block> }"
|
||||||
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
|
(${1:from}..${2:to}).each { |${3:i}| ${4} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
||||||
(${1:from}..${2:to}).each do |${3:i}|
|
(${1:from}..${2:to}).each do |${3:i}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -138,42 +138,42 @@ endsnippet
|
|||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }
|
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
|
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} }
|
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
|
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
|
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
|
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -194,56 +194,56 @@ endsnippet
|
|||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
|
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
|
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
|
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
|
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
|
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
|
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
|
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
|
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
|
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
|
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
|
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
|
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Each "<elements>.each { |<element>| <block> }"
|
snippet Each "<elements>.each { |<element>| <block> }"
|
||||||
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
|
${1:elements}.each { |${2:${1/s$//}}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet each "<elements>.each do |<element>| <block> end"
|
snippet each "<elements>.each do |<element>| <block> end"
|
||||||
${1:elements}.each do |${2:${1/s$//}}|
|
${1:elements}.each do |${2:${1/s$//}}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -251,14 +251,14 @@ endsnippet
|
|||||||
|
|
||||||
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
|
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
|
||||||
each_slice(${1:2}) do |${2:slice}|
|
each_slice(${1:2}) do |${2:slice}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
|
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
|
||||||
each_slice(${1:2}) { |${2:slice}| ${3:# TODO} }
|
each_slice(${1:2}) { |${2:slice}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }
|
`}| ${2} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }
|
`}| ${2} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }
|
`}| ${2} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`},${2:i}| ${3:# TODO} }$0
|
`},${2:i}| ${3} }$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`},${2:i}|
|
`},${2:i}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -387,14 +387,14 @@ endsnippet
|
|||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }
|
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
|
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -424,26 +424,24 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r
|
|||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
# comments about do and dov see snippets/ruby.snippets
|
||||||
|
snippet do "do ... end" i
|
||||||
snippet do "do |<key>| ... end" i
|
|
||||||
do ${1:|${2:key}|}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Do "do ... end" i
|
|
||||||
do
|
do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
snippet dov "do |<key>| ... end" i
|
||||||
|
do |${0:v}|
|
||||||
|
$1
|
||||||
|
end
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet until "until <expression> ... end"
|
snippet until "until <expression> ... end"
|
||||||
until ${1:expression}
|
until ${1:expression}
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -451,7 +449,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet Until "begin ... end until <expression>"
|
snippet Until "begin ... end until <expression>"
|
||||||
begin
|
begin
|
||||||
${0:# TODO}
|
${0}
|
||||||
end until ${1:expression}
|
end until ${1:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -459,7 +457,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet while "while <expression> ... end"
|
snippet while "while <expression> ... end"
|
||||||
while ${1:expression}
|
while ${1:expression}
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -467,7 +465,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet While "begin ... end while <expression>"
|
snippet While "begin ... end while <expression>"
|
||||||
begin
|
begin
|
||||||
${0:# TODO}
|
${0}
|
||||||
end while ${1:expression}
|
end while ${1:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -493,9 +491,9 @@ endsnippet
|
|||||||
|
|
||||||
snippet begin "begin ... rescue ... end"
|
snippet begin "begin ... rescue ... end"
|
||||||
begin
|
begin
|
||||||
${1:# TODO}
|
${1}
|
||||||
rescue
|
rescue
|
||||||
${0:# TODO}
|
${0}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
@ -413,13 +413,17 @@ snippet seld
|
|||||||
end
|
end
|
||||||
snippet lam
|
snippet lam
|
||||||
lambda { |${1:args}| ${2} }
|
lambda { |${1:args}| ${2} }
|
||||||
snippet doo
|
# I'm pretty sure that ruby users expect do to expand to do .. end
|
||||||
|
snippet do
|
||||||
do
|
do
|
||||||
${1}
|
${1}
|
||||||
end
|
end
|
||||||
|
# this is for one or more variables. typing a ", " is that cheap that it may
|
||||||
|
# not be worth adding another snippet. should 0/1 placeholders change order?
|
||||||
|
# its a good idea to think about the var name, so use it first
|
||||||
snippet dov
|
snippet dov
|
||||||
do |${1:variable}|
|
do |${0:v}|
|
||||||
${2}
|
${1}
|
||||||
end
|
end
|
||||||
snippet :
|
snippet :
|
||||||
:${1:key} => ${2:"value"}${3}
|
:${1:key} => ${2:"value"}${3}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user