The following pieces of code are indented incorrectly by "Indent Selection" - ⌥⌘[ . Any fixes?
Prb 1:
/* This comment causes the problem in the indentation of the function statement below. I guess since it does not end with a semi-colon the following line gets indented. */
void abc() { if (xyz) {
} }
Prb 2:
void abc() { /* If this comment is removed, indentation is okay.*/ if (xyz) {
} }
On 8. Jun 2007, at 03:55, Pavan Gunupudi wrote:
The following pieces of code are indented incorrectly by "Indent Selection" - ⌥⌘[ . Any fixes? [...]
The indenter is based on a simple rule system described here [1]. I don’t see how it can be made to handle comments in all forms in all contexts, but probably you could improve is slightly to work with your code.
[1] http://macromates.com/textmate/manual/appendix#indentation_rules
On Thu, 7 Jun 2007, Pavan Gunupudi wrote:
The following pieces of code are indented incorrectly by "Indent Selection" - ⌥⌘[ . Any fixes?
FWIW, I find the best way to handle re-formatting C code is to filter it through the external 'indent' command. It's *highly* customizable and comes with reasonable defaults for a number of standard formatting styles (GNU, K&R, BSD). The indent package is available through MacPorts or can be compiled from source.
That said, it would be nice if TM's formatter was a little smarter about what it does while you're typing, but I can live with it as-is for now (at least until 2.0 comes out!)
Hello all...
Speaking of external indenting apps, I download and build 'astyle' (Artistic Style) and set up a bundle command Ctrl-Option- Command-[ to run it on the selection or the entire document. Works like a charm. Tons of indentation and style options!
From the Artistic Style web page:
"Artistic Style is a source code indenter, source code formatter, and source code beautifier for the C, C++, C# and Java programming languages."
Have a look at http://astyle.sourceforge.net/ and see if it's what you need. I don't know how it compares with 'indent', any comments on that?
JP
On Jun 8, 2007, at 9:15 AM, Steve King wrote:
On Thu, 7 Jun 2007, Pavan Gunupudi wrote:
The following pieces of code are indented incorrectly by "Indent Selection" - ⌥⌘[ . Any fixes?
FWIW, I find the best way to handle re-formatting C code is to filter it through the external 'indent' command. It's *highly* customizable and comes with reasonable defaults for a number of standard formatting styles (GNU, K&R, BSD). The indent package is available through MacPorts or can be compiled from source.
That said, it would be nice if TM's formatter was a little smarter about what it does while you're typing, but I can live with it as- is for now (at least until 2.0 comes out!)
-- Steve King, steve@narbat.com ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Thanks for the tips. I might have to go for external indenting apps. The thing is I collaborate with people who use Emacs and finding a common indentation scheme is kind of important while working on the same code base.
Pavan
On 8-Jun-07, at 9:46 AM, James Perry wrote:
Hello all...
Speaking of external indenting apps, I download and build 'astyle' (Artistic Style) and set up a bundle command Ctrl-Option- Command-[ to run it on the selection or the entire document. Works like a charm. Tons of indentation and style options!
From the Artistic Style web page:
"Artistic Style is a source code indenter, source code formatter, and source code beautifier for the C, C++, C# and Java programming languages."
Have a look at http://astyle.sourceforge.net/ and see if it's what you need. I don't know how it compares with 'indent', any comments on that?
JP
On Jun 8, 2007, at 9:15 AM, Steve King wrote:
On Thu, 7 Jun 2007, Pavan Gunupudi wrote:
The following pieces of code are indented incorrectly by "Indent Selection" - ⌥⌘[ . Any fixes?
FWIW, I find the best way to handle re-formatting C code is to filter it through the external 'indent' command. It's *highly* customizable and comes with reasonable defaults for a number of standard formatting styles (GNU, K&R, BSD). The indent package is available through MacPorts or can be compiled from source.
That said, it would be nice if TM's formatter was a little smarter about what it does while you're typing, but I can live with it as- is for now (at least until 2.0 comes out!)
-- Steve King, steve@narbat.com _____________________________________________________________________ _ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
-- BEGIN-ANTISPAM-VOTING-LINKS
Teach CanIt if this mail (ID 2351641) is spam: Spam: http://134.117.9.7/canit/b.php? i=2351641&m=83462aad042a&c=s Not spam: http://134.117.9.7/canit/b.php? i=2351641&m=83462aad042a&c=n Forget vote: http://134.117.9.7/canit/b.php? i=2351641&m=83462aad042a&c=f
END-ANTISPAM-VOTING-LINKS
On Fri, 8 Jun 2007, Pavan Gunupudi wrote:
Thanks for the tips. I might have to go for external indenting apps. The thing is I collaborate with people who use Emacs and finding a common indentation scheme is kind of important while working on the same code base.
Which is a very good reason to use an external app, and make sure everyone uses the same config file for it.