Typo.
[profile.git] / .vimrc
1 " $Id$
2 se nocp
3 se ts=2
4 se bs=2
5 se sw=2
6 se expandtab
7 se ruler
8 se cindent
9 se cinkeys=0{,0},0),:,!^F,o,O,e
10 se showcmd
11 se go=agilmrtT
12 se incsearch
13 se ignorecase
14 se smartcase
15 se shm=aot
16 se laststatus=2
17 syn enable
18 if has("gui_running")
19   se guifont=Bitstream\ Vera\ Sans\ Mono\ 12
20   colo darkblue
21 endif
22 highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue
23 if has("win32")
24   se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
25 endif
26 :autocmd!
27
28 " Set up our variables.
29 fun Iain_Vars()
30   if ! exists("b:iainlist") | let b:iainlist = 0 | endif
31   if ! exists("b:iainhex") | let b:iainhex = 1 | endif
32 endfun
33
34 fun Cycle_List()
35   call Iain_Vars()
36   let b:iainlist += 1
37   if b:iainlist > 2 | let b:iainlist = 0 | endif
38   if b:iainlist == 0
39     set nolist
40   elseif b:iainlist == 1
41     set lcs=tab:\\_,trail:_,extends:<,precedes:>
42     set list
43   else
44     set lcs=tab:\\_,trail:_,extends:<,precedes:>,eol:$
45     set list
46   endif
47 endfun
48
49 fun Show_List()
50   call Iain_Vars()
51   if b:iainlist == 0
52     " No list.
53     return "  "
54   elseif b:iainlist == 1
55     " Just tabs.
56     return "\\_"
57   else
58     " Full list.
59     return "\.\$"
60   endif
61 endfun
62
63 " Cycle between hex and decimal display of toolbar stuff
64 fun Cycle_StatusLine()
65   call Iain_Vars()
66   let b:iainhex = ! b:iainhex
67   if b:iainhex
68     set statusline=%2n\:\ %<%f\ [%{Show_List()}][%{Show_Case()}]%y%m%r\ %=0\x%02B\ (%3.6c,%-4.6l)\ 0\x%04.6O\ \|\ %4.6L\ %P
69   else
70     set statusline=%2n\:\ %<%f\ [%{Show_List()}][%{Show_Case()}]%y%m%r\ %=%b\ (%3.6c,%-4.6l)\ %4.6o\ \|\ %4.6L\ %P
71   endif
72 endfun
73
74 " Save the current window width so if we change it we can restore it
75 " when we quit.
76 let andyoldcols=&columns
77
78 " This expands the terminal to display two 80-column files side-by-side
79 " when vim is opened in diff mode.
80 if &diff | let &columns = 164 | endif
81
82 map <C-"> viwvbi"<ESC>ea"<ESC>
83 map - yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>
84 map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
85 command W :w
86 se tags=~/.ctags
87
88 fun Invert_Case()
89   let &ic = ! &ic
90 endfun
91
92 fun Show_Case()
93   if &ic | return "ca" | else | return "Ca" | endif
94 endfun
95
96 " Swap hex/decimal statusline with ,x
97 map ,x :call Cycle_StatusLine()<CR>:<CR>
98 " Swap case-sensitivity with ,c.
99 map ,c :call Invert_Case()<CR>:<CR>
100 " Cycle list styles with ,l.
101 map ,l :call Cycle_List()<CR>:<CR>
102
103 call Cycle_StatusLine()
104
105 au VimLeave * if exists("andyoldcols") | let &columns=andyoldcols | endif
106
107 " Autocommands to setup features we only want in certain modes...
108
109 " ... For C/C++ files:
110
111 au BufEnter * if &ft == "c" || &ft == "cpp" | call CMode_map() | endif
112 au BufLeave * if &ft == "c" || &ft == "cpp" | call CMode_unmap() | endif
113
114 " ... For Perl files:
115
116 au BufEnter * if &ft == "perl" | call PerlMode_map() | endif
117 au BufLeave * if &ft == "perl" | call PerlMode_unmap() | endif
118
119 " ... For PHP files:
120
121 au BufEnter * if &ft == "php" | call PHPMode_map() | endif
122 au BufLeave * if &ft == "php" | call PHPMode_unmap() | endif
123
124 " ... For makefiles:
125
126 au BufEnter * if &ft == "make" | call MakeMode_map() | endif
127 au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
128
129 " Functions to call when we enter/leave a programming language buffer...
130
131 " ... For C-like languages:
132
133 fun CMode_map()
134   set cinkeys=0{,0},:,0#,!^F,o,O,e
135   set cinwords=if,else,while,do,for,switch
136 endfun
137
138 fun CMode_unmap()
139 endfun
140
141 " .. For Perl files:
142
143 fun PerlMode_map()
144   set cinkeys=0{,0},:,!^F,o,O,e
145   set cinwords=if,else,while,do,for,eval
146 endfun
147
148 fun PerlMode_unmap()
149   set foldmethod=manual
150 endfun
151
152 fun PHPMode_map()
153   set nocindent
154   set autoindent
155 endfun
156
157 fun PHPMode_unmap()
158   set noautoindent
159   set cindent
160 endfun
161
162 " ... For makefiles:
163
164 fun MakeMode_map()
165   set list
166   set noexpandtab
167 endfun
168
169 fun MakeMode_unmap()
170   set nolist
171   set expandtab
172 endfun