Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Inserting templates in C code
Inserting templates in C code [message #167811] Mon, 10 April 2006 19:49 Go to next message
Eclipse UserFriend
Originally posted by: prash.pai.gmail.com

I have a file header template that I wish to insert at the beginning of
each C source and header file. How can I accomplish that? I have set up my
templates in Window->Preferences->C/C++->Editor->Templates

Ctrl+Space does not work for this. However, Ctrl+Space works for other
things such as if statements.

I also have a method header that also needs to have the same functionality.
Re: Inserting templates in C code [message #168421 is a reply to message #167811] Wed, 19 April 2006 08:08 Go to previous messageGo to next message
Anton Leherbauer is currently offline Anton LeherbauerFriend
Messages: 490
Registered: July 2009
Senior Member
Ctrl+Space will work if you enter the first letter(s) of the tempate's
name. E.g. if the template is named "file_header", then typing
fi<Ctrl+Space> should open the completion popup or the template is
inserted immediately if there is only one matching proposal and
auto-insert is enabled.

Prashant Pai wrote:
> I have a file header template that I wish to insert at the beginning of
> each C source and header file. How can I accomplish that? I have set up
> my templates in Window->Preferences->C/C++->Editor->Templates
>
> Ctrl+Space does not work for this. However, Ctrl+Space works for other
> things such as if statements.
>
> I also have a method header that also needs to have the same functionality.
>
Re: Inserting templates in C code [message #182000 is a reply to message #168421] Wed, 10 January 2007 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stm.pdflib.com

I seem to have the same problem as Prashant. Some Code Templates work as
expected, but specifically the comment templates do not work.

There's a "comment" template available by default which looks like this:


/*
* author ${user}
*
* To change this generated comment edit the template variable
&quot;comment&quot;:
*/

I would expect that if I type "/" or "/*" and then press CTRL+SPACE,
then the template is inserted or displayed for insertion, but Eclipse
only gives a message "No completions available".

Is there a specific problem with comment templates? This happens with
Eclipse 3.2.1 and CDT 3.1.1 on MacOS X.

Thanks
Stephan

Anton Leherbauer schrieb:
> Ctrl+Space will work if you enter the first letter(s) of the tempate's
> name. E.g. if the template is named "file_header", then typing
> fi<Ctrl+Space> should open the completion popup or the template is
> inserted immediately if there is only one matching proposal and
> auto-insert is enabled.
>
> Prashant Pai wrote:
>> I have a file header template that I wish to insert at the beginning
>> of each C source and header file. How can I accomplish that? I have
>> set up my templates in Window->Preferences->C/C++->Editor->Templates
>>
>> Ctrl+Space does not work for this. However, Ctrl+Space works for other
>> things such as if statements.
>>
>> I also have a method header that also needs to have the same
>> functionality.
>>
Re: Inserting templates in C code [message #182008 is a reply to message #182000] Wed, 10 January 2007 12:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: no.spam.dd

Am 10.01.2007, 09:56 Uhr, schrieb Stephan Mühlstrasser <stm@pdflib.com>:

> I seem to have the same problem as Prashant. Some Code Templates work as
> expected, but specifically the comment templates do not work.
>
> There's a "comment" template available by default which looks like this:
>
>
> /*
> * author ${user}
> *
> * To change this generated comment edit the template variable
> &quot;comment&quot;:
> */

you should not use the first characters of the template content but the
first chars of template NAME!!
So if your template is named "comment-template" start typing "comm" and
then press CTRL+SPACE.

Does this work?? Or did I misunderstood your problem?

andrés


>
> I would expect that if I type "/" or "/*" and then press CTRL+SPACE,
> then the template is inserted or displayed for insertion, but Eclipse
> only gives a message "No completions available".
>
> Is there a specific problem with comment templates? This happens with
> Eclipse 3.2.1 and CDT 3.1.1 on MacOS X.
>
> Thanks
> Stephan
>
> Anton Leherbauer schrieb:
>> Ctrl+Space will work if you enter the first letter(s) of the tempate's
>> name. E.g. if the template is named "file_header", then typing
>> fi<Ctrl+Space> should open the completion popup or the template is
>> inserted immediately if there is only one matching proposal and
>> auto-insert is enabled.
>> Prashant Pai wrote:
>>> I have a file header template that I wish to insert at the beginning
>>> of each C source and header file. How can I accomplish that? I have
>>> set up my templates in Window->Preferences->C/C++->Editor->Templates
>>>
>>> Ctrl+Space does not work for this. However, Ctrl+Space works for other
>>> things such as if statements.
>>>
>>> I also have a method header that also needs to have the same
>>> functionality.
>>>
Re: Inserting templates in C code [message #182016 is a reply to message #182000] Wed, 10 January 2007 13:00 Go to previous messageGo to next message
Anton Leherbauer is currently offline Anton LeherbauerFriend
Messages: 490
Registered: July 2009
Senior Member
To insert the comment template, enter "com" and press Ctrl+Space.
This is how templates in Eclipse work by default.

HTH,
Toni
Re: Inserting templates in C code [message #182111 is a reply to message #182016] Thu, 11 January 2007 07:02 Go to previous message
Eclipse UserFriend
Originally posted by: stm.pdflib.com

Anton Leherbauer schrieb:
> To insert the comment template, enter "com" and press Ctrl+Space.
> This is how templates in Eclipse work by default.
>
> HTH,
> Toni

Thanks Andrés and Toni for pointing this out. I was mislead by the text
in the Eclipse online help, which reads:

> Code templates
> ...
>
> When you enter a letter combination in the C/C++ editor, and type CTRL
> +SPACE (or right-click and click Content Assist), a list of code
> elements and code templates that start with the letter combination that
> you typed is displayed.

The sentence "... code templates that start with the letter combination
that you typed ..." confused me because I understood it as referring to
the text of the template and not to the name of the template.

Regards
Stephan
Previous Topic:--enable-auto-import error
Next Topic:how to add configure command into the build options
Goto Forum:
  


Current Time: Sun Oct 06 14:15:29 GMT 2024

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

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

Back to the top