Map commands in .vimrc
to align Cucumber complient Feature File steps on the space after the keywords:
" Use Tabularize to set shortcute `,as` to align on feature file step keywords
let mapleader=','
nmap <Leader>as :Tab /^\W*[Given\|When\|Then\|And][a-zA-Z]*\zs\W/r0c0l0<CR>
vmap <Leader>as :Tab /^\W*[Given\|When\|Then\|And][a-zA-Z]*\zs\W/r0c0l0<CR>
So this:
Feature: VIM Tabularize Align Example
Scenario Outline: Tabularize can align steps
Given I have a foo
When I do bar
And bar responds
Then the bar response has <resp-obj>
And the bar response is successful
Examples: Bar Responses
| resp-obj |
| baz |
| egg. |
| spam. |
Becomes this:
Feature: VIM Tabularize Align Example
Scenario Outline: Tabularize can align steps
Given I have a foo
When I do bar
And bar responds
Then the bar response has <resp-obj>
And the bar response is successful
Examples: Bar Responses
| resp-obj |
| baz |
| egg. |
| spam. |
My regex-fu is weak, so this can almost certainly be optimized and improved