tilteng / api-style-guide

Best practices for API development at Tilt.
1 stars 0 forks source link

Vertically Aligning Hashes #2

Open tildedave opened 9 years ago

tildedave commented 9 years ago

Are there any editor plugins we can use to easily do this? Might be good to call out in the style section. Presently I do this by hand :frowning:

tildedave commented 9 years ago

ping, help requested

danschmidt5189 commented 9 years ago

Some ST3 packages worth rec'ing:

Here's a simple perltidy runner that captures our req's. (I think, I'm still beta-testing at this point.)

And here is a Sublime Text 3 Build Script for running tests, compiling, tidy-ing, and building a distribution.

ironcamel commented 9 years ago

In vim, I hilight the lines I want to align and then type !column -t. There is probably a better way, but that works for me.

comstud commented 9 years ago

ping @aanari has a good vim setup that I've been meaning to acquire for a long time now.

aanari commented 9 years ago

@comstud Here's how I set it up so that vim automatically aligns on =>:

Plugin 'atsepkov/vim-tabularity'
Plugin 'godlygeek/tabular
...
inoremap => =><Esc>:call tabularity#Align('=>')<cr>a

Source: https://github.com/aanari/dotfiles/blob/master/config/vim/settings.vim#L234

aanari commented 9 years ago

Here are my visual mode and normal mode perltidy mappings for vim as well (,pt to perltidy the whole file or the current visual selection):

vmap <leader>pt :!perltidy<cr>
nmap <leader>pt :%! perltidy<cr>
danschmidt5189 commented 9 years ago

@aanari What are your Perltidy settings? I linked some I've been testing out with Function::Parameters. Might be useful to get that out of "beta" so we can start autoformatting.

amackera commented 9 years ago

In emacs I use align-regexp on = but I haven't looked for any better solutions.