1" Vim indent file 2" Language: git config file 3" Maintainer: Tim Pope <[email protected]> 4" Last Change: 2009 Dec 24 5 6if exists("b:did_indent") 7 finish 8endif 9let b:did_indent = 1 10 11setlocal autoindent 12setlocal indentexpr=GetGitconfigIndent() 13setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F 14 15" Only define the function once. 16if exists("*GetGitconfigIndent") 17 finish 18endif 19 20function! GetGitconfigIndent() 21 let line = getline(prevnonblank(v:lnum-1)) 22 let cline = getline(v:lnum) 23 if line =~ '\\\@<!\%(\\\\\)*\\$' 24 " odd number of slashes, in a line continuation 25 return 2 * &sw 26 elseif cline =~ '^\s*\[' 27 return 0 28 elseif cline =~ '^\s*\a' 29 return &sw 30 elseif cline == '' && line =~ '^\[' 31 return &sw 32 else 33 return -1 34 endif 35endfunction 36