Sfoglia il codice sorgente

Add tabular.vim settings

weiyi 10 anni fa
parent
commit
685dc900fb
3 ha cambiato i file con 20 aggiunte e 4 eliminazioni
  1. 17 0
      vim/settings/tabular.vim
  2. 3 3
      vim/vimrc
  3. 0 1
      vim/vimrc.bundles

+ 17 - 0
vim/settings/tabular.vim

@@ -0,0 +1,17 @@
+nmap <leader>a= :Tabularize /=<CR>
+vmap <leader>a= :Tabularize /=<CR>
+nmap <leader>a: :Tabularize /:\zs<CR>
+vmap <leader>a: :Tabularize /:\zs<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

+ 3 - 3
vim/vimrc

@@ -4,9 +4,6 @@ set nocompatible
 " Formatting for JSON files
 au FileType json setlocal equalprg=python\ -m\ json.tool
 
-" Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
-nnoremap <C-b> <C-a>
-
 if has("autocmd")
   " Clear existing autocmd
   autocmd!
@@ -90,6 +87,9 @@ inoremap jk <ESC>
 " Yank from the cursor to the end of the line, to be consistent with C and D.
 nnoremap Y y$
 
+" Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
+nnoremap <C-b> <C-a>
+
 nnoremap <silent> <leader>w :set wrap!<CR>
 
 " Toggle paste mode - no autoindenting of pasted material

+ 0 - 1
vim/vimrc.bundles

@@ -8,7 +8,6 @@
 " Setup Bundle Support {{{
 " Ensure that the ~/.vim/bundle/ system works
 set nocompatible
-filetype on
 filetype off
 set rtp+=~/.vim/bundle/vundle
 call vundle#rc()