views:

102

answers:

2

I was using a certain file header for source code in Eclipse (defined in "Code Style") and now I changed it.

Is there a way to either change an existing file's header to the new one, or more simply and likely, just insert a file header to an existing file?

Thanks.

A: 

on Unix you can add a header to a file using the command shell:

echo "Header" > newfile
cat file1 >> newfile

see this for details.

Philipp
Fine, but I want to add the predefined Eclipse header which takes into consideration the file name, author, etc.
Amir Rachum
+1  A: 

There is a plugin that probably does what you want. I'd recommend checking out the Eclipse Releng tools, available from this update site:

The Eclipse Project Updates - http://download.eclipse.org/eclipse/updates/3.6

One of the tools is the Fix Copyright tool. Using this tool, you can select a project, provide a template (that includes variables such as author, and year of revision, etc). I think there is even a way to have it connect to CVS and automatically update last modified stamps in the template.

This plugin is what many of the Eclipse projects use to keep their headers up to date.

The plugin itself is not documented too well, but it is not hard to use. There is a bit of information here:

http://wiki.eclipse.org/index.php/Platform-releng-faq#How_do_I_use_the_releng_plugin.3F

Andrew Eisenberg
The first link is broken. Secondly, the second link talks about .java files, while I work with C++ (.cpp/.h files). Will it still work for me? Also, that is the *only* feature I need, while the plugin provides much more. I hope the other features won't be activated automatically.
Amir Rachum