Created
February 26, 2013 08:20
-
-
Save gpakosz/5036935 to your computer and use it in GitHub Desktop.
settings for vim's tabular plugin: https://github.com/godlygeek/tabular see http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" -- tabular settings ---------------------------------------------------------- | |
nnoremap <silent> <Leader>a= :Tabularize /=<CR> | |
vnoremap <silent> <Leader>a= :Tabularize /=<CR> | |
nnoremap <silent> <Leader>a: :Tabularize /:\zs<CR> | |
vnoremap <silent> <Leader>a: :Tabularize /:\zs<CR> | |
" auto align on pipes | |
inoremap <silent> <Bar> <Bar><Esc>:call <SID>pipe_align()<CR>a | |
function! s:pipe_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 | |
" auto align on equals (often annoying, kept here for reference) | |
" inoremap <silent> = =<Esc>:call <SID>equal_align()<CR>a | |
" function! s:equal_align() | |
" 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