views:

142

answers:

1

Hi,

I have been using Eclipse CDT for some time now, and I love it, but there are a few tedious things that I would like to fix up about it.

When you create a new file, one of the options is "New"->"Class". I was wondering if anyone knows of a way to edit the "${declarations}" section of this "Class" template.

To be more specific, I have looked through the "Window"->"Preferences" menu and been unable to find anything. I have changed both "C/C++"->"Code Style"->"Code Templates" and "C/C++"->"Editor"->"Templates". Only the first of the two actually seems to change what appears upon class creation, and it doesn't let me change what is in the "${declarations}" section. Does anyone know how to change this?

Thanks, Chris

+1  A: 

The preference C/C++ -> Editor -> Templates is used by the templates which are inserted manually via Context Assist. Try create a new file, type clas and press ctrl+space for context assist. You should get two assist proposals: a keyword proposal and a template proposal (the latter will also be triggered automatically as default if you type class and press ctrl+space).

Upon selection of the template proposal, a class body will be generated according to the template which you can define in this preference.


As for C/C++ -> Code Style -> Code Templates, this is used in automatic generation. When you use the New Class wizard, the Default C++ Source template and Default C++ Header template are used and the $(declarations) variable is replaced by whatever code is generated by the New Class wizard.


This would mean that you can use a custom template by triggering one of the Editor templates manually, possibly via creating a named class with New Class wizard and then replacing the default class body in header by your custom template.

Or do you suggest that the New Class wizard lacks any important fields and should be extended?

Kos
All of these are nice options. It would be cool if there was an easy way to literally change what $(declarations) expanded to, but this will do nicely. Thanks!
Chris Covert