One style-guide idea I try to maintain is sticking to a reasonable line length. 72 characters, 80 characters, whatever your preference; long lines are hard to read. They’re a code smell. They need to have a reason for existing.
A task I find myself repeating a lot to achieve this is breaking apart Ruby blocks and hashes into multiple lines, with a combination of jumping forward, entering insert mode, and hitting enter. Turning this:
FactoryGirl.create(:developer, username: 'jake_skid', superpower: 'technical writing and style-guide compliance')
superpower: 'technical writing and style-guide compliance'
This task has been automated for me by the Splitjoin plugin for Vim, which is included in the Hashrocket dotfiles. Typing
gS in normal mode over the first example turns it into the second example. It’s opinionated, and probably won’t satisfy every tangent of your personal style (I’d leave off the curly braces and add a trailing comma, for instance). But it’s already saved me a lot of time.
h/t Dorian Karter