Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Eclipse from auto-importing packages when pasting code?

Tags:

java

eclipse

ide

Frequently I copy and paste code from my existing code base. Eclipse frequently brings in erroneous import statements that I don't need

example, I copy and paste code into my project package named com.myproject.utilities into a file named twitter_class.java

and in the java file it adds

import com.pigmal.android.ex.twitter4j.TwitterConstants;

and this causes an error The import cannot be resolved. Of course it can't why, why did it even attempt to import that part when I didn't even select that for copying

I can imagine places where this is convenient, but it is never convenient for me and it is time consuming to repair so often.

How do I turn this off, in Eclipse, using Eclipse.

like image 237
CQM Avatar asked Jun 12 '12 18:06

CQM


People also ask

Does Eclipse auto import?

Let Eclipse automatically organise imports whenever you save a file.

How do I fix all imports in Eclipse?

1. Go to the line of unused import, press Ctrl + 1, which is an Eclipse shortcut of a quick fix. This will show a drop-down menu to fix this error and one of them will be “remove unused imports.” It will remove that import statement from the Java file.

How do I organize imports in Eclipse?

To enable this, go to Windows -> Preferences -> Java -> Editor -> Save Actions and then enable Perform the selected action on save -> Organize imports. After this, whenever you save a java file, eclipse will remove the unused imports automatically.

What is the shortcut key for importing packages in Eclipse?

Press: CTRL + SHIFT + O and you should see below dialog boxes. Choose your desired import package and click next. It will prompt you for your next import and thats it.


1 Answers

To turnoff the auto import while pasting

windows > preference > java > editor > Typing > (Under when pasting) uncheck update imports

like image 125
jmj Avatar answered Sep 22 '22 07:09

jmj