Sublime Forum

Some C++ indentation errors

#1

When I write C++ codes like this and press Enter

int main()
{
	for(;;)
	{
		for(;;);
	}//press Enter here
}

There is no indentation in the next line. But if I change the inner loop to:

int main()
{
	for(;;)
	{
		for(;;)
			;
	}//press Enter here
}

Then everything works fine. It seems like indentation doesn’t work well with single-line loops.
Also if I write something like this:

int main()
{
	//type '}' here

Indentation is wrong as well. But if I put something inside the function:

int main()
{
	return 0;
	//press '}' here

Or even type something and delete it, indentation works fine.

Is there anything I can do to fix this? Thanks in advance.

0 Likes