" Plugin 'jalcine/cmake.vim'
" Plugin 'powerman/vim-plugin-viewdoc'
+" staging
" find an alternative (latex-box? Automatic Latex Plugin?)
Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex'
" Plugin 'lokaltog/vim-easymotion'
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/replacewithregister'
+Plugin 'tpope/vim-abolish'
+Plugin 'derekwyatt/vim-protodef'
" remove entries first
set runtimepath -=$HOME/.vim
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
set lazyredraw " don't redraw while executing macros
set list " show chars defined in 'listchars'
-set listchars=tab:â\96¸\ " list of strings used for list mode
+set listchars=tab:â\9d\ " list of strings used for list mode
set listchars+=extends:❯,precedes:❮
" Only shown when not in insert mode
augroup trailing
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
-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
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//
nnoremap g; g;zzzv
nnoremap g, g,zzzv
nnoremap <c-o> <c-o>zzzv
+nnoremap <c-i> <c-i>zzzv
" Not using the default mappings of 'To line from top/bottom'
noremap H ^
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')
" break undo sequence before removing word
inoremap <C-W> <C-G>u<C-W>
-nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
-nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
-nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
-nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
+nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
+nnoremap [oe :set expandtab<CR>
+nnoremap ]oe :set noexpandtab<CR>
+
+for idt in range(1,8)
+ exe 'nnoremap co'.idt.' :set tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
+endfor
" space will toggle current fold in normal mode
nnoremap <leader><Space> za
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
+" 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
nnoremap <silent> <Leader>ff :FSHere<CR>
nnoremap <silent> <Leader>fl :FSRight<CR>
nnoremap <silent> <Leader>fh :FSLeft<CR>
+nnoremap <silent> <Leader>fj :FSBelow<CR>
+nnoremap <silent> <Leader>fk :FSAbove<CR>
nnoremap <silent> <Leader>fL :FSSplitRight<CR>
nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
+nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
+nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
" fugitive {{{2
nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<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')
" 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
nmap <leader>ef :call EditConfig('ftplugin')<CR>
nmap <leader>es :call EditConfig('syntax')<CR>
nmap <leader>ei :call EditConfig('indent')<CR>
-nmap <leader>eu :UltiSnipsEdit<CR>
+nmap <leader>eu :UltiSnipsEdit<CR>:lcd %:p:h<CR>
" spell check {{{2
" http://tex.stackexchange.com/a/52932
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: