Reputation: 4078
When I'm creating Java files, I like to maintain a similar layout between all of my files, which looks something like this:
/*
* ThisFile.java
* Jamie Davies (2012)
*/
imports
package name
class
However, when Eclipse automatically adds appropriate import statements for me (which is a very handy feature), it always adds them to the very top of the file - resulting in my file comment being pushed down.
Is there any way to get Eclipse to automatically add imports at a certain position in the file - i.e, after my comment?
I've tried looking at the 'New Java Files' template, but there doesn't seem to be a $variable for important statements. I'm running Eclipse Juno (4.2.0) on OS X Mountain Lion (10.8).
Edit: It actually appears that after I've manually placed one import statement, Eclipse will automatically add others to the same location as the first.
Upvotes: 2
Views: 248
Reputation: 11950
In the new java files
template, edit the present one to the following
${filecomment}
${package_declaration}
${typecomment}
${type_declaration}
Hope that helps. You could even try new variables by clicking on the Insert Variable
button.
Upvotes: 2
Reputation: 286
add the first import by yourself and eclipse will automatically generate the others just following yours.
Upvotes: 0