You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TextMate auto-indents C and C++ in an unexpected way. To be specific, I would like to get:
This (1):
switch (x) {
case 3:
sdrhit;
case 4:
dfsdkfsd;
}
Or this (2):
switch (x) {
case 3:
sdrhit;
case 4:
dfsdkfsd;
}
Unfortunately, instead, I get this:
switch (x) {
case 3:
sdrhit;
case 4:
dfsdkfsd;
}
I looked into this, and I understand that the Swift indent rules would behave as I expect. I'm told that I can edit the indentation rules, but for C, I don't see the word "select" mentioned anywhere in the indentation rules, so this is confusing to me. My opinion is that (1) or (2) should be default, but at the very least, documentation somewhere about how to change them to fix this specific case would be really nice.
The text was updated successfully, but these errors were encountered:
Ok, I figured out that the C indentation rules just don't mention switch/case or anything. I compared to Swift, and I edited C rules to be this:
{ increaseIndentPattern = '(?x)
^ .* \{ [^}"'']* $
| ^ \s* (public|private|protected): \s* $
| ^ \s* @(public|private|protected) \s* $
| ^ \s* \{ \} $
| ^ \s* (case\b .+ |default): # NEW!
';
decreaseIndentPattern = '(?x)
^ \s* ( (?! \S.* /[*] ) .* [*]/ \s* )? \}
| ^ \s* (public|private|protected): \s* $
| ^ \s* @(public|private|protected) \s* $
| (case\b .+ |default): \s* (/[/*] .*)? $ # NEW!
';
indentNextLinePattern = '(?x)^
(?! .* [;:{},] \s* # do not indent when line ends with ;, :, {, }, or comma
( // .* | /[*] .* [*]/ \s* )? $ # …account for potential trailing comment
| @(public|private|protected) # do not indent after obj-c data access keywords
)
. # the negative look-ahead above means we don’t care about what we match here
';
unIndentedLinePattern = '^\s*((/\*|\*/|//|template\b.*?>(?!\(.*\))|@protocol|@optional|@interface(?!.*\{)|@implementation|@end).*)?$';
zeroIndentPattern = '^\s*#';
}
Even if the devs don't want to make this the default, anyone else encountering this problem could refer to this bug report if they want to change it themselves.
TextMate auto-indents C and C++ in an unexpected way. To be specific, I would like to get:
This (1):
Or this (2):
Unfortunately, instead, I get this:
I looked into this, and I understand that the Swift indent rules would behave as I expect. I'm told that I can edit the indentation rules, but for C, I don't see the word "select" mentioned anywhere in the indentation rules, so this is confusing to me. My opinion is that (1) or (2) should be default, but at the very least, documentation somewhere about how to change them to fix this specific case would be really nice.
The text was updated successfully, but these errors were encountered: