Today, I Learned...

by Justin Campbell

< All

Use vim-ruby-refactoring to quickly perform common refactorings. My 2 favorites:

Post-conditionals

unless current_user
  "Hello guest!"
end

:RConvertPostConditional or <leader>rcpc

"Hello guest!" unless current_user

Local variables

raise if current > values.to_a.mean * 2

:RExtractLocalVariable or <leader>relv, and then name your variable

double_the_mean = values.to_a.mean * 2

raise if current > double_the_mean

See more examples here.

November 13th, 2012