How to set vim, not automatic indentation in extern "C" {line

In our project will be

#ifdef __cplusplus extern "C" { #endif int foobar(); // <-- vim auto indent it 

How to install vimrc or c-support so that vim does not automatically indent only extern "C" next to Marco to replace extern "C" {?

+6
source share
1 answer

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

0
source

Source: https://habr.com/ru/post/975338/


All Articles