1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4 " Multi-version vimrc compatible with version 4 and above.
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
7 " Note that "if <condition> | call Something() | endif" syntax is unsupported
8 " in Vim 4 so we write all our functions out the long way. It does work in
9 " autocommand definitions, however.
11 " Vim 4 complains if version isn't set in the configuration file.
14 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
15 " Handle options safe to use in version 4. Vim 4 parses but ignores the
16 " "if version" syntax used later in this file so we don't use it. No attempt
17 " is made to make this configuration compatible with Vim 3.
18 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
19 " No compatibility mode.
24 " And use spaces not tabs.
26 " And << and >> indent by 2.
29 " Allow backspace to delete before start of line.
34 " Show partial commands in the ruler.
36 " And always show the status line.
41 se cinkeys=0{,0},0),:,!^F,o,O,e
47 " Don't be bugged by messages at the bottom of the screen.
53 " Case-insensitive search.
55 " But override by typing capitals.
58 " Look for ctags in home directory first.
59 se tags=~/.tags,./tags,tags
61 " Use - and = to create underlines.
62 map - yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>
63 map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
65 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
66 " Handle options only available in Vim 5 and above.
67 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
71 " Save sessions in UNIX format with / as file separator. This is
75 " Nuke any pre-existing autocommands.
78 " Save the current window width so we can restore it when we quit.
81 " More GUI options. Add icon, tearoffs and toolbar.
84 " Allow dynamic window resize even if we aren't in an xterm.
85 se t_WS=
\e[8;%p1%d;%p2%dt
87 " Highlight search results.
90 " Syntax highlighting.
98 " Set up our variables.
100 if ! exists("b:iainlist")
103 if ! exists("b:iainhex")
106 if ! exists("b:iainverbose")
107 let b:iainverbose = 0
111 " Helper for status line.
112 " Show space, underscore or dollar sign depending on list mode.
118 elseif b:iainlist == 1
127 " Helper for status line.
128 " Show c or C to denote case-sensitivity.
137 " Helper for status line.
138 " Show the size of the tabstop.
143 " Helper for status line.
144 " Show p when paste mode is on.
153 " Show the status line.
154 fun! Show_StatusLine()
156 let sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %='
157 let sl3='L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P'
160 let hexformat='0\x%02B'
163 let sl2=hexformat . '\ \|\ P:%4.6o\ '
167 exec "set statusline=" . sl1 . sl2 . sl3
170 " Restore window size.
171 au VimLeave * if exists("oldcols") | let &columns=oldcols | endif
174 au BufEnter * if &ft == "make" | call MakeMode_map() | endif
175 au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
177 " Entering Make mode.
184 fun! MakeMode_unmap()
189 " Show the status line for the first time.
190 call Show_StatusLine()
193 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
194 " Handle options only available in Vim 6 and above.
195 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
199 " Set indenting by filetype.
202 " Track changing number mode.
203 let g:numbercols=&columns
204 let g:numberchanges=0
206 " Less intrusive syntax highlighting.
210 if has("gui_running")
211 se guifont=Bitstream\ Vera\ Sans\ Mono\ 10
215 se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
218 " Ignore whitespace when diffing.
219 se diffopt=filler,iwhite
221 " Expand window when doing a vertical diff.
226 " Status bar matches the colour.
227 highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue
230 highlight LineNr term=underline cterm=bold guifg=blue ctermfg=blue
232 " Make * and # work the way you expect in visual mode.
233 vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
234 vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
238 let basic='tab:\\_,trail:_,extends:<,precedes:>'
240 let b:iainlist = b:iainlist + 1
246 elseif b:iainlist == 1
247 exec "set lcs=" . basic
250 exec "set lcs=" . basic . ",eol:$"
255 " Cycle between hex and decimal display of toolbar stuff.
256 fun! Cycle_HexStatusLine()
258 let b:iainhex = ! b:iainhex
259 call Show_StatusLine()
262 " Cycle verbose display of toolbar stuff.
263 fun! Cycle_VerboseStatusLine()
265 let b:iainverbose = ! b:iainverbose
266 call Show_StatusLine()
269 " Cycle between number mode.
270 " FIXME: Toggling in a split window doesn't work properly. We need to track
271 " the number of windows and number modes. Something for later...
272 " Perhaps have a redraw callback that checks width and original column number.
278 let g:numberchanges=g:numberchanges-1
283 " Change size back if this was the last window.
284 if g:numberchanges == 0
285 let &columns=g:numbercols
290 " Save width between number toggling.
292 " Expand if this was the first change.
293 if g:numberchanges == 0
294 let g:numbercols=&columns
296 " Expand column by our preferred width.
297 let &columns=&columns+&numberwidth
299 " Vim 6 hardcodes width to 8.
300 let &columns=&columns+8
305 let g:numberchanges=g:numberchanges+1
311 " Toggle case-sensitivity.
316 " We'll use Q for various commands. Unmap it.
319 " Change to ts=2 with Q2.
320 map Q2 :se ts=2<CR>:<CR>
321 " Change to ts=4 with Q4.
322 map Q4 :se ts=4<CR>:<CR>
323 " Change to ts=8 with Q8.
324 map Q8 :se ts=8<CR>:<CR>
325 " Change to ts=16 with Q6.
326 map Q6 :se ts=16<CR>:<CR>
327 " Change to ts=32 with Q3.
328 map Q3 :se ts=32<CR>:<CR>
329 " Change foldmethod with Qf.
330 map Qf :se foldenable!<CR>:<CR>
331 " Toggle paste mode with Qp.
332 map Qp :se paste!<CR>:<CR>
333 " Swap hex/decimal statusline with Qx
334 map Qx :call Cycle_HexStatusLine()<CR>:<CR>
335 " Change statusline verbosity with Qv
336 map Qv :call Cycle_VerboseStatusLine()<CR>:<CR>
337 " Swap case-sensitivity with Qc.
338 map Qc :call Invert_Case()<CR>:<CR>
339 " Cycle list styles with Ql.
340 map Ql :call Cycle_List()<CR>:<CR>
341 " Change number mode with Qn.
342 map Qn :call Cycle_Number()<CR>:<CR>
343 " Toggle tags with Qt.
345 " Clear search pattern with Q/.
346 map Q/ :let @/=""<CR>:<CR>
350 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
351 " Handle options only available in Vim 7 and above.
352 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
356 " Make diffs vertical by default.
359 " Set size of numbers column.
362 " Add "previous tab" mapping as gb.