Sublime Forum

After hitting Enter, indentation is failed between curly braces

#1

Recently, I have installed Sublime text in Ubuntu20.04. But there is indentation problem .

#include<bits/stdc++.h>
using namespace std;
int main()

{|}

After hit enter, indentation is like this:

#include<bits/stdc++.h>
using namespace std;
int main()

{

|}

But it should be like this:

#include<bits/stdc++.h>
using namespace std;

int main()

{
… |
}

How can I fix this?

N.B. I also install some packages to solve this problem but in vain.

0 Likes

#2

This works for me out of the box. One thing to note is that the indent rules are based on the type of file that you’re editing, so you want to make sure that Sublime knows that you’re editing a C++ file by saving the file to disk with an appropriate extension or using the command palette and using Set Syntax: C++.

0 Likes

#3

Yes, I save the file name with. cpp extension and sublime text also show that it is c++ language. But indentation problem is not solved.

0 Likes

#4

Does it happen in safe mode?

0 Likes

#5

@bschaaf, No, it is not in safe mode. I face the same problem when I am using codeblocks.But in VS code, there is no such this problem. Perhaps, it is any package issue or related with operating system, I don’t know.

0 Likes

#6

If it’s not happening in safe mode then it’s likely a plugin installed or configuration you’ve made. I suggest using the "ignored_packages" setting to temporary disable packages to find the culprit.

0 Likes