]> git.rmz.io Git - dotfiles.git/blobdiff - vim/vimrc
vim: show trailing space on first start
[dotfiles.git] / vim / vimrc
index ae76bc81b176a38e199929eaf303ce40971f8243..10e5770e3f22338bc5a9dcc8546e3e0fc47bc2dc 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -27,7 +27,6 @@ Plugin 'kshenoy/vim-signature'
 Plugin 'majutsushi/tagbar'
 Plugin 'raimondi/delimitmate'
 " Plugin 'rking/ag.vim'
 Plugin 'majutsushi/tagbar'
 Plugin 'raimondi/delimitmate'
 " Plugin 'rking/ag.vim'
-Plugin 'scrooloose/nerdtree'
 Plugin 'scrooloose/syntastic'
 Plugin 'shougo/vimproc.vim'
 Plugin 'shougo/unite.vim'
 Plugin 'scrooloose/syntastic'
 Plugin 'shougo/vimproc.vim'
 Plugin 'shougo/unite.vim'
@@ -66,8 +65,11 @@ Plugin 'justinmk/vim-sneak'
 Plugin 'chrisbra/checkattach'
 Plugin 'nathanaelkane/vim-indent-guides'
 Plugin 'alx741/vinfo'
 Plugin 'chrisbra/checkattach'
 Plugin 'nathanaelkane/vim-indent-guides'
 Plugin 'alx741/vinfo'
+Plugin 'octol/vim-cpp-enhanced-highlight'
 Plugin 'vim-scripts/mediawiki.vim'
 Plugin 'vim-scripts/mediawiki.vim'
+Plugin 'vim-scripts/replacewithregister'
 Plugin 'tpope/vim-abolish'
 Plugin 'tpope/vim-abolish'
+Plugin 'derekwyatt/vim-protodef'
 
 " remove entries first
 set runtimepath -=$HOME/.vim
 
 " remove entries first
 set runtimepath -=$HOME/.vim
@@ -85,6 +87,9 @@ syntax on
 colorscheme badwolf
 
 " options {{{1
 colorscheme badwolf
 
 " options {{{1
+" put $ and the end of text to be replaced with 'cw' and the likes
+set cpoptions+=$
+
 " moving around, searching and patterns {{{2
 set incsearch           " show match for partly typed search command
 set ignorecase          " ignore case when using a search pattern
 " moving around, searching and patterns {{{2
 set incsearch           " show match for partly typed search command
 set ignorecase          " ignore case when using a search pattern
@@ -95,10 +100,10 @@ set nostartofline       " don't move the cursor to the first non-blank char of a
 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
 
 " displaying text {{{2
 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
 
 " displaying text {{{2
-set scrolloff=5                 " number of screen lines to show around the cursor
 set nowrap                      " long lines wrap
 set linebreak                   " wrap long lines at a character in 'breakat'
 set showbreak=↪                 " show these chars for wrapped lines
 set nowrap                      " long lines wrap
 set linebreak                   " wrap long lines at a character in 'breakat'
 set showbreak=↪                 " show these chars for wrapped lines
+set breakindent                 " preserve indentation in wrapped text
 
 set lazyredraw                  " don't redraw while executing macros
 
 
 set lazyredraw                  " don't redraw while executing macros
 
@@ -106,12 +111,14 @@ set list                        " show chars defined in 'listchars'
 set listchars=tab:❭\            " list of strings used for list mode
 set listchars+=extends:❯,precedes:❮
 " Only shown when not in insert mode
 set listchars=tab:❭\            " list of strings used for list mode
 set listchars+=extends:❯,precedes:❮
 " Only shown when not in insert mode
+au InsertLeave * :set listchars+=trail:·
 augroup trailing
     au!
     au InsertEnter * :set listchars-=trail:·
     au InsertLeave * :set listchars+=trail:·
 augroup END
 
 augroup trailing
     au!
     au InsertEnter * :set listchars-=trail:·
     au InsertLeave * :set listchars+=trail:·
 augroup END
 
+set scrolloff=5                 " number of screen lines to show around the cursor
 set sidescroll=1                " number of collumns to scroll
 set sidescrolloff=1             " don't scroll over the listchars
 
 set sidescroll=1                " number of collumns to scroll
 set sidescrolloff=1             " don't scroll over the listchars
 
@@ -178,11 +185,15 @@ set pastetoggle=<F11>           " key sequence to toggle paste mode
 set foldmethod=marker           " folding type
 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 set foldmethod=marker           " folding type
 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
+" open folds when jumping to line
+set foldopen+=jump
+
 " save and restore folds
 set viewoptions=cursor          " only save cursor position
 
 " diff mode {{{2
 " save and restore folds
 set viewoptions=cursor          " only save cursor position
 
 " diff mode {{{2
-set diffopt=filler,vertical
+" vertical splits and ignore white space in diffs
+set diffopt=filler,vertical,iwhite
 
 " reading and writing files {{{2
 set modeline                    " read modelines
 
 " reading and writing files {{{2
 set modeline                    " read modelines
@@ -228,7 +239,7 @@ set wildignore+=*.pyc                            " Python byte code
 set wildignore+=*.orig                           " Merge resolution files
 
 " various {{{2
 set wildignore+=*.orig                           " Merge resolution files
 
 " various {{{2
-set virtualedit=block           " let cursor move past last char in <C-V> mode
+set virtualedit=all             " let cursor move past last char in <C-V> mode
 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 set viewdir=$XDG_CACHE_HOME/vim/view//
 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 set viewdir=$XDG_CACHE_HOME/vim/view//
@@ -330,10 +341,10 @@ vnoremap H ^
 vnoremap L g_
 
 " Heresy, emacs insert bindings
 vnoremap L g_
 
 " Heresy, emacs insert bindings
-inoremap <c-a> <esc>I
-inoremap <c-e> <esc>A
-cnoremap <c-a> <home>
-cnoremap <c-e> <end>
+inoremap <C-A> <Esc>I
+inoremap <C-E> <Esc>A
+cnoremap <C-A> <Home>
+cnoremap <C-E> <End>
 
 " proper movement when lines are wrapped
 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
 
 " proper movement when lines are wrapped
 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
@@ -402,11 +413,18 @@ autocmd BufWinLeave *.* mkview
 autocmd BufWinEnter *.* silent loadview
 
 " save with sudo
 autocmd BufWinEnter *.* silent loadview
 
 " save with sudo
-cnoremap w!! w !sudo tee % > /dev/null
+cabbrev w!! w !sudo tee % > /dev/null
 
 " uppercase previous word
 inoremap <C-C> <Esc>gUiwgi
 
 
 " uppercase previous word
 inoremap <C-C> <Esc>gUiwgi
 
+" http://git.io/v3ZeU
+nmap <silent> <leader>qq :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
+
+" commands {{{1
+command! Cd lcd %:h
+command! Cr execute('lcd ' . FindGitDirOrHome())
+
 " plugins options {{{1
 " airline {{{2
 let g:airline#extensions#whitespace#enabled = 1
 " plugins options {{{1
 " airline {{{2
 let g:airline#extensions#whitespace#enabled = 1
@@ -453,15 +471,6 @@ nmap <silent> cog <Plug>IndentGuidesToggle
 nmap <silent> [og <Plug>IndentGuidesEnable
 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 nmap <silent> [og <Plug>IndentGuidesEnable
 nmap <silent> ]og <Plug>IndentGuidesDisable
 
-" NERDTree {{{2
-" open/close NERDTree with \e
-nmap <Leader>e :NERDTreeToggle<CR>
-nmap <F6> :NERDTreeToggle<CR>
-" <space> to open files/dirs
-let NERDTreeMapActivateNode='l'
-" close vim if only NERDTree is open
-autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
-
 " python-mode {{{2
 
 let g:pymode_rope_completion = 0
 " python-mode {{{2
 
 let g:pymode_rope_completion = 0
@@ -541,6 +550,7 @@ if executable('ag')
     let g:unite_source_grep_recursive_opt = ''
 end
 nnoremap <silent> [unite]a :<C-u>Unite grep -input=\12\17<CR>
     let g:unite_source_grep_recursive_opt = ''
 end
 nnoremap <silent> [unite]a :<C-u>Unite grep -input=\12\17<CR>
+command! -nargs=1 Ag Unite grep -input=<args>
 
 " unite-file_rec {{{3
 if executable('ag')
 
 " unite-file_rec {{{3
 if executable('ag')
@@ -590,6 +600,7 @@ nnoremap <leader>jd :YcmCompleter GoTo<CR>
 " vim-easy-align {{{2
 " start interactive EasyAlign in visual mode
 vmap <Enter> <Plug>(EasyAlign)
 " vim-easy-align {{{2
 " start interactive EasyAlign in visual mode
 vmap <Enter> <Plug>(EasyAlign)
+nmap ga <Plug>(EasyAlign)
 
 " vim-json {{{2
 let g:vim_json_syntax_conceal = 0
 
 " vim-json {{{2
 let g:vim_json_syntax_conceal = 0
@@ -679,3 +690,23 @@ endfunction
 nnoremap <silent> coS :call SwitchSpell()<CR>
 " fix spelling with first choice
 nnoremap <Leader>f 1z=
 nnoremap <silent> coS :call SwitchSpell()<CR>
 " fix spelling with first choice
 nnoremap <Leader>f 1z=
+
+" gitdir or home {{{2
+" from derek wyatt:
+" http://git.io/v3GAV
+function! FindGitDirOrHome()
+  let filedir = expand('%:p:h')
+  if isdirectory(filedir)
+    let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
+    let gitdir = system(cmd)
+    if strlen(gitdir) == 0
+      return '~'
+    else
+      return gitdir[:-2]
+    endif
+  else
+    return '~'
+  endif
+endfunction
+
+" vim:set et sw=2 ts=2 tw=78: