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 " Vim 5 hardcodes the size of numbers column to 8.
74 " Save sessions in UNIX format with / as file separator. This is
78 " Nuke any pre-existing autocommands.
81 " Save the current window width so we can restore it when we quit.
84 " More GUI options. Add icon, tearoffs and toolbar.
87 " Allow dynamic window resize even if we aren't in an xterm.
88 se t_WS=
\e[8;%p1%d;%p2%dt
90 " Highlight search results.
93 " Syntax highlighting.
101 " Set up our variables.
103 if ! exists("b:iainlist")
106 if ! exists("b:iainhex")
109 if ! exists("b:iainverbose")
110 let b:iainverbose = 0
114 " Helper for status line.
115 " Show space, underscore or dollar sign depending on list mode.
121 elseif b:iainlist == 1
130 " Helper for status line.
131 " Show c or C to denote case-sensitivity.
140 " Helper for status line.
141 " Show the size of the tabstop.
146 " Helper for status line.
147 " Show p when paste mode is on.
156 " Show the status line.
157 fun! Show_StatusLine()
159 let sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %='
160 let sl3='L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P'
163 let hexformat='0\x%02B'
166 let sl2=hexformat . '\ \|\ P:%4.6o\ '
170 exec "set statusline=" . sl1 . sl2 . sl3
173 " Toggle case-sensitivity.
178 " Restore window size.
179 au VimLeave * if exists("oldcols") | let &columns=oldcols | endif
182 au BufEnter * if &ft == "make" | call MakeMode_map() | endif
183 au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
185 " Entering Make mode.
192 fun! MakeMode_unmap()
197 " Show the status line for the first time.
198 call Show_StatusLine()
200 " Change to ts=2 with Q2.
201 map Q2 :se ts=2<CR>:<CR>
202 " Change to ts=4 with Q4.
203 map Q4 :se ts=4<CR>:<CR>
204 " Change to ts=8 with Q8.
205 map Q8 :se ts=8<CR>:<CR>
206 " Change to ts=16 with Q6.
207 map Q6 :se ts=16<CR>:<CR>
208 " Change to ts=32 with Q3.
209 map Q3 :se ts=32<CR>:<CR>
210 " Toggle paste mode with Qp.
211 map Qp :se paste!<CR>:<CR>
212 " Swap case-sensitivity with Qc.
213 map Qc :call Invert_Case()<CR>:<CR>
214 " Change number mode with Qn.
215 map Qn :se number!<CR>:<CR>
216 " Expand or shrink window size with Q> and Q<. For use after toggling number.
217 map Q> :exe 'se columns+=' . numberwidth<CR>:<CR>
218 map Q< :exe 'se columns-=' . numberwidth<CR>:<CR>
219 " Clear search pattern with Q/.
220 map Q/ :let @/=""<CR>:<CR>
224 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
225 " Handle options only available in Vim 6 and above.
226 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
230 " Remember quickfix state.
233 " Set indenting by filetype.
236 " Less intrusive syntax highlighting.
240 if has("gui_running")
241 se guifont=Bitstream\ Vera\ Sans\ Mono\ 10
245 se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
248 " Ignore whitespace when diffing.
249 se diffopt=filler,iwhite
251 " Expand window when doing a vertical diff.
256 " Status bar matches the colour.
257 highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue
260 highlight LineNr term=underline cterm=bold guifg=blue ctermfg=blue
262 " Remember that we are opening the quickfix window.
263 au BufWinEnter quickfix let g:quickfixing=1
264 au BufUnload * if &ft == "qf" | let g:quickfixing=0 | endif
266 " Make * and # work the way you expect in visual mode.
267 vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
268 vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
272 let basic='tab:\\_,trail:_,extends:<,precedes:>'
274 let b:iainlist = b:iainlist + 1
280 elseif b:iainlist == 1
281 exec "set lcs=" . basic
284 exec "set lcs=" . basic . ",eol:$"
289 " Cycle between hex and decimal display of toolbar stuff.
290 fun! Cycle_HexStatusLine()
292 let b:iainhex = ! b:iainhex
293 call Show_StatusLine()
296 " Cycle verbose display of toolbar stuff.
297 fun! Cycle_VerboseStatusLine()
299 let b:iainverbose = ! b:iainverbose
300 call Show_StatusLine()
303 " Toggle quickfix window.
304 fun! Cycle_Quickfix()
305 if g:quickfixing == 1
313 " We use Q for various commands. Unmap it.
314 " Vim 5 won't let us unmap this as it treats Q as an ambiguous mapping (because
315 " Qx also exists. With Vim 5 you are rewarded with Ex mode if you don't type
316 " the Qx sequence quickly enough. Vim 6 allows us to forget the Ex mapping.
319 " Swap hex/decimal statusline with Qx
320 map Qx :call Cycle_HexStatusLine()<CR>:<CR>
321 " Change statusline verbosity with Qv
322 map Qv :call Cycle_VerboseStatusLine()<CR>:<CR>
323 " Cycle list styles with Ql.
324 map Ql :call Cycle_List()<CR>:<CR>
325 " Toggle tags with Qt.
327 " Change foldmethod with Qf.
328 map Qf :se foldenable!<CR>:<CR>
329 " Toggle quickfix window with Qq.
330 map Qq :call Cycle_Quickfix()<CR>:<CR>
334 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
335 " Handle options only available in Vim 7 and above.
336 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
340 " Make diffs vertical by default.
343 " Set size of numbers column.
346 " Add "previous tab" mapping as gb.