# HG changeset patch # User zegervdv # Date 1406835515 -7200 # Node ID 8a5464ec3c293ceb640964729a2e4fffee1a162a # Parent d282fe62a21548211d71e255c23e59a08c689c96 Add vim mappings from https://bitbucket.org/sjl/dotfiles diff -r d282fe62a215 -r 8a5464ec3c29 vimrc --- a/vimrc Wed Jul 30 21:03:24 2014 +0200 +++ b/vimrc Thu Jul 31 21:38:35 2014 +0200 @@ -53,6 +53,7 @@ set wildmenu set wildmode=full set ttyfast +set lazyredraw set diffopt+=iwhite @@ -85,7 +86,7 @@ set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex " set list -" set listchars=tab:▸\ ,eol:¬ +set listchars=tab:▸\ ,eol:¬ " }}} " Custom remaps and tricks {{{ " When editing a file, always jump to the last known cursor position. @@ -108,7 +109,13 @@ map k gk " remap tag-search to better place -nmap +" nmap +function! JumpToTagInSplit() + execute "normal! \v\mzzMzvzz15\" + execute "keepjumps normal! `z" + Pulse +endfunction +nnoremap :silent! call JumpToTag() " Jump to end of line in insert mode inoremap I @@ -129,6 +136,15 @@ nmap / /\v cmap s/ s/\v +" Keep search matches in the middle of the window. +nnoremap n nzzzv +nnoremap N Nzzzv + +" Show local search results in quickfix +nnoremap / :execute 'vimgrep /'.@/.'/g %':copen +nnoremap ? :Ag +" nnoremap ? :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "","") . "'" + " Clear highlight nnoremap n :nohlsearch @@ -137,12 +153,7 @@ nnoremap % vnoremap % -" Move between windows -nnoremap -nnoremap -nnoremap j -nnoremap - +" Move between tabs nnoremap :tabprevious nnoremap :tabnext nnoremap :tabfirst @@ -170,6 +181,9 @@ redraw endfunction +" Highlight VCS conflict markers +match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' + " Swap v and CTRL-V nnoremap v nnoremap v @@ -200,6 +214,37 @@ au FileType c setl foldmethod=syntax +au VimResized * exe "normal! \=" + +cnoremap +cnoremap + +" Swap backticks and quotes +nnoremap ` ' +nnoremap ' ` + +" Note that this will overwrite the contents of the z mark. I never use it, but +" if you do you'll probably want to use another mark. +inoremap mzgUiw`za + +nnoremap ev :vsplit $MYVIMRC + +function! MyFoldText() " {{{ + let line = getline(v:foldstart) + + let nucolwidth = &fdc + &number * &numberwidth + let windowwidth = winwidth(0) - nucolwidth - 3 + let foldedlinecount = v:foldend - v:foldstart + + " expand tabs into spaces + let onetab = strpart(' ', 0, &tabstop) + let line = substitute(line, '\t', onetab, 'g') + + let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) + let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' +endfunction " }}} +set foldtext=MyFoldText() " }}} @@ -426,4 +471,3 @@ source ~/.vimrc.local endif -nnoremap o