Skip to content

Instantly share code, notes, and snippets.

View pivotal-casebook's full-sized avatar

pivotal-casebook

View GitHub Profile
@pivotal-casebook
pivotal-casebook / cucumber.vim
Created December 16, 2011 16:14 — forked from tpope/cucumbertables.vim
tpope's Tabular-for-Cucumber, renamed for ftpluginability
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))