Inserting templates in C code [message #167811] |
Mon, 10 April 2006 19:49 |
Eclipse User |
|
|
|
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 #182000 is a reply to message #168421] |
Wed, 10 January 2007 08:56 |
Eclipse User |
|
|
|
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
"comment":
*/
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 |
Eclipse User |
|
|
|
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
> "comment":
> */
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 #182111 is a reply to message #182016] |
Thu, 11 January 2007 07:02 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02733 seconds