Altering Eclipse user name

Using StatET’s code generation templates is handy, but the standard Eclipse variable for ${user} just inserts the currently logged-in user’s account name. If you want a different name to appear when ${user} is called, one method is to alter the eclipse.ini file.

Specifically, add the line = Your full name
at the end of the .ini file.

For instance, my eclipse.ini file looks like this:
-Xmx512m Miller

When I open a new R-script file in Eclipse now, StatET automatically inserts that user name.

You can further alter the generated code in the Eclipse Preferences window. Go to Window>Preferences and you’ll get the following window.

The StatET code generation options are accessed under the StatET item on the left menu tree.

Open the StatET section of the left menu tree, click on Code Generation. In the upper right window, open the R Code menu tree, and click on the New R Script File item. In the preview window, you’re shown an example of the automatically generated code that will be inserted at the head of every new R script file your create in Eclipse. You can edit this by hitting the Edit button.

Modifying the code generation settings. New variables can be inserted and deleted at will. Eclipse will show you the available code snippets if you enter a $ in the window.

In the Edit Template window, I’ve made a few changes. I inserted a line that says
# Filename: ${file_name}
That will print out “Filename:” and follow it with the name of each newly created R script file I make.
I also modified the 3rd line as follows:
# Author: ${user} ${date}
That will print out “Author:” followed by the user name I specified in the eclipse.ini file, followed by the current date.

To save the changes, hit OK, and then hit Apply in the Preferences Window.

If I create a new R script, which I’ve called “junk.R” here, I get the following automatically generated code in the window:

The result of the automatic code generation.