1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
5 " Note that "if <condition> | call Something() | endif" syntax is unsupported
6 " in Vim 4 so we write all our functions out the long way. It does work in
7 " autocommand definitions, however.
9 " Vim 4 complains if version isn't set in the configuration file.
12 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
13 " Handle options safe to use in version 4. Vim 4 parses but ignores the
14 " "if version" syntax used later in this file so we don't use it. No attempt
15 " is made to make this configuration compatible with Vim 3.
16 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
17 " No compatibility mode.
22 " And use spaces not tabs.
24 " And << and >> indent by 2.
27 " Allow backspace to delete before start of line.
32 " Show partial commands in the ruler.
34 " And always show the status line.
39 se cinkeys=0{,0},0),:,!^F,o,O,e
44 " Don't be bugged by messages at the bottom of the screen.
50 " Case-insensitive search.
52 " But override by typing capitals.
55 " Look for ctags in home directory first.
56 se tags=~/.tags,./tags,tags
58 " Use - and = to create underlines.
59 map - yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>
60 map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
62 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
63 " Handle options only available in Vim 5 and above.
64 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
68 " Nuke any pre-existing autocommands.
71 " Save the current window width so we can restore it when we quit.
74 " More GUI options. Add icon, tearoffs and toolbar.
77 " Allow dynamic window resize even if we aren't in an xterm.
78 se t_WS=
\e[8;%p1%d;%p2%dt
80 " Highlight search results.
83 " Syntax highlighting.
91 " Set up our variables.
93 if ! exists("b:iainlist")
96 if ! exists("b:iainhex")
101 " Helper for status line.
102 " Show space, underscore or dollar sign depending on list mode.
108 elseif b:iainlist == 1
117 " Helper for status line.
118 " Show c or C to denote case-sensitivity.
127 " Helper for status line.
128 " Show the size of the tabstop.
133 " Helper for status line.
134 " Show p when paste mode is on.
143 " Show the status line.
144 fun! Show_StatusLine()
146 let sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %='
147 let sl2='\ \|\ P:%4.6o\ L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P'
150 let hexformat='0\x%02B'
152 exec "set statusline=" . sl1 . hexformat . sl2
155 " Restore window size.
156 au VimLeave * if exists("oldcols") | let &columns=oldcols | endif
159 au BufEnter * if &ft == "c" || &ft == "cpp" | call CMode_map() | endif
160 au BufLeave * if &ft == "c" || &ft == "cpp" | call CMode_unmap() | endif
163 au BufEnter * if &ft == "perl" | call PerlMode_map() | endif
164 au BufLeave * if &ft == "perl" | call PerlMode_unmap() | endif
167 au BufEnter * if &ft == "make" | call MakeMode_map() | endif
168 au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
172 let oldcinkeys=&cinkeys
173 let oldcinwords=&cinwords
174 set cinkeys=0{,0},:,0#,!^F,o,O,e
175 set cinwords=if,else,while,do,for,switch
180 set cinkeys=oldcinkeys
181 set cinwords=oldcinwords
184 " Entering Perl mode.
186 let oldcinkeys=&cinkeys
187 let oldcinwords=&cinwords
188 set cinkeys=0{,0},:,!^F,o,O,e
189 set cinwords=if,else,while,do,for,eval
193 fun! PerlMode_unmap()
194 set cinkeys=oldcinkeys
195 set cinwords=oldcinwords
198 " Entering Make mode.
205 fun! MakeMode_unmap()
210 " Show the status line for the first time.
211 call Show_StatusLine()
214 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
215 " Handle options only available in Vim 6 and above.
216 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
220 " Less intrusive syntax highlighting.
224 if has("gui_running")
225 se guifont=Bitstream\ Vera\ Sans\ Mono\ 12
229 se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
232 " Expand window when doing a vertical diff.
237 " Status bar matches the colour.
238 highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue
240 " Make * and # work the way you expect in visual mode.
241 vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
242 vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
246 let basic='tab:\\_,trail:_,extends:<,precedes:>'
248 let b:iainlist = b:iainlist + 1
254 elseif b:iainlist == 1
255 exec "set lcs=" . basic
258 exec "set lcs=" . basic . ",eol:$"
263 " Cycle between hex and decimal display of toolbar stuff.
264 fun! Cycle_HexStatusLine()
266 let b:iainhex = ! b:iainhex
267 call Show_StatusLine()
274 let &columns=g:numbercols
278 " Save width between number toggling.
280 let g:numbercols=&columns
281 let &columns=&columns+5
290 " We'll use Q for various commands. Unmap it.
293 " Change to ts=2 with Q2.
294 map Q2 :se ts=2<CR>:<CR>
295 " Change to ts=4 with Q4.
296 map Q4 :se ts=4<CR>:<CR>
297 " Change to ts=8 with Q8.
298 map Q8 :se ts=8<CR>:<CR>
299 " Change to ts=16 with Q6.
300 map Q6 :se ts=16<CR>:<CR>
301 " Change to ts=32 with Q3.
302 map Q3 :se ts=32<CR>:<CR>
303 " Change foldmethod with Qf.
304 map Qf :se foldenable!<CR>:<CR>
305 " Toggle paste mode with Qp.
306 map Qp :se paste!<CR>:<CR>
307 " Swap hex/decimal statusline with Qx
308 map Qx :call Cycle_HexStatusLine()<CR>:<CR>
309 " Swap case-sensitivity with Qc.
310 map Qc :call Invert_Case()<CR>:<CR>
311 " Cycle list styles with Ql.
312 map Ql :call Cycle_List()<CR>:<CR>
313 " Change number mode with Qn.
314 map Qn :call Cycle_Number()<CR>:<CR>
315 " Toggle tags with Qt.
319 fun! PerlMode_unmap()
320 set cinkeys=oldcinkeys
321 set cinwords=oldcinwords
322 set foldmethod=manual
326 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
327 " Handle options only available in Vim 7 and above.
328 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
332 " Add "previous tab" mapping as gb.