Skip to content

Instantly share code, notes, and snippets.

@tpope
Created January 26, 2010 19:51
Show Gist options
  • Save tpope/287147 to your computer and use it in GitHub Desktop.
Save tpope/287147 to your computer and use it in GitHub Desktop.

Revisions

  1. tpope created this gist Jan 26, 2010.
    12 changes: 12 additions & 0 deletions cucumbertables.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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('.'))
    endif
    endfunction