Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Comment templates?(What, specifically, causes the comment template to fire?)
Comment templates? [message #553259] Mon, 16 August 2010 20:45 Go to next message
Steve Cohen is currently offline Steve Cohen
Messages: 43
Registered: July 2009
Member
I am tasked with maintaining a huge piece of legacy C code. I wish to "litter" this code with many small comments indicating where I've been and mapping various points in the code to certain larger concepts. And I would like to do so in a disciplined way so that these comments would easily be distinguishable from others.

I've modified the comment template to do this. Yet I don't see what I need to do in order to "launch" this template and cause its contents to be placed in my code.

Alternatively, rather than use the comment template, I could create a new code template. The question would then become "what would launch this template".

You might say that rather than a template, I'm looking for an editor macro. But those don't exist.
Re: Comment templates? [message #553305 is a reply to message #553259] Tue, 17 August 2010 06:19 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1952
Registered: July 2009
Senior Member
Quote:
The question would then become "what would launch this template".

Code templates are inserted when you start typing the name of the template ("comment" in your example) and hit CTRL-Enter. This will pop-up Code Assist and when you hit CTRL-ENTER once more you will get the template proposals. You can define this behavior in Preferences->C/C++->Editor->Content Assist->Advanced

BTW, I am using Task Tags for this kind of "code littering". You can define them in Preferences->C/C++->Task Tags
E.g. I have defined the tag MYTODO, so whenever I want to mark some code I insert a comment like this
 float a; // MYTODO: this should be initialized 


Eclipse will automatically recognize this self defined tag and add it to the Tasks View. In addition, you will see a task marker in the editor (left and right border).




Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Comment templates? [message #553690 is a reply to message #553305] Wed, 18 August 2010 13:53 Go to previous messageGo to next message
Steve Cohen is currently offline Steve Cohen
Messages: 43
Registered: July 2009
Member
Well, OK, thanks! I didn't realize I had to type comment followed by Ctrl-Space (not ctrl-enter, btw ) to launch the functionality. I was expecting it to be triggered by the Insert Block Comment on the menu.

However, I find the mechanism to be flaky.

I defined a new template for my special type of comments and yesterday it was working.

It now no longer is! Ctrl-Space now seems to ignore all the template proposals, not only for my new template but for any predefined template as well (such as "if"). My new template (defined as "w") now, when I type Ctrl-Space brings up only code reference suggestions beginning with w, not templates, even though templates are turned on on the code assist settings page.

What if anything am I misunderstanding - or is this a bug?

This is all by the way on the Helios version of Eclipse on Windows.
Re: Comment templates? [message #553691 is a reply to message #553690] Wed, 18 August 2010 13:56 Go to previous messageGo to next message
Steve Cohen is currently offline Steve Cohen
Messages: 43
Registered: July 2009
Member
answering my own question, partially:

The template suggestions DO seem to work when editing .c files but not when editing .h files.

What does this mean?
Re: Comment templates? [message #553857 is a reply to message #553691] Thu, 19 August 2010 08:24 Go to previous message
Axel Mueller is currently offline Axel Mueller
Messages: 1952
Registered: July 2009
Senior Member
Steve Cohen wrote on Wed, 18 August 2010 15:56
answering my own question, partially:

The template suggestions DO seem to work when editing .c files but not when editing .h files.

What does this mean?

Hm, I have no problems with .h files. Are template proposals in the default choice or do you have to hit CTRL-Enter twice (btw, you can define your own keymapping for template proposals).


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:Visualizing Data in Eclipse
Next Topic:Using linked resources
Goto Forum:
  


Current Time: Wed Sep 24 04:43:27 GMT 2014

Powered by FUDForum. Page generated in 0.02590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software