]> code.delx.au - dotfiles/blob - .vim/macros.vim
vim macro :WQ and friends for clumsy people like me :)
[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! QA :wqa
15 command! Qa :wqa
16
17 " Unhighlight search results
18 map <C-l> :nohlsearch<CR>:redraw!<CR>
19
20 " Map Y to be consistent with D, C, etc
21 noremap Y y$
22
23 " CTRL-n and CTRL-p to go forwards and backwards through files
24 nnoremap <C-n> :next<CR>
25 nnoremap <C-p> :prev<CR>
26
27 " Press CTRL-X after pasting something to fix up formatting
28 imap <C-z> <ESC>u:set paste<CR>.:set nopaste<CR>i
29
30 " Spell checking mode toggle
31 function s:spell()
32 if !exists("s:spell_check") || s:spell_check == 0
33 echo "Spell check on"
34 let s:spell_check = 1
35 setlocal spell spelllang=en_au
36 else
37 echo "Spell check off"
38 let s:spell_check = 0
39 setlocal spell spelllang=
40 endif
41 endfunction
42 map <F8> :call <SID>spell()<CR>
43 imap <F8> <C-o>:call <SID>spell()<CR>
44