Tabular conf

This commit is contained in:
Simon Vieille 2016-11-26 20:30:57 +01:00
parent 1ee3009037
commit a3b5800c8c
1 changed files with 13 additions and 0 deletions

13
vimrc
View File

@ -355,6 +355,19 @@ map <c-s> :w<CR>
map <F6> :call PhpInsertUse()<CR>
nnoremap <F5> :GundoToggle<CR>
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
"""""""""""""""""""""""""""
" UI AND EDITION
"""""""""""""""""""""""""""