tabularize.vim (520B)
1 inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a 2 3 function! s:align() 4 let p = '^\s*|\s.*\s|\s*$' 5 if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) 6 let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) 7 let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) 8 Tabularize/|/l1 9 normal! 0 10 call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) 11 endif 12 endfunction