Skip to content

Instantly share code, notes, and snippets.

@cstrahan
Forked from tpope/cucumbertables.vim
Created April 5, 2012 21:57
Show Gist options
  • Select an option

  • Save cstrahan/2314502 to your computer and use it in GitHub Desktop.

Select an option

Save cstrahan/2314502 to your computer and use it in GitHub Desktop.
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
@j3j3

j3j3 commented May 16, 2012

Copy link
Copy Markdown

What an amazing gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment