7f1a8f7c548a7286fa2c4edebe891c1bf72f485e
[profile.git] / .vimrc
1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 " Multi-version vimrc compatible with version 4 and above.   vim:set fdm=marker:
3 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4
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.
8
9 " Vim 4 complains if version isn't set in the configuration file.
10 version 4.0
11
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 " Some of these settings should strictly be wrapped inside "if has()" blocks
17 " but that would cause them not to be ignored by Vim 4.
18 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
19 "{{{1
20 " No compatibility mode.
21 se nocp
22
23 " Tabstop 2.
24 se ts=2
25 " And use spaces not tabs.
26 se expandtab
27 " And << and >> indent by 2.
28 se sw=2
29 " Backspace deletes full tab width at the start of a line.
30 se smarttab
31
32 " Allow backspace to delete before start of line.
33 se bs=2
34
35 " Don't jump to the start of the line when using H, L etc.
36 se nosol
37
38 " Show the ruler.
39 se ruler
40 " Show partial commands in the ruler.
41 se showcmd
42 " And always show the status line.
43 se laststatus=2
44
45 " Use C indent style.
46 se cindent
47 se cinkeys=0{,0},0),:,!^F,o,O,e
48 se cinoptions=b1,c2
49
50 " GUI options.
51 se go=aglmr
52
53 " Don't be bugged by messages at the bottom of the screen.
54 se shm=aot
55
56 " Find as you type.
57 se incsearch
58
59 " Case-insensitive search.
60 se ignorecase
61 " But override by typing capitals.
62 se smartcase
63
64 " Look for ctags in home directory first.
65 se tags=~/.tags,./tags,tags
66
67 " Don't timeout waiting to interpet, eg, <ESC>OA as an escape code.
68 se ttimeoutlen=100
69
70 " Remember undo list for closed (but not wiped) buffers.
71 se hidden
72
73 " Use ^B to search backward when completing.
74 inoremap <C-b> <C-p>
75 " Use ^L to show matching completions but don't select one.
76 inoremap <C-l> <C-n><C-p>
77
78 " Swap jump keys.
79 nnoremap ' `
80 nnoremap ` '
81
82 " Select previous widnow.
83 nnoremap <C-w>^ <C-w>p
84 nnoremap <C-w><C-^> <C-w>p
85 "}}}1
86
87 " Find stuff.
88 if (has("win32") || has("win64")) && version >= "504"
89   se rtp=~/.vim,$VIMRUNTIME
90 endif
91
92 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
93 " Handle options only available in Vim 5 and above.
94 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
95 if version >= "500" "{{{1
96 version 5.0
97
98 " Tell Vim we use dark backgrounds in our terminals.
99 if ! has("gui_running")
100   se bg=dark
101 endif
102
103 " Allow mouse use in a terminal but only if it can work.
104 if has("xterm_clipboard")
105   se mouse=nvir
106 endif
107
108 " Update more quickly.  For use with sign highlighting as polling for
109 " CursorMove makes redrawing slow.
110 if has("signs")
111   se updatetime=500
112 endif
113
114 " Enable tab-completion prompting for commands.
115 if has("wildmenu")
116   se wildmenu
117   " Don't list object files when globbing files to load.
118   se wildignore+=*.o,*.obj
119   " So there's no need to assign them low priority.
120   se suffixes-=*.o,*.obj
121 endif
122
123 " Save sessions in UNIX format with / as file separator.  This is
124 " cross-platform.
125 if has("mksession")
126   se ssop+=unix,slash
127 endif
128
129 " How often do we need to use ^A/^X on octals?
130 se nf=hex
131
132 " Nuke any pre-existing autocommands.
133 if has("autocmd")
134   augroup Display
135   autocmd!
136   augroup Mode
137   autocmd!
138   if has("signs")
139     augroup Signs
140     autocmd!
141   endif
142   augroup StatusLine
143   autocmd!
144   augroup File
145   autocmd!
146   augroup END
147 endif
148
149 " Save the current window dimensions so we can restore them when we quit.
150 if ! exists("g:oldcols")
151   let g:oldcols=&columns
152 endif
153 if ! exists("g:oldlines")
154   let g:oldlines=&lines
155 endif
156
157 " More GUI options.  Add icon and tearoffs.
158 if has("gui")
159   se go+=i
160   se go+=t
161 endif
162
163 " Allow dynamic window resize even if we aren't in an xterm.
164 se t_WS=\e[8;%p1%d;%p2%dt
165
166 " Highlight search results.
167 if has("extra_search")
168   se hlsearch
169 endif
170
171 " Syntax highlighting.  New versions will use syn enable instead.
172 if version < "600"
173   syn on
174 endif
175
176 if has("user_commands")
177   " Catch typos.
178   command! W :w
179   command! Wq :wq
180   command! Wqa :wqa
181 endif
182
183 " Forget the Ex mode mapping.
184 map Q <NOP>
185
186 if has("autocmd")
187   " Position the compview plugin window.
188   au Display BufEnter -SearchResults- set buftype=nowrite | set nonumber | wincmd J
189 endif
190 endif "}}}1
191
192 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
193 " Handle options only available in Vim 5.2 and above.
194 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
195 if version >= "502" "{{{1
196 version 5.2
197
198 " Helper to initialise a variable.
199 fun! Prep_Var(var, value) "{{{2
200   if exists(a:var)
201     return
202   endif
203   exe "let " . a:var . "=" . a:value
204 endfun "}}}2
205
206 " Set up our variables.
207 fun! Iain_Vars() "{{{2
208   call Prep_Var("w:iainlist", 0)
209   call Prep_Var("b:iainhex", 0)
210   call Prep_Var("b:iainverbose", 0)
211   " Window Flags: (F)ocused, (I)nsert mode, Cursor (H)old.
212   call Prep_Var("b:iainstatus", "'Fih'")
213   call Prep_Var("g:iainextracolumnsnumber", "''")
214   call Prep_Var("g:iainextracolumnslist", "''")
215   call Prep_Var("b:iainalt", 0)
216   if has("signs")
217     call Prep_Var("g:marksigns", 0)
218     call Prep_Var("g:firstsign", 100)
219   endif
220   call Prep_Var("g:resizable", "''")
221 endfun "}}}2
222
223 " Show the window title.
224 fun! Show_TitleString() "{{{2
225   if bufname("") == ""
226     let l:ts1='Vim'
227   else
228     " Vim 5 doesn't have printf.
229     let l:ts1=bufnr("")
230     if l:ts1 < 10
231       let l:ts1=" " . l:ts1
232     endif
233     let l:ts1=l:ts1 . ": " . expand('%t')
234   endif
235   let l:ts1=l:ts1 . " (" .  getcwd() . ")"
236   if has("clientserver")
237     let l:ts1=l:ts1 . " " . v:servername
238   endif
239   return l:ts1
240 endfun "}}}2
241
242 " Toggle case-sensitivity.
243 fun! Invert_Case() "{{{2
244   let &ic = ! &ic
245 endfun "}}}2
246
247 " Can we resize this window?
248 fun! Can_Resize() "{{{2
249   call Iain_Vars()
250
251   if g:resizable == "0" || g:resizable == "1"
252     return g:resizable
253   endif
254
255   " Do we KNOW we can(not) resize?
256   if has("gui_running")
257     let g:resizable = 1
258   elseif $RESIZABLE == &term
259     let g:resizable = 1
260   elseif $RESIZABLE == "0"
261     let g:resizable = 0
262   else
263     " Assume we can.  Allow overriding.
264     let g:resizable = 1
265   endif
266   return g:resizable
267 endfun "}}}2
268
269 " Grow or shrink the window width.
270 fun! Resize_Columns(op, ...) "{{{2
271   if a:op == ""
272     return
273   endif
274
275   if ! Can_Resize()
276     return
277   endif
278
279   if a:0 == 0
280     " Vim 5 hardcodes the size of numbers column to 8.
281     if version >= "700" && has("linebreak")
282       let l:columns = &numberwidth
283     else
284       let l:columns = 8
285     endif
286   else
287     let l:columns = a:1
288   endif
289
290   exe "let l:resize=" . &columns . a:op . l:columns
291   let l:resize = "se columns=" . l:resize
292
293   " HACK: Inside screen there is an extra line for the status bar.  Vim
294   " manages the resize by sending an escape sequence to set the number of
295   " lines and number of columns in one action.  To do this it will first query
296   " the number of lines and then set <same number of lines> by <new number of
297   " columns>.  Because of the extra line for the status bar this results in
298   " the real terminal being shrunk by a line.  We ask for the terminal to grow
299   " by a line so it ends up actually being the same.
300   if &term =~ '^screen'
301     let l:resize = l:resize . " lines=" . (&lines + 1)
302   endif
303
304   exe l:resize
305 endfun "}}}2
306
307 " Grow or shrink the window height.
308 fun! Resize_Lines(op, lines) "{{{2
309   if a:op == ""
310     return
311   endif
312
313   if ! Can_Resize()
314     return
315   endif
316
317   exe "let l:resize=" . &lines . a:op . a:lines
318   if &term =~ '^screen'
319     let l:resize = l:resize + 1
320   endif
321   let l:resize = "se lines=" . l:resize
322
323   exe l:resize
324 endfun "}}}2
325
326 " Set extra columns depending on window status.
327 fun! Extra_Columns(extra, var, ...) "{{{2
328   " Vim 6 doesn't have winnr("$").  Determine which windows are open
329   " ourselves by using :windo to incremement a counter.  As Vim 5
330   " doesn't have :windo we require Vim 6 for this.
331   if v:version < "600"
332     return ""
333   endif
334   if ! has("windows")
335     return ""
336   endif
337
338   " Remember which window we're in.
339   let l:winnr = winnr()
340   let l:num_windows = 0
341   windo let l:num_windows = l:num_windows + 1
342   " Switch back to the window we were in.
343   exe l:winnr . "wincmd w"
344
345   call Iain_Vars()
346
347   if a:0 == 0
348     let l:condition = ""
349   else
350     let l:condition = a:1
351   endif
352
353   let l:n = 0
354   let l:i = 1
355   let l:windows = ""
356   while l:n < l:num_windows
357     " If window w exists then getwinvar(w, "&modified") will be 0 or 1.
358     if getwinvar(l:i, "&modified") =~ '^\d'
359       let l:n = l:n + 1
360
361       let l:val = 0
362       exe "if getwinvar(" . l:i . ", '" . a:var . "') " . l:condition . " | let l:val = 1 | endif"
363       if l:val
364         exe "let l:windows = '" . l:windows . ":" . l:i . "'"
365       endif
366     endif
367     let l:i = l:i + 1
368   endwhile
369
370   let l:extra = "g:iainextracolumns" . a:extra
371   exe "let l:val = " . l:extra
372   exe "let " . l:extra . " = '" . l:windows . "'"
373
374   if l:windows == l:val
375     return ""
376   endif
377
378   if l:windows == ""
379     return "-"
380   elseif l:val == ""
381     return "+"
382   endif
383 endfun "}}}2
384
385 " Toggle number display.
386 fun! Number(resize) "{{{2
387   call Iain_Vars()
388   let &number = ! &number
389
390   " Ensure we keep track of any extra columns even if we aren't resizing.
391   " This prevents confusion when number is set at startup.
392   let l:extra = Extra_Columns("number", "&number")
393
394   if a:resize
395     call Resize_Columns(l:extra)
396   endif
397 endfun "}}}2
398
399 " Restore window size.
400 if has("autocmd") && ! has("gui_running")
401   au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif
402   au Display VimLeave * if exists("g:oldlines") | call Resize_Lines("-", (&lines - g:oldlines)) | endif
403 endif
404
405 " Map Makefile mode.
406 if has("autocmd")
407   au Mode BufEnter * if &ft == "make" | call MakeMode_map() | endif
408   au Mode BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
409 endif
410
411 " Entering Make mode.
412 fun! MakeMode_map() "{{{2
413   call Iain_Vars()
414   let w:iainlist=1
415   call Cycle_List()
416   set ts=8
417   set noexpandtab
418 endfun "}}}2
419
420 " Leaving Make mode.
421 fun! MakeMode_unmap() "{{{2
422   call Cycle_List()
423   set ts=2
424   set expandtab
425 endfun "}}}2
426
427 " Function to create mappings with either a hardcoded \ or <Leader>.
428 fun! Mapping(keysequence,mapping) "{{{2
429   if version < "600"
430     exec "map \\" . a:keysequence . " " . a:mapping
431   else
432     exec "map <Leader>" . a:keysequence . " " . a:mapping
433   endif
434 endfun "}}}2
435
436 " Use - and = to create underlines.
437 call Mapping("-", "yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>")
438 call Mapping("=", "yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>")
439
440 " Change to ts=2 with \2.
441 call Mapping("2", ":se ts=2<CR>:<CR>")
442 " Change to ts=4 with \4.
443 call Mapping("4", ":se ts=4<CR>:<CR>")
444 " Change to ts=8 with \8.
445 call Mapping("8", ":se ts=8<CR>:<CR>")
446 " Change to ts=16 with \6.
447 call Mapping("6", ":se ts=16<CR>:<CR>")
448 " Change to ts=32 with \3.
449 call Mapping("3", ":se ts=32<CR>:<CR>")
450 " Toggle paste mode with \p.
451 call Mapping("p", ":se paste!<CR>:<CR>")
452 " Swap case-sensitivity with \c.
453 call Mapping("C", ":call Invert_Case()<CR>:<CR>")
454 " Change number mode with \n.
455 call Mapping("n", ":call Number(1)<CR>:<CR>")
456 " Expand or shrink window size with \> and \<.
457 call Mapping(">", ":call Resize_Columns('+')<CR>:<CR>")
458 call Mapping("<", ":call Resize_Columns('-')<CR>:<CR>")
459 " Clear search pattern with \/.
460 call Mapping("/", ":let @/=\"\"<CR>:<CR>")
461 " Toggle alternate buffer name with \#.
462 call Mapping("#", ":call Cycle_Alt()<CR>:<CR>")
463
464 " Set graphical window title.
465 if has("win32") || has("win64")
466   " Windows taskbar entries are probably too small to show full titles.
467   se titlestring=%t
468 else
469   se titlestring=%{Show_TitleString()}
470 endif
471
472 " Vim tip 99: What's the highlighting group under the cursor?
473 call Mapping("h", ":echo \"hi<\" . synIDattr(synID(line(\".\"),col(\".\"),1),\"name\") . '> trans<' . synIDattr(synID(line(\".\"),col(\".\"),0),\"name\") . \"> lo<\" . synIDattr(synIDtrans(synID(line(\".\"),col(\".\"),1)),\"name\") . \">\"<CR>")
474
475 fun! Uncluttered_Buffer() "{{{2
476   if exists("uncluttered_buffer")
477     if uncluttered_buffer == 1
478       return 1
479     endif
480   endif
481
482   if version >= "600"
483     if &buftype != ''
484       return 1
485     endif
486   endif
487
488   if &ft == 'perforce'
489     return 1
490   endif
491
492   if &ft == 'svn'
493     return 1
494   endif
495
496   if &ft == 'gitcommit'
497     return 1
498   endif
499
500   return 0
501 endfun "}}}2
502
503 fun! Startup_Resize() "{{{2
504   let l:columns = 0
505
506   " Resize for numbers.
507   if &number
508     if version >= "700" && has("linebreak")
509       let l:columns = &numberwidth
510     else
511       let l:columns = 8
512     endif
513   endif
514
515   " Resize for signs.
516   if has("signs")
517     if g:marksigns
518       if version >= "600"
519         let l:columns = l:columns + 2
520       endif
521     endif
522   endif
523
524   if g:oldcols < (80 + l:columns)
525     call Resize_Columns("+", l:columns)
526   endif
527 endfun "}}}2
528
529 " Change status bar colour when various things happen.
530 " Flags: H/h: Cursor held/moved.
531 "        F/f: Focus gained/lost.
532 "        I/i: Insert mode entered/left.
533 fun! Highlight_StatusLine(flag) "{{{2
534   if ! has("statusline")
535     return
536   endif
537   " Get current status.
538   call Iain_Vars()
539
540   " Change the status based on the flag.  XXX: Does Vim let us to do flags?
541   let l:ic = &ic
542   set ic
543   let b:iainstatus = substitute(b:iainstatus, a:flag, a:flag, "")
544   let &ic = l:ic
545
546   let l:normalcolour = "darkblue"
547   let l:editingcolour = "darkmagenta"
548   let l:warningcolour = "darkred"
549   let l:readonlycolour = "red"
550
551   " Default colour.
552   let l:colour = l:normalcolour
553   " Maybe override depending on status.
554   if b:iainstatus =~# "H"
555     if b:iainstatus =~# "I"
556       " Held in insert mode.  Add extra highlight if we don't have focus.
557       if b:iainstatus =~# "f"
558         let l:colour = l:warningcolour
559       else
560         let l:colour = l:editingcolour
561       endif
562     endif
563   else
564     if b:iainstatus =~# "I"
565       " Regular insert mode.
566       let l:colour = l:editingcolour
567     endif
568   endif
569
570   " Override again if readonly.
571   if l:colour != l:normalcolour
572     if getbufvar("", "&ro")
573       let l:colour = l:readonlycolour
574     endif
575   endif
576
577   let l:termcolour = Iain_Colour(l:colour)
578
579   exec "highlight StatusLine gui=none term=none cterm=none guifg=white guibg=" . l:colour . " ctermfg=white ctermbg=" . l:termcolour
580   exec "highlight User1 gui=bold term=bold cterm=bold guifg=white guibg=" . l:colour . " ctermfg=white ctermbg=" . l:termcolour
581 endfun "}}}2
582
583 fun! Iain_Colour(colour) "{{{2
584   if &t_Co == 88
585     if a:colour == "darkblue"
586       return 17
587     elseif a:colour == "darkmagenta"
588       return 33
589     elseif a:colour == "darkred"
590       return 32
591     elseif a:colour == "red"
592       return 64
593     endif
594   elseif &t_Co == 256
595     if a:colour == "darkblue"
596       return 17
597     elseif a:colour == "darkmagenta"
598       return 90
599     elseif a:colour == "darkred"
600       return 88
601     elseif a:colour == "red"
602       return 196
603     endif
604   else
605     return a:colour
606   endif
607 endfun "}}}2
608
609 if has("autocmd")
610   au StatusLine VimEnter * call Highlight_StatusLine("")
611
612   " Show numbers by default.
613   au Display VimEnter * if ! Uncluttered_Buffer() | call Number(0) | endif
614 endif
615 endif "}}}1
616
617 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
618 " Handle options only available in Vim 5.4 and above.
619 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
620 if version >= "504" "{{{1
621 version 5.4
622
623 " Reuse windows when using sbuffer.
624 se switchbuf=useopen
625
626 " Allow persistent variable saving for localvimrc.
627 se viminfo+=!
628
629 " Do we have Unicode?
630 fun! Has_Unicode() "{{{2
631   if ! has('multi_byte')
632     return 0
633   endif
634
635   if version < "602"
636     return 0
637   endif
638
639   if &tenc =~? '^u\(tf\|cs\)'
640     return 1
641   endif
642
643   if ! strlen(&tenc) && &enc =~? '^u\(tf\|cs\)'
644     return 1
645   endif
646
647   return 0
648 endfun "}}}2
649
650 " Helper for status line.
651 " Show space, underscore or dollar sign depending on list mode.
652 fun! Show_List() "{{{2
653   call Iain_Vars()
654   if w:iainlist == 0
655     " No list.
656     return " "
657   elseif Has_Unicode()
658     if w:iainlist == 1
659       " Just tabs.
660       return "»"
661     else
662       " Full list.
663       return "¶"
664     endif
665   else
666     if w:iainlist == 1
667       return "_"
668     else
669       return "\$"
670     endif
671   endif
672 endfun "}}}2
673
674 " Helper for status line.
675 " Show c or C to denote case-sensitivity.
676 fun! Show_Case() "{{{2
677   if &ic
678     return "c"
679   else
680     return "C"
681   endif
682 endfun "}}}2
683
684 " Helper for status line.
685 " Show the size of the tabstop.
686 fun! Show_Tabstop() "{{{2
687   return &ts
688 endfun "}}}2
689
690 " Helper for status line.
691 " Show p when paste mode is on.
692 fun! Show_Paste() "{{{2
693   if &paste
694     return "p"
695   else
696     return ""
697   endif
698 endfun "}}}2
699
700 " Helper for status line.
701 " Show v when virtualedit mode is block, insert or onemore.
702 " Show V when virtualedit mode is all.
703 fun! Show_VirtualEdit() "{{{2
704   if ! has("virtualedit")
705     return ""
706   endif
707
708   if &ve == "all"
709     return "V"
710   elseif &ve != ''
711     return "v"
712   else
713     return ""
714   endif
715 endfun "}}}2
716
717 " Helper for status line.
718 " Show U when persistent undo is on.
719 " Show u when persistent undo is off but an undofile exists.
720 fun! Show_Undo() "{{{2
721   if ! exists("&undofile")
722     return ""
723   endif
724
725   if &undofile
726     return "U"
727   elseif filereadable(undofile(expand("%")))
728     return "u"
729   else
730     return ""
731   endif
732 endfun "}}}2
733
734 " Helper for status line.
735 " Show alternate buffer number and name.
736 fun! Show_Alt() "{{{2
737   let l:alt = bufnr("#")
738   if l:alt < 0 || l:alt == bufnr("") || ! b:iainalt
739     return ""
740   endif
741
742   return " " . l:alt . ": " . expand("#:t")
743 endfun "}}}2
744
745 " Helper for status line.
746 " Show scrollbind or cursorbind.
747 fun! Show_Bind() "{{{2
748   if has("cursorbind")
749     if &cursorbind
750       if Has_Unicode()
751         return "⇄"
752       else
753         return ">"
754       endif
755     elseif &scrollbind
756       if Has_Unicode()
757         return "⇅"
758       else
759         return "^"
760       endif
761     endif
762   endif
763   return ""
764 endfun "}}}2
765
766 " Show the status line.
767 fun! Show_StatusLine() "{{{2
768   if ! has("statusline")
769     return
770   endif
771   call Iain_Vars()
772   let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R]%{Show_Alt()}\ '
773   let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%V%0*\ \|\ %P'
774   let l:hexformat='%b'
775   if b:iainhex
776     let l:hexformat='0\x%02B'
777   endif
778   if b:iainverbose
779     let l:sl1=l:sl1 . v:version . '\ %='
780     let l:sl2=l:hexformat . '\ \|\ P:%4.6o\ '
781   else
782     let l:sl1=l:sl1 . '%='
783     let l:sl2=''
784   endif
785   exec "set statusline=" . l:sl1 . l:sl2 . l:sl3
786 endfun "}}}2
787
788 " Show the status line for the first time.
789 call Show_StatusLine()
790 endif "}}}1
791
792 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
793 " Handle options only available in Vim 6 and above.
794 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
795 if version >= "600" "{{{1
796 version 6.0
797
798 if has("win32") || has("win64")
799   se encoding=utf-8
800 endif
801
802 " Remember quickfix state.
803 if has("quickfix")
804   let g:quickfixing=0
805 endif
806
807 " Set indenting by filetype.
808 filetype indent on
809
810 " Less intrusive syntax highlighting.
811 if has("syntax")
812   " The :syntax enable command tries to source the syntax.vim runtime script.
813   " Parsing this .vimrc will fail if for some reason the runtime doesn't
814   " exist, as could be the case if the binary was installed with no support
815   " files.  GNU On Windows is one example of an incomplete installation.
816   try
817     syn enable
818   catch
819   endtry
820 endif
821
822 " Set colours.
823 if has("gui_running")
824   if has("win32") || has("win64")
825     exe "silent se guifont=DejaVu_Sans_Mono:h10:cANSI"
826   else
827     exe "silent se guifont=DejaVu\\ Sans\\ Mono\\ 10"
828   endif
829 endif
830 if has("gui_running") || &t_Co > 16
831   exe "silent colo iain"
832 endif
833
834 " Ignore whitespace when diffing.
835 if has("diff")
836   se diffopt=filler,iwhite
837 endif
838
839 if has("autocmd")
840   if has("quickfix")
841     " Remember that we are opening the quickfix window.
842     au Mode BufWinEnter quickfix let g:quickfixing=1
843     au Mode BufUnload * if &ft == "qf" | let g:quickfixing=0 | endif
844   endif
845
846   " Allow in-place editing of crontabs.
847   au Mode FileType crontab set backupcopy=yes
848 endif
849
850 " Make * and # work the way you expect in visual mode.
851 vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
852 vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
853
854 " Set mark and update highlighting.
855 if has("signs")
856   au Signs BufReadPost * call <SID>Highlight_Signs()
857   au Signs CursorHold * call <SID>Highlight_Signs()
858 endif
859
860 " Helper to set buffer variable for a given sign.
861 fun! <SID>Prep_Sign(sign) "{{{2
862   if ! exists("b:sign" . a:sign) || ! g:marksigns
863     exe "let b:sign" . a:sign . "=0"
864    endif
865 endfun "}}}2
866
867 fun! <SID>Place_Sign(number, line, old, name) "{{{2
868   if a:line == a:old
869     return a:old
870   endif
871
872   exe "sign unplace " . (g:firstsign + a:number) . " buffer=" . bufnr("")
873   " Don't place the sign if it would conflict with the last change sign.
874   exe "sign place " . (g:firstsign + a:number) . " line=" . a:line . " name=" . a:name . " buffer=" . bufnr("")
875   return a:line
876 endfun "}}}2
877
878 fun! <SID>Highlight_Signs(...) "{{{2
879   if ! has("signs") || ! g:marksigns || Uncluttered_Buffer()
880     return
881   endif
882
883   let l:signs = g:iainsigns
884   let l:sign = ""
885   let l:i = 0
886   while strlen(l:signs)
887     let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=>-][^ ]\+')
888
889     let l:name = substitute(l:sign, '[:.=>-].*', "", "")
890     let l:var = tolower(l:name)
891     let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "")
892     let l:ascii = matchstr(l:sign, '^:.')
893     let l:mark = substitute(l:sign, '^\(:.\)*[.=>-]', "", "")
894     if strlen(l:ascii)
895       let l:ascii = substitute(l:ascii, '^:', "", "")
896     else
897       let l:ascii = l:mark
898     endif
899     let l:ascii = substitute(l:ascii, '"', '\\"', "")
900
901     if l:ascii == "o"
902       let l:line = "."
903     else
904       let l:line = "'" . l:ascii
905     endif
906
907     call <SID>Prep_Sign(l:var)
908     exe "let " . l:var . " = <SID>Place_Sign(" . l:i . ", line(\"" . l:line . "\"), b:sign" . l:var . ", \"Mark" . l:name . "\")"
909     let l:i = l:i + 1
910
911     let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
912   endwhile
913 endfun "}}}2
914
915 " Toggle signs.
916 fun! <SID>Cycle_Signs(resize) "{{{2
917   if ! has("signs")
918     return
919   endif
920   call Iain_Vars()
921   let g:marksigns = ! g:marksigns
922
923   " Retrofit arrays on to Vim 6.
924   if ! exists("g:iainsigns")
925     " Signs are defined in g:iainsigns.  The syntax is as follows:
926     "
927     " Sign ::= Name (':' Mark)* Type Symbol
928     " Type ::= '=' | '-' | '.'
929     "
930     " Signs with Type '=' will be highlighted with the MarkSign group.
931     " Signs with Type '-' will be highlighted with the MarkLine group.
932     " Signs with Type '.' will be highlighted with the MarkDot group.
933     " Signs with Type '>' will be highlighted with the MarkArrow group.
934     " Define the Mark where Symbol is not also the mark name, eg "']".
935     let g:iainsigns = "Less=< Greater=> Left=( Right=) SquareLeft=[ SquareRight=] BraceLeft={ BraceRight=} a-a b-b c-c d-d e-e f-f A-A B-B C-C D-D E-E F-F"
936     if Has_Unicode()
937       let g:iainsigns = g:iainsigns . " Quote:\"=” Dash:'=’ Caret:^.ʌ Dot:..•"
938       if version < "704"
939         let g:iainsigns = g:iainsigns ." Cursor:o>▶"
940       endif
941     else
942       let g:iainsigns = g:iainsigns . " Quote=\" Dash=' Caret.^ Dot:..*"
943       if version < "704"
944         let g:iainsigns = g:iainsigns ." Cursor>o"
945       endif
946     endif
947   endif
948
949   if g:marksigns
950     " Signs to highlight marks.
951     " Syntax won't work properly in Vim 6.
952     let l:signs = g:iainsigns
953     let l:sign = ""
954     while strlen(l:signs)
955       let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=>-][^ ]\+')
956
957       let l:name = substitute(l:sign, '[:.=>-].*', "", "")
958       let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "")
959       let l:ascii = matchstr(l:sign, '^:.')
960       let l:mark = substitute(l:sign, '^\(:.\)*[.=>-]', "", "")
961       if strlen(l:ascii)
962         let l:ascii = substitute(l:ascii, '^:', "", "")
963         let l:ascii = matchstr(l:ascii, '^.')
964       else
965         let l:ascii = l:mark
966       endif
967       let l:ascii = substitute(l:ascii, '"', '\\"', "")
968       let l:type = substitute(l:sign, '^:.', "", "")
969       let l:type = matchstr(l:type, '^.')
970
971       let l:hl = ""
972       if l:type == "="
973         let l:hl = "texthl=MarkSign text="
974       elseif l:type == "."
975         let l:hl = "texthl=MarkDot text="
976       elseif l:type == "-"
977         let l:hl = "texthl=MarkLine text="
978       elseif l:type == ">"
979         let l:hl = "texthl=MarkArrow text="
980       endif
981
982       exe "sign define Mark" . l:name . " " . l:hl . l:mark
983
984       let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
985     endwhile
986
987     if a:resize
988       call Resize_Columns("+", 2)
989     endif
990     call <SID>Highlight_Signs()
991   else
992     let l:i = 0
993     while l:i < 25
994       exe "sign unplace " . (g:firstsign + l:i)
995       let l:i = l:i + 1
996     endwhile
997
998     let l:signs = g:iainsigns
999     let l:sign = ""
1000     while strlen(l:signs)
1001       let l:sign = matchstr(l:signs, '^[A-Za-z]\+')
1002
1003       exe "sign undefine Mark" . l:sign
1004       call <SID>Prep_Sign(tolower(l:sign))
1005       let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
1006     endwhile
1007
1008     if a:resize
1009       call Resize_Columns("-", 2)
1010     endif
1011   endif
1012 endfun "}}}2
1013
1014 " Change list mode.
1015 fun! Cycle_List() "{{{2
1016   " Pretty UTF-8 listchars.
1017   if Has_Unicode()
1018     let basic='tab:»·,trail:…,extends:«,precedes:»'
1019     let eol='eol:¶'
1020     if version >= "700"
1021       let basic=basic . ',nbsp:•'
1022     endif
1023   else
1024     let basic='tab:\\_,trail:_,extends:<,precedes:>'
1025     let eol='eol:$'
1026     if version >= "700"
1027       let basic=basic . ',nbsp:+'
1028     endif
1029   endif
1030   call Iain_Vars()
1031   let w:iainlist = w:iainlist + 1
1032   if w:iainlist > 2
1033     let w:iainlist = 0
1034   endif
1035   if w:iainlist == 0
1036     setlocal nolist
1037   elseif w:iainlist == 1
1038     exec "setlocal lcs=" . basic
1039     setlocal list
1040   else
1041     exec "setlocal lcs=" . basic . "," . eol
1042     setlocal list
1043   endif
1044
1045   call Resize_Columns(Extra_Columns("list", "iainlist", " == 2"), 1)
1046   call Extra_Whitespace_Match()
1047 endfun "}}}2
1048
1049 " Cycle between hex and decimal display of toolbar stuff.
1050 fun! Cycle_HexStatusLine() "{{{2
1051   call Iain_Vars()
1052   let b:iainhex = ! b:iainhex
1053   call Show_StatusLine()
1054 endfun "}}}2
1055
1056 " Cycle verbose display of toolbar stuff.
1057 fun! Cycle_VerboseStatusLine() "{{{2
1058   call Iain_Vars()
1059   let b:iainverbose = ! b:iainverbose
1060   call Show_StatusLine()
1061 endfun "}}}2
1062
1063 " Toggle quickfix window.
1064 fun! Cycle_Quickfix() "{{{2
1065   if ! has("quickfix")
1066     return
1067   endif
1068   if g:quickfixing == 1
1069     cclose
1070     let g:quickfixing=0
1071   else
1072     copen
1073   endif
1074 endfun "}}}2
1075
1076 " Toggle showing alternate buffer information.
1077 fun! Cycle_Alt() "{{{2
1078   call Iain_Vars()
1079   let b:iainalt = ! b:iainalt
1080   call Show_StatusLine()
1081 endfun "{{{2
1082
1083 " To be overridden later if applicable.
1084 fun! Extra_Whitespace_Match() "{{{2
1085   " NOP.
1086 endfun "}}}2
1087
1088 " Swap hex/decimal statusline with \x.
1089 call Mapping("x", ":call Cycle_HexStatusLine()<CR>:<CR>")
1090 " Change statusline verbosity with \v.
1091 call Mapping("V", ":call Cycle_VerboseStatusLine()<CR>:<CR>")
1092 " Cycle list styles with \l.
1093 call Mapping("l", ":call Cycle_List()<CR>:<CR>")
1094 " Toggle tags with \t.
1095 call Mapping("t", ":Tlist<CR>")
1096 " Change foldmethod with \f.
1097 call Mapping("f", ":se foldenable!<CR>:<CR>")
1098 " Toggle quickfix window with \q.
1099 call Mapping("q", ":call Cycle_Quickfix()<CR>:<CR>")
1100 " Rerun filetype detection with \s.  The s is for syntax, as this will be
1101 " updated as a side-effect.
1102 call Mapping("S", ":filetype detect<CR>:<CR>")
1103 " Toggle marks with \m.
1104 call Mapping("m", ":call <SID>Cycle_Signs(1)<CR>:<CR>")
1105
1106 if has("autocmd")
1107   " Show signs by default.
1108   au Display VimEnter * call <SID>Cycle_Signs(0)
1109 endif
1110 endif "}}}1
1111
1112 " move.
1113 nmap <A-u> <Plug>MoveLineHalfPageUp
1114 nmap <A-d> <Plug>MoveLineHalfPageDown
1115 vmap <A-u> <Plug>MoveBlockHalfPageUp
1116 vmap <A-d> <Plug>MoveBlockHalfPageDown
1117
1118 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1119 " Handle options only available in Vim 7 and above.
1120 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1121 if version >= "700" "{{{1
1122 version 7.0
1123
1124 " Helper to show tab name.
1125 fun! <SID>TabName(label, gui) "{{{2
1126   let l:label = a:label
1127   if l:label == ""
1128     let l:label = "No Name"
1129     if a:gui
1130       let l:label = "[" . l:label . "]"
1131     endif
1132   else
1133     let l:label = fnamemodify(l:label, ":t")
1134     if strlen(l:label) >= 18
1135       let l:label = l:label[0:17] . ".."
1136     endif
1137   endif
1138   return l:label
1139 endfun "}}}2
1140
1141 " Find out if any buffer was modified.
1142 fun! <SID>TabModified(buflist) "{{{2
1143   let l:i = 0
1144   while l:i < len(a:buflist)
1145     if getbufvar(a:buflist[l:i], "&modified") == 1
1146       return "+"
1147     endif
1148     let l:i = l:i + 1
1149   endwhile
1150   return ""
1151 endfun "}}}2
1152
1153 " Tab line.
1154 fun! Show_TabLine() "{{{2
1155   let l:s = "%#TabLineFill#Tabs:"
1156
1157   let l:i = 0
1158   while l:i < tabpagenr("$")
1159     let l:i = l:i + 1
1160     " Get the label.
1161     let l:buflist = tabpagebuflist(l:i)
1162     let l:winnr = tabpagewinnr(l:i)
1163     let l:n = tabpagewinnr(l:i, "$")
1164     let l:label = <SID>TabName(bufname(l:buflist[l:winnr - 1]), 0)
1165     let l:modified = <SID>TabModified(l:buflist)
1166
1167     " Choose highlighting.
1168     if l:i == tabpagenr()
1169       let l:s .= "%#TabLineSel#[" . l:n . l:modified . " " . l:label . "]"
1170     else
1171       let l:s .= "%#TabLine# " . l:n . l:modified . " " . l:label . " "
1172     endif
1173   endwhile
1174
1175   " Padding.
1176   let l:s .= "%#TabLine#%T"
1177   return l:s
1178 endfun "}}}2
1179
1180 " Per tab label for the GUI.
1181 fun! Show_GUITabLine() "{{{2
1182   let l:buflist = tabpagebuflist(v:lnum)
1183   let l:winnr = tabpagewinnr(v:lnum)
1184   let l:s = tabpagewinnr(v:lnum, "$")
1185   let l:label = <SID>TabName(bufname(l:buflist[l:winnr - 1]), 1)
1186   let l:modified = <SID>TabModified(l:buflist)
1187
1188   let l:s .= l:modified . " " . l:label
1189   return l:s
1190 endfun "}}}2
1191
1192 " Handle searching in a BufExplorer window.
1193 fun! <SID>BufExplorer_Search(n) "{{{2
1194   if a:n == 0
1195     let l:re = '^  *\d %'
1196   else
1197     let l:re = "^ *" . a:n
1198   endif
1199
1200   " Find matching line.
1201   let l:line = search(l:re, 'w')
1202   if ! l:line
1203     return
1204   endif
1205
1206   if a:n == 0
1207     return
1208   endif
1209
1210   " Peek ahead to the next matching line.
1211   let l:next = search(l:re, 'w')
1212
1213   " Select the buffer if the match is unambiguous.
1214   if l:next == l:line
1215     exe "normal \<CR>"
1216     return
1217   endif
1218
1219   " Go back.
1220   call cursor(l:line, 0)
1221 endfun! "}}}2
1222
1223 " Entering a BufExplorer window.
1224 fun! <SID>BufExplorer_Map() "{{{2
1225   for l:n in [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
1226     exec "nnoremap <buffer> <silent>" . l:n . " :call <SID>BufExplorer_Search(" . l:n . ")<CR>"
1227   endfor
1228 endfun "}}}2
1229
1230 if has("windows")
1231   se tabline=%!Show_TabLine()
1232   se guitablabel=%!Show_GUITabLine()
1233 endif
1234
1235 if has("autocmd")
1236   au StatusLine CursorHoldI * call Highlight_StatusLine("H")
1237   au StatusLine CursorMovedI * call Highlight_StatusLine("h")
1238   au StatusLine FocusGained * call Highlight_StatusLine("F")
1239   au StatusLine FocusLost * call Highlight_StatusLine("f")
1240   au StatusLine InsertEnter * call Highlight_StatusLine("I")
1241   au StatusLine InsertLeave * call Highlight_StatusLine("i")
1242
1243   if has("signs")
1244     au Signs CursorHoldI * call <SID>Highlight_Signs()
1245     au Signs InsertEnter * call <SID>Highlight_Signs()
1246     au Signs InsertLeave * call <SID>Highlight_Signs()
1247   endif
1248
1249   au Mode BufEnter \[BufExplorer\] call <SID>BufExplorer_Map()
1250 endif
1251
1252 " Limit the size of the popup menu when completing.
1253 if has("insert_expand")
1254   se pumheight=20
1255 endif
1256
1257 " Make diffs vertical by default.
1258 if has("diff")
1259   se diffopt+=vertical
1260 endif
1261
1262 " Set size of numbers column.
1263 if has("linebreak")
1264   se numberwidth=5
1265 endif
1266
1267 " Add "previous tab" mapping as gb.
1268 map gb :tabprevious<CR>:<CR>
1269
1270 " Transparency.
1271 if has("gui_macvim")
1272   se transparency=15
1273 endif
1274
1275 " Yet more GUI options.  Add tabs.
1276 if has("gui")
1277   se go+=e
1278 endif
1279
1280 " Perforce.
1281 let g:p4EnableMenu=1
1282 let g:p4Presets='P4CONFIG'
1283
1284 " BufExplorer.
1285 let g:bufExplorerShowRelativePath=1
1286 let g:bufExplorerSplitOutPathName=0
1287
1288 " NERDcommenter.
1289 let g:NERDSpaceDelims=1
1290 endif "}}}1
1291
1292 " localvimrc.
1293 let g:localvimrc_persistent=1
1294
1295 " Gitv.
1296 let g:Gitv_OpenHorizontal='auto'
1297 let g:Gitv_WipeAllOnClose=1
1298
1299 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1300 " Handle options only available in Vim 7.2 and above.
1301 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1302 if version >= "702" "{{{1
1303 if has("autocmd")
1304   " http://vim.wikia.com/wiki/Highlight_unwanted_spaces
1305   augroup WhitespaceMatch
1306   autocmd!
1307   au Display BufWinEnter * call Extra_Whitespace_Match()
1308   au Display Syntax * call Extra_Whitespace_Match()
1309   au Display BufWinLeave * call clearmatches()
1310   augroup END
1311
1312   fun! Extra_Whitespace_Match() "{{{2
1313     " \s\+            <whitespace>
1314     "            $    <before end of line>
1315     "        \@<!     <unless preceded by>
1316     "     \%#         <cursor position, ie when typing>
1317     let l:pattern = '\s\+\%#\@<!$'
1318     " Don't match single space in first column of diff.
1319     if &ft =~# '^diff$\|git'
1320       "         \@!  <unless also matching>
1321       " \(^\s$\)     <a single whitespace>
1322       let l:pattern = '\(^\s$\)\@!' . l:pattern
1323     endif
1324
1325     let l:hl = 'ctermfg=red guifg=red'
1326     if ! &list
1327       " Underline if we aren't using listchars.
1328       let l:hl = l:hl . ' cterm=underline gui=underline'
1329     endif
1330     highlight clear ExtraWhitespace
1331     exe "highlight ExtraWhitespace " . l:hl
1332     if exists('w:whitespace_match_number')
1333       try
1334         call matchdelete(w:whitespace_match_number)
1335       catch
1336       endtry
1337       call matchadd('ExtraWhitespace', l:pattern, 10, w:whitespace_match_number)
1338     else
1339       let w:whitespace_match_number = matchadd('ExtraWhitespace', l:pattern)
1340     endif
1341   endfun "}}}2
1342
1343   call Extra_Whitespace_Match()
1344 endif
1345
1346 endif "}}}1
1347
1348 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1349 " Handle options only available in Vim 7.3 and above.
1350 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1351 if version >= "703" "{{{1
1352 version 7.3
1353
1354 " Toggle persistent undo with \u.
1355 call Mapping("u", ":call <SID>Cycle_Undo()<CR>:<CR>")
1356 " Remove persistent undo file with \U.
1357 call Mapping("U", ":call <SID>Clear_Undo()<CR>:<CR>")
1358
1359 " Toggle gundo window with \g.
1360 call Mapping("g", ":call gundo#GundoToggle()<CR>:<CR>")
1361
1362 " Use a persistent undo file if it exists.
1363 fun! <SID>Check_Undo() "{{{2
1364   if filereadable(undofile(expand("%")))
1365     setlocal undofile
1366   endif
1367 endfun "}}}2
1368
1369 " Toggle persistent undo for this buffer.
1370 fun! <SID>Cycle_Undo() "{{{2
1371   if has("persistent_undo")
1372     let &undofile = ! &undofile
1373   endif
1374 endfun "}}}2
1375
1376 " Remove the persistent undo file for this buffer.
1377 fun! <SID>Clear_Undo() "{{{2
1378   if ! has("persistent_undo")
1379     return
1380   endif
1381
1382   setlocal noundofile
1383
1384   let l:f = expand("%")
1385   if l:f == ""
1386     return
1387   endif
1388
1389   let l:u = undofile(l:f)
1390   if l:u == ""
1391     return
1392   endif
1393
1394   if ! filereadable(l:u) || ! filewritable(l:u)
1395     return
1396   endif
1397
1398   call delete(l:u)
1399 endfun "}}}2
1400
1401 " Toggle ColorColumn at cursor position.
1402 fun! <SID>Cycle_ColorColumn() "{{{2
1403   if ! has("syntax")
1404     return
1405   endif
1406
1407   let l:cc = &colorcolumn
1408   let l:column = col(".")
1409   let l:re = ",*\\<" . l:column . "\\>"
1410   if l:cc =~# l:re
1411     let l:cc = substitute(l:cc, l:re, "", "g")
1412   else
1413     let l:cc = l:cc . "," . l:column
1414   endif
1415   let &colorcolumn = substitute(l:cc, "^,*", "", "")
1416 endfun "}}}2
1417
1418 if has("syntax")
1419   " Enable showing ColorColumn at cursor position with \CC.
1420   call Mapping("CC", ":call <SID>Cycle_ColorColumn()<CR>:<CR>")
1421   " Remove last shown ColorColumn with \Cc.
1422   call Mapping("Cc", ":let &colorcolumn=substitute(&colorcolumn, \",*[0-9]*$\", \"\", \"\")<CR>:<CR>")
1423   " Remove all ColorColumns with \Cx.
1424   call Mapping("Cx", ":se colorcolumn=<CR>:<CR>")
1425 endif
1426
1427 " Use persistent undo if available.
1428 if has("autocmd")
1429   if has("persistent_undo")
1430     au File BufReadPost * call <SID>Check_Undo()
1431   endif
1432
1433   if has("cursorbind")
1434     au Display WinEnter * if &diff | se cursorbind | endif
1435   endif
1436 endif
1437
1438 " Mapping to reload the gundo window.
1439 if has("autocmd")
1440   au Mode BufEnter * if &ft == "gundo" | try | nnoremap <silent> <buffer> <unique> r :call gundo#GundoToggle()<CR>:call gundo#GundoToggle()<CR> | catch | endtry | endif
1441 endif
1442
1443 endif "}}}1
1444 "
1445 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1446 " Handle options only available in Vim 7.4 and above.
1447 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1448 if version >= "704" "{{{1
1449 version 7.4
1450
1451 if has("syntax")
1452   se cursorline
1453 endif
1454
1455 endif "}}}1
1456
1457 " Resize after startup.
1458 if version >= "500" "{{{1
1459 if has("autocmd")
1460   au Display VimEnter * call Startup_Resize()
1461 endif
1462 endif "}}}1