JuanPablo
JuanPablo

Reputation: 24764

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 an openmp sentence (this begins with #) the cursor jumps to the beginning of the 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

Can I set this in the autoindent in Vim?

Upvotes: 5

Views: 842

Answers (1)

kev
kev

Reputation: 161674

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#

Upvotes: 8

Related Questions