]> code.delx.au - dotfiles/blobdiff - .vim/macros.vim
Vim Q reformats paragraph
[dotfiles] / .vim / macros.vim
index 11980226c26a1331bd3def8918bd73cb3c9f490c..79b17aa0e280eed0aa040bd44d9ccddfb564ca50 100644 (file)
@@ -1,6 +1,24 @@
 " Python Calculator
 command! -nargs=+ Calc :r! python -c "from math import *; print <args>"
 
+" 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
 map <C-l> :nohlsearch<CR>:redraw!<CR>
 
@@ -11,9 +29,19 @@ noremap Y y$
 nnoremap <C-n> :next<CR>
 nnoremap <C-p> :prev<CR>
 
+" CTRL-J/K to move up and down, collapsing open windows
+map <C-J> <C-W>j<C-W>_
+map <C-K> <C-W>k<C-W>_
+
 " Press CTRL-X after pasting something to fix up formatting
 imap <C-z> <ESC>u:set paste<CR>.:set nopaste<CR>i
 
+" Tab to switch between split windows
+map <Tab> <C-w><C-w>
+
+" Q to reformat paragraph. I never use ex mode anyway (default binding for Q)
+map Q gwip
+
 " Spell checking mode toggle
 function s:spell()
        if !exists("s:spell_check") || s:spell_check == 0