]> code.delx.au - dotfiles/blob - .vim/macros.vim
Vim Q reformats paragraph
[dotfiles] / .vim / macros.vim
1 " Python Calculator
2 command! -nargs=+ Calc :r! python -c "from math import *; print <args>"
3
4 " I frequently type :Q or :WQ, etc instead of :q, :wq
5 command! WQA :wqa
6 command! WqA :wqa
7 command! WQa :wqa
8 command! Wqa :wqa
9 command! WA :wa
10 command! Wa :wa
11 command! WQ :wq
12 command! Wq :wq
13 command! W :w
14 command! Wn :wn
15 command! WN :wn
16 command! Wp :wp
17 command! WP :wp
18 command! QA :qa
19 command! Qa :qa
20 command! Q :q
21
22 " Unhighlight search results
23 map <C-l> :nohlsearch<CR>:redraw!<CR>
24
25 " Map Y to be consistent with D, C, etc
26 noremap Y y$
27
28 " CTRL-n and CTRL-p to go forwards and backwards through files
29 nnoremap <C-n> :next<CR>
30 nnoremap <C-p> :prev<CR>
31
32 " CTRL-J/K to move up and down, collapsing open windows
33 map <C-J> <C-W>j<C-W>_
34 map <C-K> <C-W>k<C-W>_
35
36 " Press CTRL-X after pasting something to fix up formatting
37 imap <C-z> <ESC>u:set paste<CR>.:set nopaste<CR>i
38
39 " Tab to switch between split windows
40 map <Tab> <C-w><C-w>
41
42 " Q to reformat paragraph. I never use ex mode anyway (default binding for Q)
43 map Q gwip
44
45 " Spell checking mode toggle
46 function s:spell()
47 if !exists("s:spell_check") || s:spell_check == 0
48 echo "Spell check on"
49 let s:spell_check = 1
50 setlocal spell spelllang=en_au
51 else
52 echo "Spell check off"
53 let s:spell_check = 0
54 setlocal spell spelllang=
55 endif
56 endfunction
57 map <F8> :call <SID>spell()<CR>
58 imap <F8> <C-o>:call <SID>spell()<CR>
59