views:

34

answers:

1

So I was using Eclipse and I went to go copy some import statements I had selected but I somehow miss-typed and the coolest thing happened: A snippet package was created and a class Snippet.java was created which looked like this:

package snippet;

public class Snippet {
    public static void main(String[] args) {
        // Selected code
    }
}

I have tried searching online but no luck. Does anyone know what this keyboard shortcut is to do this? It seems like a immensely useful feature to have.

Thanks

+3  A: 

This is what happens when you copy code and paste it into the Package Explorer. If you have a project selected, it will create the snippet package, if you have nothing selected then it will create a new java project named _pasted_code_

Andrew Niefer