Reputation: 821
I'm using ST3 and code in the C89 standard. The super useful for-loop auto completion completes to:
for (int i = 0; i < count; ++i)
{
/* code */
}
But this does not honor the standard. Can this behavior be changed in some config file to complete to:
int i = 0;
for (i < count; ++i)
{
/* code */
}
?
Upvotes: 1
Views: 168
Reputation: 3734
This is actually a snippet which is provided by c++ package that ships with sublime (that package covers both C and C++ due to their similarities).
The snippet which is responsible for the auto complete is in Packages\C++\Snippets\030-for-int-loop-(fori).sublime-snippet, and looks like this:
<snippet>
<description>For Loop</description>
<content><![CDATA[for (int ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${0:/* code */}
}]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.c, source.objc, source.c++, source.objc++</scope>
</snippet>
You can modify that as you prefer. To do this,
Modify the code to with this.
<snippet>
<description>For Loop</description>
<content>
<![CDATA[int ${2:i} = 0;
for ( ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${0:/* code */}
}]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.c, source.objc, source.c++, source.objc++</scope>
</snippet>
And save the file.
Upvotes: 1
Reputation: 365
You can find how to add specific auto- completion in the Sublime Text docs here - http://docs.sublimetext.info/en/latest/extensibility/completions.html. If you already have a Sublime Text package which is performing the C autocomplete for you, you might have to disable it.
Upvotes: 0