Vim: C ++ back indent C #

I am using vim in C ++ code with openmp suggestions. And in my~/.vimrc

 set ai " auto indent

my problem: when I use the openmp clause (it starts with #), the cursor jumps to the beginning of the line without automatic indentation.

Example:

int main()
{
  int idx = 100;
#pragma omp parallel private(idx) // jump to begin of line

when i like it

int main()
{
  int idx = 100;
  #pragma omp parallel private(idx) // this is ok

ok Can I set this to autoindent in vim?

+5
source share
1 answer

Vim puts the row in column 1 when it starts with #(preprocessor directive) if it cinkeyscontains #.
So you can remove #from cinkeysto disable this feature:

:set cinkeys-=0#
+6
source

All Articles