1 " Function key mappings
2 map <F8> :call ToggleSpelling()<CR>
3 imap <F8> <C-o>:call ToggleSpelling()<CR>
4 map <F9> :call InvShow()<CR>
5 imap <F9> <C-o>:call InvShow()<CR>
6 map <F10> :call WrapToggle()<CR>
7 imap <F10> <C-o>:call WrapToggle()<CR>
10 command -nargs=+ Calc :r! python -c "from math import *; print <args>"
12 " Unhighlight search results and redraw the screen
13 nmap <C-l> :nohlsearch<CR>:redraw!<CR>
15 " Map Y to be consistent with D, C, etc
18 " CTRL-n and CTRL-p to go forwards and backwards through files
22 " CTRL-J/K to move up and down, collapsing open windows
23 map <C-J> <C-W>j<C-W>_
24 map <C-K> <C-W>k<C-W>_
26 " Press CTRL-z after pasting something to fix up formatting
27 imap <C-z> <ESC>u:set paste<CR>.:set nopaste<CR>i
29 " Tab to switch between split windows
33 " Q to reformat paragraph. I never use ex mode anyway (default binding for Q)
36 " Stay in visual after indenting
41 command SudoWrite call SudoWriteFunction()
43 " I frequently type :Q or :WQ, etc instead of :q, :wq
61 " Make the number pad work
86 " Turn word wrap off, reset arrows, home, end, etc to default bindings
89 " Go up and down by physical linebreaks when not wordwrapped
91 iunmap <buffer> <Home>
92 iunmap <buffer> <Down>
94 nunmap <buffer> <Down>
97 nunmap <buffer> <Home>
101 vunmap <buffer> <Down>
103 vunmap <buffer> <End>
104 vunmap <buffer> <Home>
108 " Allow only backspace & space
112 " Turn word wrapping on and bind arrows, home, end, etc to display lines
115 " Go up and down by display lines, not linebreaks when wordwrapped
116 imap <buffer> <End> <C-o>g$
117 imap <buffer> <Home> <C-o>g0
118 imap <buffer> <Down> <C-o>gj
119 imap <buffer> <Up> <C-o>gk
120 nmap <buffer> <Down> gj
121 nmap <buffer> <Up> gk
122 nmap <buffer> <End> g$
123 nmap <buffer> <Home> g0
127 vmap <buffer> <Down> gj
128 vmap <buffer> <Up> gk
129 vmap <buffer> <End> g$
130 vmap <buffer> <Home> g0
134 " Allow backspace, space, left/right keys to move across lines
135 set whichwrap=b,s,<,>,[,]
139 " Toggle show invisible characters
142 echo "Invisible characters off"
145 echo "Invisible characters on"
146 set listchars=tab:.\ ,trail:!
152 " Spell checking mode toggle
153 function ToggleSpelling()
154 if !exists("s:spell_check") || s:spell_check == 0
155 echo "Spell check on"
156 let s:spell_check = 1
157 setlocal spell spelllang=en_au
159 echo "Spell check off"
160 let s:spell_check = 0
161 setlocal spell spelllang=
167 function SudoWriteFunction()