From 676deabc4c13df63fcd5fc7e78ee36070bc238b2 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Sat, 5 Apr 2014 14:46:42 -0500 Subject: [PATCH] .vimrc: Cleanup unused mappings, misc tweaks --- .vimrc | 67 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/.vimrc b/.vimrc index bc715df..cfbeadf 100644 --- a/.vimrc +++ b/.vimrc @@ -181,14 +181,6 @@ vnoremap gj vnoremap gk inoremap gj inoremap gk -" buffer navigation -nnoremap :bnext -nnoremap :bprev -" easier moving cursor between split-windows -nnoremap h -nnoremap j -nnoremap k -nnoremap l " do not menu with left / right in command line cnoremap cnoremap @@ -196,6 +188,8 @@ cnoremap " reflow paragraph with Q in normal and visual mode nnoremap Q gqap vnoremap Q gq +" remap U to for easier redo +nnoremap U " make Y consistent with C (c$) and D (d$) nnoremap Y y$ " disable default vim regex handling for searching @@ -207,16 +201,10 @@ vnoremap > >gv " to turn off highlighting and clear any message already displayed. nnoremap :nohlsearch:echo -" to pastetoggle, to turn-off autoindent when pasting from system clipboard -nnoremap :set paste! paste? -set pastetoggle= " to toggle NERDTree nnoremap :NERDTreeToggle " to toggle Gundo nnoremap :GundoToggle -" to toggle spell-check -nnoremap :setlocal spell! spell? -inoremap :setlocal spell! spell? " leader-based keyboard shortcuts let mapleader = "," @@ -238,13 +226,6 @@ nmap gp :Gpush nmap cd :lcd %:h " toggle diffmode for a buffer nmap df :call DiffToggle() -function! DiffToggle() - if &diff - diffoff - else - diffthis - endif -endfunction " quickly edit/reload vimrc nmap ev :edit $MYVIMRC nmap sv :source $MYVIMRC @@ -253,15 +234,15 @@ nmap fc /\v^[<=>]{7}( .*\|$) " toggle hlsearch nmap hs :set hlsearch! hlsearch? " upper/lower word -nmap u mQviwU`Q -nmap l mQviwu`Q +nmap wu mQviwU`Q +nmap wl mQviwu`Q " upper/lower first char of word -nmap U mQgewvU`Q -nmap L mQgewvu`Q +nmap wU mQgewvU`Q +nmap wL mQgewvu`Q " smart paste - enable paste-mode and paste contents of system clipboard map p :set pasteo"*]p:set nopaste " strip all trailing whitespace in file -nmap s :call whitespace#strip_trailing() +nmap sw :call whitespace#strip_trailing() " toggle spell-check nmap sp :setlocal spell! spell? " set text wrapping toggles @@ -269,6 +250,39 @@ nmap tw :set wrap! wrap? " set list-whitespace-chars toggle nmap ws :set list! list? +" -------------------------------------------------------------------------- +" Functions +" -------------------------------------------------------------------------- + +" Toggle diff-mode +function! DiffToggle() + if &diff + diffoff + else + diffthis + endif +endfunction + +" Make a scratch buffer with all of the leader keybindings. +" Adapted from http://ctoomey.com/posts/an-incremental-approach-to-vim/ +function! ListLeaders() + silent! redir @b + silent! nmap + silent! redir END + silent! new + silent! set buftype=nofile + silent! set bufhidden=hide + silent! setlocal noswapfile + silent! put! b + silent! g/^s*$/d + silent! %s/^.*,// + silent! normal ggVg + silent! sort + silent! let lines = getline(1,"$") + silent! normal +endfunction +command! ListLeaders :call ListLeaders() + " ---------------------------------------------------------------------------- " Plugin Settings " ---------------------------------------------------------------------------- @@ -285,6 +299,7 @@ let g:ctrlp_cache_dir = $HOME.'/.vim/.cache/ctrlp' " --------------------------------------------------------------------------- augroup vimrc_autocmds + " clear auto command group so we don't define it multiple times autocmd! " jump to last position of buffer when opening (but not for commit messages) au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") | -- 2.45.2