After a few hours of browsing for answers, testing plugins, and modifying ST3 language files, I am still stuck on an issue that seems common for others ( https://forum.sublimetext.com/t/line-reindent-does-not-work-for-comments/11460/1). I am working mainly in PHP/HTML on Build 3059. I have read that this problem occurs in other languages – so why not find a way to fix it together?
The ‘Reindent’ command seems to ignore some comments, keeping them on the first column (if starting with an unindented file). Specifically, any comments in this syntax:
// inline comment
/**
* multi-line comments
*/
Oddly enough, there is one type of comment that will indent correctly:
/* a comment using multi-line syntax on a single line WILL indent correctly */
This may not be a huge deal to anyone else, but it’s a bit of a nuisance to manually indent comments over to the correct column. And, to quote mindlube from the topic linked above:
“Compounding the issue: code lines below the comment get lined up with the comment, when re-indent is applied to them. So the end result is me having to always do manual indent/unindent-ing of comments.”
All-in-all, this leads to messy code, or too much time spent manually indenting comments.
In my quest to fix this problem, I stumbled upon the language files in the application packages (on OSX: Sublime Text.app > Contents > MacOS > Packages > PHP.sublime-package). After unzipping and looking over the contents, I found two files of particular interest:
- Indentation Rules Annex.tmPreferences
- Indentation Rules.tmPreferences
I became increasingly hopeful when I saw the properties ‘decreaseIndentPattern’ and ‘indentNextLinePattern’ in the ‘Indentation Rules.tmPreferences’ file and the property ‘unIndentedLinePattern’ in the ‘Indentation Rules Annex.tmPreferences’ file. Perhaps these properties have some sort of say over what lines are formatted / how to handle indentation.
Unfortunately, I cannot make sense of how these properties should be modified (if they should be at all…).
Has anyone poked through these files to make the sort of change I am looking for? Or am I jumping into too deep a rabbit hole?