Skip to content

Instantly share code, notes, and snippets.

@caiguo37
Forked from MaienM/cucumbertables.vim
Created February 2, 2013 13:50
Show Gist options
  • Save caiguo37/4697456 to your computer and use it in GitHub Desktop.
Save caiguo37/4697456 to your computer and use it in GitHub Desktop.
inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
function! s:ealign()
let p = '^.*=\s.*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment