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