1 " Vim profile.
  2 " Author: Peter Odding <peter@peterodding.com>
  3 " Last Change: September 5, 2010
  4 " URL: http://peterodding.com/code/vim/profile/vimrc
  5 
  6 " Enable syntax highlighting.
  7 syntax on
  8 
  9 " Enable file-type detection and file-type (indentation) plug-ins.
 10 filetype plugin indent on
 11 
 12 " Global options for Vim. {{{1
 13 
 14 set autoread
 15 set completeopt=menu
 16 set display=lastline showbreak=>>>\
 17 set ignorecase smartcase infercase
 18 set incsearch
 19 set linebreak nojoinspaces
 20 set modeline
 21 set path=.,~/.vim/** suffixesadd=.vim
 22 set ruler
 23 set tabpagemax=25
 24 set tabstop=2 shiftwidth=2
 25 set tags=./.tags;
 26 
 27 " Can't live with it, can't live without it:
 28 " http://groups.google.com/group/vim_dev/browse_thread/thread/dc24d36b9eee0b35
 29 set autochdir
 30 
 31 " When Vim wraps underlined text for display the underline continues in the
 32 " empty space at the end of the line. This bothers me about hyperlinks because
 33 " they get very long. Since hyperlinks don't contain whitespace the following
 34 " is a reasonable workaround:
 35 set breakat=\
 36 
 37 " Do use the currently active spell checking for completion though!
 38 " (I love this feature :-)
 39 set complete+=kspell
 40 
 41 " Don't complete tags because my "easytags.vim" plug-in makes my tags file grow
 42 " pretty big and it slows Vim down to scan it each time I complete…
 43 set complete-=t
 44 
 45 " Make Vim a bit more GUI friendly, see
 46 " http://groups.google.com/group/vim_dev/browse_frm/thread/2091f334b792c10a/
 47 set confirm
 48 
 49 " I've grown so tired of <Tab> that I've decided to ban it from my source code,
 50 " mostly because of indentation sensitive source code like Python.
 51 set expandtab
 52 
 53 " Make Vim open and close folded text as needed because I can't be bothered to
 54 " do so myself and wouldn't use text folding at all if it wasn't automatic.
 55 set foldmethod=marker foldopen=all,insert foldclose=all
 56 
 57 " Remember the last 5000 commands and search patterns in ~/.viminfo.
 58 set history=5000 viminfo='250,<0,r/tmp
 59 
 60 " Highlight matches for last used search pattern.
 61 set hlsearch
 62 
 63 " I don't use hidden buffers much but I do keep several Vim sessions around
 64 " using :mksession, and the number of loaded buffers in those tends to only
 65 " grow without this :-)
 66 set ssop-=buffers
 67 
 68 " Enable enhanced command line completion.
 69 set wildmenu wildmode=list:full
 70 
 71 " Ignore these filenames during enhanced command line completion.
 72 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
 73 set wildignore+=*.jpg,*.bmp,*.gif " binary images
 74 set wildignore+=*.luac " Lua byte code
 75 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 76 set wildignore+=*.pyc " Python byte code
 77 set wildignore+=*.spl " compiled spelling word lists
 78 set wildignore+=*.sw? " Vim swap files
 79 
 80 if has('gui_running')
 81   " Only highlight misspelled words in graphical Vim because it shows a red
 82   " underline; In the console a red background color is used which I really
 83   " don't like because it confuses me endlessly :-)
 84   if has('unix')
 85     set spell spelllang=en,nl spellcapcheck=
 86   endif
 87   set mousemodel=popup_setpos nomousehide
 88   set go-=m go-=T go-=r go-=L
 89   if has('gui_gtk2')
 90     let &gfn = string#trim(system('gconftool --get /desktop/gnome/interface/monospace_font_name'))
 91   elseif has('gui_win32')
 92     set gfn=Consolas:h13
 93   endif
 94   colorscheme wombat
 95   runtime mswin.vim " Still haven't unlearned Ctrl-C/Ctrl-V...
 96 elseif $TERM =~ 'xterm\|screen'
 97   " Enable 256 colors in console Vim.
 98   set t_Co=256
 99   " Enable the mouse in console Vim.
100   set mouse=a
101   " Set the terminal title even if it can't be restored.
102   set title
103   colorscheme xoria256
104   " None of the cursor keys work out of the box in console Vim but once I
105   " manually fix <Up>, the other cursor keys starts working magically?! See
106   " also https://bugs.launchpad.net/ubuntu/+source/vim/+bug/491615.
107   imap <Esc>[A <Up>
108   " Support <F11> in xterm so the :Fullscreen command from my shell.vim plug-in
109   " Just Works (TM), see http://peterodding.com/code/vim/shell/
110   nmap <Esc>[23~ <F11>
111 endif
112 
113 " Global options for syntax scripts, plug-ins, etc. {{{1
114 
115 " Scripts included in Vim's runtime files.
116 let c_syntax_for_h = 1 " See :help ft-c-syntax
117 let is_bash = 1 " See :help ft-bash-syntax
118 let java_allow_cpp_keywords = 1 " See :help ft-java-syntax
119 let netrw_hide = 1 " See :help netrw-hide
120 let netrw_list_hide = '^\(\..\{-}\.sw.\|.\{-}\.pyc\)$'
121 let python_highlight_all = 1 " See :help ft-python-syntax
122 let tex_flavor = 'latex' " See :help ft-tex-plugin
123 let tex_fold_enabled = 1 " See :help ft-tex-syntax
124 let vimsyn_noerror = 1 " See :help g:vimsyn_noerror
125 
126 " Scripts downloaded from http://www.vim.org/
127 let php_highlight_quotes = 1 " See http://www.vim.org/scripts/script.php?script_id=1571
128 
129 " Plug-ins developed by myself, see http://peterodding.com/code/vim/
130 let colorschemeswitch_filter = '^\(default\|delek\|peachpuff\|ron\|zellner\|elflord\|blue\|koehler\|dual\|railscasts\)$'
131 let notes_location = '/home/peter/Documenten/Notities/%s' " Unreleased plug-in for note taking in Vim.
132 let balloon_syntax = 0 " Unreleased plug-in that uses Vim's balloon-eval feature.
133 let shell_fullscreen_items = 'mT' " See http://peterodding.com/code/vim/shell/#shell_fullscreen_items_option
134 let easytags_resolve_links = 1 " See http://peterodding.com/code/vim/easytags/#easytags_resolve_links_option
135 
136 " Automatic commands. {{{1
137 
138 autocmd FileType c setlocal cms=/*%s*/
139 autocmd FileType gitcommit setlocal autoindent
140 autocmd FileType sh setlocal isfname-==
141 autocmd FileType sh,php setlocal textwidth=0
142 autocmd BufReadPost */etc/* setlocal textwidth=0
143 autocmd BufReadPost */var/log/* setlocal ft=messages
144 autocmd FileType messages setlocal nowrap nomodifiable nospell
145 autocmd SwapExists * let v:swapchoice = 'e'
146 autocmd BufReadPost ~/.vim-plugin-tool.conf setl ft=dosini nospell
147 
148 " Automatically sort word lists and generate spell files.
149 autocmd BufWritePre */spell/*.add %sort i
150 autocmd BufWritePost */spell/*.add silent mkspell! %
151 
152 " Enable completion dictionaries for PHP and Python buffers.
153 autocmd FileType python set complete+=k~/.vim/dict/python " isk+=.,(
154 autocmd FileType php set complete+=k~/.vim/dict/php
155 autocmd FileType lua set complete+=k~/.vim/dict/lua
156 
157 " Enable omni-completion in Python scripts.
158 autocmd FileType python set omnifunc=pythoncomplete#Complete
159 
160 " Hide # comment markers from folded text in Python scripts.
161 autocmd FileType python set commentstring=#%s
162 
163 " Disable syntax highlighting of the Rhythmbox music library (which is > 20M).
164 " TODO Find a plug-in that does this automatically for large files?!
165 autocmd BufEnter */.gnome2/rhythmbox/rhythmdb.xml syntax off
166 autocmd BufLeave */.gnome2/rhythmbox/rhythmdb.xml syntax on
167 
168 " Use a small tab stop and shift width for the following file types.
169 autocmd FileType c,css,html,lua,vim setlocal tabstop=2 shiftwidth=2
170 
171 " Enable completion of auto load function names in Vim scripts.
172 autocmd FileType vim setlocal iskeyword+=#
173 
174 " Enable clicking on hyphenated tags in Vim's help.
175 " TODO Can this be considered a bug in $VIMRUNTIME/ftplugin/help.vim?!
176 autocmd FileType help setlocal iskeyword+=-
177 
178 " Enable folding of #region markers in C# source code.
179 autocmd FileType cs setl fdm=marker fmr=#region,#endregion
180 
181 " Enable completion of hexadecimal color codes in CSS style sheets.
182 autocmd FileType css setlocal iskeyword+=#
183 
184 " Open tags files read-only and update the buffer when the file changes.
185 autocmd FileType tags setlocal readonly
186 
187 " Disable text wrapping and folds in quick-fix lists, HTML files and tags files.
188 autocmd FileType help,qf,tags,html,strace setlocal nowrap nofoldenable nospell
189 
190 " Disable my balloon evaluation plug-in in quick-fix lists and help windows.
191 autocmd FileType qf,help let [b:balloon_syntax, b:balloon_tags] = [0, 0]
192 
193 " Resize quick-fix lists to their contents but don't make them too big.
194 autocmd FileType qf execute 'resize' min([&lines / 2, line('$')])
195 
196 " Use text background color for non text area as well.
197 autocmd ColorScheme * highlight NonText guibg=bg
198 
199 " Really ignore the "Ignore" highlighting group!
200 autocmd ColorScheme * highlight Ignore guifg=bg
201 
202 " Automatically make files in ~/bin/ executable. {{{2
203 
204 if has('unix')
205   autocmd BufWritePost ~/bin/* call s:MarkExecutable()
206   function s:MarkExecutable()
207     let pathname = expand('%:p')
208     let listing = system('ls -l ' . shellescape(expand('%:p')))
209     if split(listing)[0] != '-rwxr-xr-x'
210       silent !chmod u=rwx,go=rx "%:p"
211       if v:shell_error
212         echoerr 'Failed to make ' . expand('%:p:~') . ' executable!'
213       else
214         let ft_save = &ft
215         silent edit
216         let &ft = ft_save
217       endif
218     endif
219   endfunction
220 endif
221 
222 " Customizations for diff mode. {{{2
223 
224 autocmd WinEnter * if &diff | call s:DiffTweaks() | endif
225 
226 function s:DiffTweaks()
227   " I don't like the diff colors used by most color schemes…
228   let diff_colors = 'default'
229   if g:colors_name != diff_colors
230     execute 'colorscheme' fnameescape(diff_colors)
231   endif
232   " I use automatic text folding which kind of breaks diff mode.
233   setlocal nofoldenable
234 endfunction
235 
236 " On-the-fly loading of project-specific tags files. {{{2
237 
238 " To avoid my global tags file from growing too large for Vim to be able to
239 " highlight, see also http://github.com/xolox/vim-easytags/commit/92cd87df83b24e1c45b946bc9eadbe4482de12ba
240 
241 autocmd BufReadPost,BufWritePost * call s:LoadTagsFile()
242 
243 function s:LoadTagsFile()
244   if &ft == 'c' || &ft == 'cpp'
245     if search('\c\<lua_\w', 'nw') >= 1
246       setl tags+=~/.vim/tags/lua-c-api
247     endif
248     if search('^#include "vim.h"$', 'nw') >= 1
249       setl tags+=~/.vim/tags/vim-src
250     endif
251     if search('\c\<apr_\w', 'nw') >= 1
252       setl tags+=~/.vim/tags/apr-c-api
253     endif
254     if search('\c\<Py[\u_]', 'nw') >= 1
255       setl tags+=~/.vim/tags/python-c-api
256     endif
257   endif
258 endfunction
259 
260 " Local additions to file type detection. {{{2
261 
262 augroup filetypedetect
263   au BufNewFile,BufRead * if getline(1) =~ '^!_TAG_' | setf tags | endif
264   au BufNewFile,BufRead *.desktop.* setf desktop
265   au BufNewFile,BufRead *.json setf javascript
266   au BufNewFile,BufRead *.list setf desktop
267   au BufNewFile,BufRead *.md set ft=mkd " override "ft=modula2"
268   au BufNewFile,BufRead *.pls setf dosini
269   au BufNewFile,BufRead *.vb set filetype=vb " override stupid "ft=conf" setting.
270   au BufNewFile,BufRead */etc/apache{,2}/*.conf setf apache
271   au BufNewFile,BufRead */etc/environment setf sh
272   au BufNewFile,BufRead */etc/mysql/*.cnf setf dosini
273   au BufNewFile,BufRead */nginx/* setf nginx
274   au BufNewFile,BufRead */sites-{available,enabled}/* setf apache
275   au BufNewFile,BufRead ~/.ctags setf sh
276   au StdinReadPost,BufRead * if getline(1) =~ 'sending incremental file list' | setf rsync | endif
277 augroup END
278 
279 " Allow reading of PDF and Word documents. {{{2
280 
281 " Based on the Vim profile at http://www.noah.org/engineering/dotfiles/.vimrc
282 " (thanks! :-). If you're using Ubuntu, install the "xpdf-utils" and "antiword"
283 " packages.
284 
285 autocmd BufReadPre *.pdf,*.doc setlocal readonly
286 autocmd BufReadPost *.pdf silent %!pdftotext -nopgbrk "%" - | fmt -csw78
287 autocmd BufReadPost *.doc call s:WordFilter()
288 
289 function s:WordFilter()
290   setlocal noreadonly modifiable
291   silent %!antiword -i 1 -s -f "%" -
292   silent %s/^\s\+\.\s\+//
293   setlocal readonly nomodifiable
294   setlocal filetype=antiword
295 endfunction
296 
297 " Make the :help command a little smarter. {{{2
298 
299 autocmd BufEnter * call s:CloseEmptyBuffer()
300 
301 function s:CloseEmptyBuffer()
302   if winnr('$') == 2 && &bt == 'help'
303     let bufnr = tabpagebuflist()[1]
304     let modified = getwinvar(2, '&modified')
305     if bufname(bufnr) == '' && !modified
306       only
307     endif
308   endif
309 endfunction
310 
311 " Adjust &tabstop for tab-delimited tags files. {{{2
312 
313 autocmd FileType tags call s:UpdateTabStop()
314 
315 function s:UpdateTabStop()
316   let width = 0
317   for values in map(getline(1, '$'), 'split(v:val, "\t")')
318     let width = max([width, strlen(get(values, 0, ''))])
319   endfor
320   let &l:tabstop = width + 1
321 endfunction
322 
323 " Restore cursor position in previously edited files. {{{2
324 
325 autocmd BufReadPost * call s:RestoreCursorPosition()
326 
327 function s:RestoreCursorPosition()
328   let lnum = line('''"')
329   if lnum > 0 && lnum <= line("$")
330     normal `"
331     normal zz
332   endif
333 endfunction
334 
335 " Automatic updating of "Last Change:" comments. {{{2
336 
337 autocmd BufWritePre * call s:UpdateLastChangeDate()
338 
339 function s:UpdateLastChangeDate()
340   let pattern = '\<Last Change:\s\zs.*'
341   let lnum = match(getline(1, 10), pattern)
342   if lnum >= 0
343     let existing = getline(lnum+1)
344     let substitute = substitute(strftime('%B %e, %Y'), '\s\{2,}', ' ', 'g')
345     let updated = substitute(existing, pattern, substitute, '')
346     if updated !=# existing
347       undojoin
348       keepjumps call setline(lnum+1, updated)
349     endif
350   endif
351 endfunction
352 
353 " I've configured my Ubuntu install to use the nl_NL locale but want strftime()
354 " to generate dates in English format inside s:UpdateLastChangeDate() above.
355 language C
356 
357 " User defined commands. {{{1
358 
359 command CopyFileName let @+ = expand('%:p') | echo "Copied" @+ "to clipboard"
360 
361 " Rename a buffer and its corresponding file. {{{2
362 
363 command -nargs=1 -complete=file RenameFile call s:RenameCmd(<q-args>)
364 
365 function s:RenameCmd(newfname)
366   let oldfname = expand('%:p')
367   let newfname = expand(a:newfname)
368   if filereadable(oldfname) && rename(oldfname, newfname)
369     call xolox#warning("Failed to rename file from `%s' to `%s'!", oldfname, newfname)
370     return
371   endif
372   execute 'saveas!' fnameescape(newfname)
373 endfunction
374 
375 " Delete a buffer and its corresponding file. {{{2
376 
377 command DeleteFile call s:DeleteCmd()
378 
379 function s:DeleteCmd()
380   let fname = expand('%:p')
381   if filereadable(fname) && delete(fname)
382     call xolox#warning("Failed to delete file `%s'!", fname)
383     return
384   endif
385   bdelete!
386 endfunction
387 
388 " Key mappings. {{{1
389 
390 " F3: Toggle folding of text without repositioning current line in window. {{{2
391 
392 imap <silent> <F3> <C-O>:call <Sid>ToggleFolding()<CR>
393 nmap <silent> <F3> :call <Sid>ToggleFolding()<CR>
394 
395 function s:ToggleFolding()
396   " Save the position of the text cursor.
397   let position = getpos('.')
398   " Get the screen line of the text cursor.
399   let winline = winline()
400   " Invert text folding and wrapping.
401   setlocal invfoldenable
402   " Redraw with calculated line at top of window.
403   let firstline = line('.')
404   for i in range(winline - 1)
405     let i = foldclosed(firstline)
406     let firstline = (i != -1 ? i : firstline) - 1
407   endfor
408   execute 'normal' firstline . 'zt'
409   " Restore the position of the text cursor.
410   call setpos('.', position)
411 endfunction
412 
413 " F5: Execute the :make command. {{{2
414 
415 " Bug fix: Always make sure working directory is correct!
416 
417 imap <silent> <F5> <C-O>:call <Sid>Reload()<CR>
418 nmap <silent> <F5> :call <Sid>Reload()<CR>
419 
420 function s:Reload()
421   if expand('%') =~ '^sftp://'
422     " Reload remote buffer.
423     silent edit
424   else
425     " Make project.
426     echo "Running make .. "
427     silent cd %:h
428     silent! make!
429     if v:shell_error == 0
430       echo ""
431       redraw
432     else
433       echohl warningmsg
434       echomsg "Failed to execute :make .."
435       echohl none
436       redraw
437     endif
438     silent cd -
439   endif
440 endfunction
441 
442 " C-]: Show list of matching tags when more than one tag matches <cword>. {{{2
443 
444 noremap <c-]> g<c-]>
445 
446 " "gf": Goto file in tab page instead of current window and open non-existing files. {{{2
447 
448 nmap gf :call <Sid>GotoFile()<CR>
449 
450 function s:GotoFile()
451   let fname = expand('<cfile>')
452   if fname !~ '^\w\+://'
453     " Expand &includeexpr?
454     if &includeexpr =~ '\<v:fname\>'
455       let substitute = xolox#escape#substitute(string(fname))
456       let result = eval(substitute(&inex, '\<v:fname\>', substitute, 'g'))
457       let fname = type(result) == type('') && result != '' ? result : fname
458     endif
459     " Search the Vim &path.
460     let path_elements = xolox#option#split(&path)
461     if index(path_elements, '.') == -1
462       call insert(path_elements, '.')
463     endif
464     let path = xolox#option#join(path_elements)
465     let names = xolox#unique(split(globpath(path, fname), '\n'))
466     if len(names) == 1
467       let fname = names[0]
468     elseif len(names) > 1
469       call map(names, 'fnamemodify(v:val, ":~:.")')
470       let index = inputlist(sort(names))
471       if index >= 0 && index < len(names)
472         let fname = names[index]
473       endif
474     endif
475   endif
476   call s:OpenInTabPage(fname)
477 endfunction
478 
479 function s:OpenInTabPage(fname)
480   if bufexists(a:fname)
481     try
482       let swb_save = &switchbuf
483       set switchbuf=useopen,usetab,split
484       execute 'sbuffer' fnameescape(fnamemodify(a:fname, ':p'))
485     finally
486       let &switchbuf = swb_save
487     endtry
488   else
489     " Silent because of hit-enter prompt caused by netrw.
490     silent execute 'tabnew' fnameescape(a:fname)
491   endif
492 endfunction
493 
494 " *** {{{2
495 
496 imap *** <C-o>:call <Sid>AlignedDelimiter()<CR>
497 
498 function! <Sid>AlignedDelimiter()
499   let delimiter = '* * *'
500   let textwidth = &textwidth
501   if textwidth == 0
502     let textwidth = 80
503   endif
504   let indent = (textwidth - len(delimiter)) / 2 - 1
505   call setline('.', repeat(' ', indent) . delimiter)
506   normal o
507   normal o
508 endfunction
509 
510 " ... {{{2
511 
512 imap ...513 
514 " iabbrev ... … doesn't really work because it only triggers after a space!
515 
516 " Use cursor keys to move by virtual (screen) lines. {{{2
517 
518 inoremap <expr> <Up> pumvisible() ? "\<C-P>" : "\<C-O>gk"
519 nnoremap <expr> <Up> pumvisible() ? "\<C-P>" : "gk"
520 inoremap <expr> <Down> pumvisible() ? "\<C-N>" : "\<C-O>gj"
521 nnoremap <expr> <Down> pumvisible() ? "\<C-N>" : "gj"
522 
523 " Control-Up: Move displayed lines up without moving cursor. {{{2
524 
525 imap <C-Up> <C-O><C-E>
526 nmap <C-Up> <C-E>
527 
528 " Control-Down: Move displayed lines down without moving cursor. {{{2
529 
530 inoremap <C-Down> <C-O><C-Y>
531 nnoremap <C-Down> <C-Y>
532 
533 " Alt-Left/Right: Goto older/newer cursor position in jump list. {{{2
534 
535 " FIXME: Sometimes I need to use <Alt-Left> or <Alt-Right> multiple times
536 " before the text cursor position is changed.
537 
538 inoremap <A-Left> <C-o><C-o>
539 nnoremap <A-Left> <C-o>
540 inoremap <A-Right> <C-o><C-i>
541 nnoremap <A-Right> <C-i>
542 
543 " Tab: Add one level of indent to selected lines. {{{2
544 
545 xmap <Tab> >0gv
546 smap <Tab> <C-O>V<C-O><Tab>
547 
548 " Shift-Tab: Remove one level of indent from selected lines. {{{2
549 
550 xmap <S-Tab> <0gv
551 smap <S-Tab> <C-O>V<C-O><S-Tab>
552 
553 " Tab: Start keyword completion after keyword characters. {{{2
554 
555 inoremap <expr> <Tab> <Sid>TabComplete()
556 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
557 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
558 inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
559 
560 function s:TabComplete()
561   if pumvisible()
562     " In the pop-up menu <Tab> selects the next menu item.
563     return "\<C-n>"
564   elseif search('\k\%#', 'bcn', line('.')) && getline('.') !~ '\S\t\+\S'
565     " After keyword characters <Tab> starts keyword completion, except on
566     " lines with tab-delimited fields like /etc/fstab and /etc/crypttab.
567     return "\<C-n>"
568   else
569     " In all other cases, fall back to the default behavior.
570     return "\<Tab>"
571   endif
572 endfunction
573 
574 " Control-Shift-PageUp: Drag active tab page left. {{{2
575 
576 imap <C-S-PageUp> <C-O>:TabMoveLeft<CR>
577 nmap <C-S-PageUp> :TabMoveLeft<CR>
578 
579 command -bar TML call s:TabMoveLeft()
580 command -bar TabMoveLeft call s:TabMoveLeft()
581 
582 function s:TabMoveLeft()
583   let n = tabpagenr()
584   execute 'tabmove' (n == 1 ? '' : n - 2)
585   " Redraw tab page labels.
586   let &showtabline = &showtabline
587 endfunction
588 
589 " Control-Shift-PageDown: Drag active tab page right. {{{2
590 
591 imap <C-S-PageDown> <C-O>:TabMoveRight<CR>
592 nmap <C-S-PageDown> :TabMoveRight<CR>
593 
594 command -bar TMR call s:TabMoveRight()
595 command -bar TabMoveRight call s:TabMoveRight()
596 
597 function s:TabMoveRight()
598   let n = tabpagenr()
599   execute 'tabmove' (n == tabpagenr('$') ? 0 : n)
600   " Redraw tab page labels.
601   let &showtabline = &showtabline
602 endfunction
603 
604 " Insert mode abbreviations. {{{1
605 
606 " I hate entering dots in abbreviations manually :-)
607 iabbrev aub a.u.b.
608 iabbrev svp s.v.p.
609 
610 " Define Dutch abbreviations with capitalized variants.
611 " (improvised &infercase for insert mode abbreviations)
612 
613 function s:DefCapAbbr(abbr, exp)
614   execute 'iabbrev' a:abbr a:exp
615   execute 'iabbrev' s:UcFirst(a:abbr) s:UcFirst(a:exp)
616 endfunction
617 
618 function s:UcFirst(s)
619   return substitute(a:s, '^\l', '\u\0', '')
620 endfunction
621 
622 call s:DefCapAbbr('bv', 'bijvoorbeeld')
623 call s:DefCapAbbr('dmv', 'door middel van')
624 call s:DefCapAbbr('dwz', 'dat wil zeggen')
625 call s:DefCapAbbr('icm', 'in combinatie met')
626 call s:DefCapAbbr('idd', 'inderdaad')
627 call s:DefCapAbbr('iig', 'in ieder geval')
628 call s:DefCapAbbr('iii', 'in eerste instantie')
629 call s:DefCapAbbr('ipd', 'in plaats daarvan')
630 call s:DefCapAbbr('ipv', 'in plaats van')
631 call s:DefCapAbbr('mbv', 'met behulp van')
632 call s:DefCapAbbr('oa', 'onder andere')
633 call s:DefCapAbbr('tov', 'ten opzichte van')
634 call s:DefCapAbbr('ws', 'waarschijnlijk')
635 call s:DefCapAbbr('zsm', 'zo snel mogelijk')
636 
637 " Miscellaneous things. {{{1
638 
639 " Define a function that can be called using "gvim --remote-expr ..." to
640 " change Vim's &guifont option in existing graphical Vim instances.
641 
642 function SetFont(s)
643   let &gfn = a:s
644   redraw
645 endfunction