diff --git a/vim/bundles.vim b/vim/bundles.vim index cc4f48b..d2458d6 100644 --- a/vim/bundles.vim +++ b/vim/bundles.vim @@ -36,24 +36,51 @@ call vundle#rc() Bundle 'tjennings/git-grep-vim' " }}} +" Text objects {{{ + Bundle 'kana/vim-textobj-user' + Bundle 'nelstrom/vim-textobj-rubyblock' + Bundle 'michaeljsmith/vim-indent-object' + Bundle 'argtextobj.vim' +" }}} + " Utility {{{ Bundle 'tpope/vim-bundler' Bundle 'Tabular' - " These need more work: - " TODO: - keep cursor position - " - don't align equals sign if inside hashrocket - " inoremap => =>:Tab /=> i - " inoremap = =:Tab /=i - map a= :Tab /= - map a> :Tab /=> - map a: :Tab /\z: - vmap a= :Tab /= - vmap a> :Tab /=> - vmap a: :Tab /\z: - imap a= :Tab /=i - imap a> :Tab /=>i - imap a: :Tab /\z:i + if exists(":Tabularize") + map a= :Tab /= + map a> :Tab /=> + map a: :Tab /\z: + + vmap a= :Tab /= + vmap a> :Tab /=> + vmap a: :Tab /\z: + + imap a= :Tab /=i + imap a> :Tab /=>i + imap a: :Tab /\z:i + + " Auto-align + "" Cucumber + 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 + + "" Assignments etc + " These need more work: + " TODO: - keep cursor position + " - don't align equals sign if inside hashrocket + " inoremap => =>:Tab /=> i + " inoremap = =:Tab /=i + endif Bundle 'scrooloose/nerdcommenter' let NERDSpaceDelims = 1 " space between comment and code