vim : c++ back indent with #

I use vim in a c++ code with openmp sentences. And in my ~/.vimrc

 set ai " auto indent

my problem: when I use a openmp sentence (this begin with # ) the cursor jump to begin of line without the auto indent.

Example:

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

when I like this

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

ok I can set this in the autoindent in vim ?


Vim puts a line in column 1 when it starts with # (preprocessor directives), if cinkeys contains # .
So you can remove # from cinkeys to disable this feature:

:set cinkeys-=0#
链接地址: http://www.djcxy.com/p/8724.html

上一篇: vim不会正确缩进pascal代码

下一篇: vim:c ++用#缩进