Guest User

Untitled

a guest
Sep 16th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. " The contents of this file are mostly from a Gist by Tim Pope
  2. " (https://gist.github.com/287147) with minor adjustments.
  3.  
  4. inoremap <buffer> <silent> <bar> <bar><esc>:call <sid>TabularizeCucumberTables()<cr>a
  5.  
  6. function! s:TabularizeCucumberTables()
  7. let p = '^\s*|\s.*\s|\s*$'
  8. if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
  9. let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
  10. let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
  11. Tabularize/|/l1
  12. normal! 0
  13. call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
  14. endif
  15. endfunction
Advertisement
Add Comment
Please, Sign In to add comment