Sublime Forum

Unindent on typing '#' in C++ syntax

#1

In C++, ‘#’ should generally start from the beginning of the line. At least it’s the most common style to type #ifdef … at the beginning of the line. I would love if Sublime would do that automatically by removing indentation when # is typed and there is nothing on the left of it besides whitespace. Or maybe can someone come up with keyboard binding or plugin that does that?

0 Likes

#2

+1, would like this feature too

0 Likes

#3

I find it more readable to indent preprocessor directives for the same reasons as indenting normal code. I guess it’s up to personal taste. I’d be fine with this as optional behaviour though.

0 Likes

#4

jonte, OK, but major IDE’s (VS, XCode) unindent automatically on inserting ‘#’ character so this probably means that this is more comment style. And more importantly, my company follows that style and thus also me. :smile:

So I’ve made a simple plugin to do that - github.com/rchl/UnindentPreprocessor
Eventually will probably appear on Package Control so will be easier to get. For now on github only.

0 Likes