Indenting in vim configured with 'cinoptions'. But it does not support "extern C". See the answer to a similar question .
function! IndentNamespace() let l:cline_num = line('.') let l:pline_num = prevnonblank(l:cline_num - 1) let l:pline = getline(l:pline_num) let l:retv = cindent('.') while l:pline =~# '\(^\s*{\s*\|^\s*//\|^\s*/\*\|\*/\s*$\)' let l:pline_num = prevnonblank(l:pline_num - 1) let l:pline = getline(l:pline_num) endwhile if l:pline =~# '^\s*extern "C".*' let l:retv = 0 endif return l:retv endfunction setlocal indentexpr=IndentNamespace()
Save it as ~ / .vim / indent / cpp.vim
lollo source share