Improve ruby snippets (only for indentation)

This commit is contained in:
ujihisa 2013-12-29 19:51:13 -08:00
parent f82c5e1edf
commit fe636d7684

View File

@ -1,133 +1,133 @@
snippet if snippet if
abbr if ... end abbr if ... end
if ${1:#:condition} if ${1:#:condition}
${2:TARGET} ${2:TARGET}
end end
snippet def snippet def
abbr def ... end abbr def ... end
def ${1:#:method_name} def ${1:#:method_name}{}
${2:TARGET} ${2:TARGET}
end end
snippet defrescue snippet defrescue
alias defr alias defr
abbr def ... rescue ... end abbr def ... rescue ... end
def ${1:#:method_name} def ${1:#:method_name}
${2:TARGET} ${2:TARGET}
rescue ${3:#:StandardError} => ${4:error} rescue ${3:#:StandardError} => ${4:error}
${5} ${5}
end end
snippet do snippet do
abbr do ... end abbr do ... end
do do
${1:TARGET} ${1:TARGET}
end end
snippet dovar snippet dovar
abbr do |var| ... end abbr do |var| ... end
do |${1:#:var}| do |${1:#:var}|
${2:TARGET} ${2:TARGET}
end end
snippet block snippet block
abbr { ... } abbr { ... }
{ {
${1:TARGET} ${1:TARGET}
} }
snippet blockvar snippet blockvar
abbr {|var| ... } abbr {|var| ... }
{|${1:#:var}| {|${1:#:var}|
${2:TARGET} ${2:TARGET}
} }
snippet fileopen snippet fileopen
abbr File.open(filename) do ... end abbr File.open(filename) do ... end
File.open(${1:#:filename}, '${2:#:mode}') do |${3:io}| File.open(${1:#:filename}, '${2:#:mode}') do |${3:io}|
${0:TARGET} ${0:TARGET}
end end
snippet edn snippet edn
abbr => end? abbr => end?
end end
snippet urlencode snippet urlencode
# coding: utf-8 # coding: utf-8
require 'erb' require 'erb'
puts ERB::Util.url_encode '${1}' puts ERB::Util.url_encode '${1}'
snippet encoding snippet encoding
alias enc alias enc
# coding: utf-8 # coding: utf-8
${0} ${0}
snippet each snippet each
options word options word
each { |${1:#:variable}| ${2} } each { |${1:#:variable}| ${2} }
snippet each_do snippet each_do
options word options word
each do |${1:#:variable}| each do |${1:#:variable}|
${2} ${2}
end end
snippet each_byte snippet each_byte
options word options word
each_byte {|${1:#:variable}| ${2} } each_byte {|${1:#:variable}| ${2} }
snippet each_char snippet each_char
options word options word
each_char {|${1:#:variable}| ${2} } each_char {|${1:#:variable}| ${2} }
snippet each_index snippet each_index
options word options word
each_index {|${1:#:variable}| ${2} } each_index {|${1:#:variable}| ${2} }
snippet each_key snippet each_key
options word options word
each_key {|${1:#:variable}| ${2} } each_key {|${1:#:variable}| ${2} }
snippet each_line snippet each_line
options word options word
each_line {|${1:#:variable}| ${2} } each_line {|${1:#:variable}| ${2} }
snippet each_with_index snippet each_with_index
options word options word
each_with_index {|${1:#:variable}| ${2} } each_with_index {|${1:#:variable}| ${2} }
snippet map snippet map
options word options word
map {|${1:#:variable}| ${2} } map {|${1:#:variable}| ${2} }
snippet sort snippet sort
options word options word
sort {|${1:#:variable}| ${2} } sort {|${1:#:variable}| ${2} }
snippet sort_by snippet sort_by
options word options word
sort_by {|${1:#:variable}| ${2} } sort_by {|${1:#:variable}| ${2} }
snippet lambda snippet lambda
options word options word
-> (${1:#:args}) { ${2} } -> (${1:#:args}) { ${2} }
snippet lambda-keyword snippet lambda-keyword
options word options word
lambda {|${1:#:args}| ${2} } lambda {|${1:#:args}| ${2} }
snippet main snippet main
options head options head
if __FILE__ == \$0 if __FILE__ == \$0
${0:TARGET} ${0:TARGET}
end end
# This idiom is only for legacy ruby such as 1.9.3 # This idiom is only for legacy ruby such as 1.9.3
snippet filedir-legacy-compatibility snippet filedir-legacy-compatibility
alias __dir__ alias __dir__
abbr File.dirname(...) abbr File.dirname(...)
File.dirname(File.expand_path(__FILE__)) File.dirname(File.expand_path(__FILE__))
snippet glob snippet glob
options head options head
@ -144,3 +144,5 @@ options head
else else
${4} ${4}
end end
# vim:set et ts=2 sts=2 sw=2 tw=0: