Andrew Bucknell
Andrew Bucknell

Reputation: 1950

How do I clone a class in intellij?

I have a scala project in intellij. I would like to clone a new class into the same package the source class is in, but I cant figure out how to do this. I can see how to copy it to a new package, but I want to copy/clone within the same package.

[Edit]

If I have a class called orderwidget in package com.company.widgets and I want to create productwidget in com.company.widgets, I need to be able to clone orderwidget and rename it. Copy wont work because orderwidget already exists in the package.

Upvotes: 4

Views: 2994

Answers (1)

Mifeet
Mifeet

Reputation: 13608

What I use is drag & drop the file you try to copy to the parent folder in Project view, holding Ctrl to copy the file.

I admit it works in some cases but doesn't in others. Sometimes Idea offers you a dialog asking for name of the new file; sometimes is doesn't and gives "File already exists" error; sometimes it copies the file but messes up it's contents (Idea 14.1.4)

Upvotes: 3

Related Questions