From a3b5800c8c2cc15ba2cd82336d24a9bb6c1ab4c4 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sat, 26 Nov 2016 20:30:57 +0100 Subject: [PATCH] Tabular conf --- vimrc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vimrc b/vimrc index babba6f..17c9181 100644 --- a/vimrc +++ b/vimrc @@ -355,6 +355,19 @@ map :w map :call PhpInsertUse() nnoremap :GundoToggle +inoremap :call align()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 """""""""""""""""""""""""""