Sublime Forum

How to make the C++ default syntax indent 4 spaces instead of 1, inside the preprocessor?

#1

How to make the C++ default syntax indent 4 spaces instead of 1, inside the preprocessor?

If I am starting a new function as:

Everything when ok. (except for the unindent patter do not work on the closing brace, do you know how to fix it?)

But for the preprocessor it is not, if there is a block comment before it:

It tries to indent for it. Why it is not catching the #if indentation, instead of the line before it \n */?

0 Likes

#2

Created this file on Packages/C++/Indentation Rules - Increased.tmPreferences based on:

  1. #26207 Everything you (n)ever wanted to know about indentation in ST3

Indentation Rules - Increased.tmPreferences

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>doccomment.block.c++, comment.block.c++</string>
    <key>settings</key>
    <dict>
        <key>unIndentedLinePattern</key>
        <string>.</string>
    </dict>
</dict>
</plist>

It solved the preprocessor problem. But is actually it is not a problem because is desired that the preprocessor indentation to be ignored as it is usually is out from the correct scope. Example:

int main()
{
    function;
#if def
    code;
#endif
    morecode;
}

Now only remains the close brace problem:

(that black/gray box/rectangle on the gif is a bug from the gif recorder/compressor)

The brace should unindent on the after the empty line. But Sublime Text does not allow match against them, so we can fix it?

0 Likes