What is the most efficient way to change Ruby's hashrocket notation into the name: 'value'
notation in vim?
Some examples:
{
:id => site.id,
:primary_domain => site.name,
:wp_admin_url => site.wp_admin_url
}
{
id: site.id,
primary_domain: site.name,
wp_admin_url: site.wp_admin_url
}
{ :id => site.id, :primary_domain => site.name }
{ id: site.id, primary_domain: site.name }
Site.find_by(:access_token => params[:access_token], :primary_domain => params[:primary_domain])
Site.find_by(access_token: params[:access_token], primary_domain:params[:primary_domain])
Do you have a macro for this? Some more efficient sequence then mine? Use search-replace? The most efficient I can come up with, is quite manual and requires some repetiotion:
ft:xpldf>
go to the first :
, delete it and paste it after the word, then move one character forward and delete the =>
part.
This needs to be repeated for each :name => value
part in a Hash. And cannot be simply ran N times, because there might very well be some :symbols
that need to remain, like in the last example.
How do you quickly change from the Hashrocket notation?