" Python Calculator command! -nargs=+ Calc :r! python -c "from math import *; print " " I frequently type :Q or :WQ, etc instead of :q, :wq command! WQA :wqa command! WqA :wqa command! WQa :wqa command! Wqa :wqa command! WA :wa command! Wa :wa command! WQ :wq command! Wq :wq command! W :w command! Wn :wn command! WN :wn command! Wp :wp command! WP :wp command! QA :qa command! Qa :qa command! Q :q " Unhighlight search results nmap :nohlsearch:redraw! " Map Y to be consistent with D, C, etc nmap Y y$ " CTRL-n and CTRL-p to go forwards and backwards through files nmap :next nmap :prev " CTRL-J/K to move up and down, collapsing open windows map j_ map k_ " Press CTRL-z after pasting something to fix up formatting imap u:set paste.:set nopastei " Tab to switch between split windows nmap " Q to reformat paragraph. I never use ex mode anyway (default binding for Q) nmap Q gwip " Toggle wordwrap function WrapToggle() if &wrap call WrapOff() echo "Word wrap off" else call WrapOn() echo "Word wrap on" endif endfunction map :call WrapToggle() imap :call WrapToggle() " Turn word wrap off, reset arrows, home, end, etc to default bindings function WrapOff() setlocal nowrap " Go up and down by physical linebreaks when not wordwrapped iunmap iunmap iunmap iunmap nunmap nunmap nunmap nunmap nunmap 0 nunmap ^ nunmap $ vunmap vunmap vunmap vunmap vunmap 0 vunmap ^ vunmap $ " Allow only backspace & space set whichwrap=b,s endfunction " Turn word wrapping on and bind arrows, home, end, etc to display lines function WrapOn() setlocal wrap " Go up and down by display lines, not linebreaks when wordwrapped imap g$ imap g0 imap gj imap gk nmap gj nmap gk nmap g$ nmap g0 nmap 0 g0 nmap ^ g^ nmap $ g$ vmap gj vmap gk vmap g$ vmap g0 vmap 0 g0 vmap ^ g^ vmap $ g$ " Allow backspace, space, left/right keys to move across lines set whichwrap=b,s,<,>,[,] endfunction " Toggle show invisible characters function InvShow() if &list echo "Invisible characters off" set nolist else echo "Invisible characters on" set listchars=tab:.\ ,trail:! set list endif endfunction map :call InvShow() imap :call InvShow() " Spell checking mode toggle function ToggleSpelling() if !exists("s:spell_check") || s:spell_check == 0 echo "Spell check on" let s:spell_check = 1 setlocal spell spelllang=en_au else echo "Spell check off" let s:spell_check = 0 setlocal spell spelllang= endif endfunction map :call ToggleSpelling() imap :call ToggleSpelling()