Turn a list of attributes into symbols in vim
I pasted in a list of columns from a spec document, so I had something like this (only it was a much larger list of attributes:
module Foo
  Bar = Struct.new(
    Order Number
    Line Item
    Date
    Amount
  )
end
I used the following
:3,6!ruby  -ne'puts $_.gsub(/\b \b/,"_").sub(/(\s+)(.+)/, "\\1:\\2,").downcase'
To turn it into this
module Foo
  Bar = Struct.new(
    :order_number,
    :line_item,
    :date,
    :amount,
  )
endWritten by Amiel Martin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Ruby 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#