Eclipse: setting default action for double-clicking files of a certain type - eclipse

I have .py and .js files in my Eclipse project for various reasons, but I don't ever want to execute them by double-clicking on them in Eclipse -- which is the default Eclipse behavior.
Is there a way I can change this default behavior so it just opens files in the Eclipse text editor, rather than executes the system "Open" command?

Open the main Preferences window and go to
General->Editors->File Associations

In Eclipse, On the menu bar at the top, go to
Window -> Preferences -> General -> Editors -> File Associations
Set the Open unassociated files with to Text Editor
This opens your files with the Eclipse text editor on double click.

Related

Eclipse TFS Error when double-clicking file - org.eclipse.ui.PartInitException: Unable to open external editor

I am getting the following error when clicking on a .xlsm file in TFS Explorer in Eclipse:
org.eclipse.ui.PartInitException: Unable to open external editor Excel
How can I resolve this error?
On Windows:
Navigate to Window -> Preferences -> General -> Editors -> File Associations.
If *.xlsm isn't in the list of File types, then click Add... and add it first.
Once this is done, select *.xlsm in the top box. I found that "Excel (default)" was the Associated Editor, which was the one that was failing. To get the Excel document to open in Excel instead, I first Removed the broken default editor, and then clicked Add...and selected Microsoft Excel Macro-Enabled Worksheet from the list.
Note that the list provided depends on the settings on your machine; and it's the file associations list rather than a list of programs. You can also click the "Browse..." button to select a specific program on your machine.

Where are per-file editor type overrides stored

In Eclipse, you have a set of default editors set up in Preferences > General > Editors > File Associations. When you open a file, if you select "Open With" and choose an editor other than the default for that file type, Eclipse remembers which editor you chose for that file, and uses it again when you re-open that file later.
Where are these per-file overrides for which editor to use stored?
If Open With has been used to select a specific editor this is stored using
IFile file = ... the file
file.setPersistentProperty(IDE.EDITOR_KEY, "editor id");
where IDE is org.eclipse.ui.ide.IDE.
you can use file.getPersistentProperty(IDE.EDITOR_KEY) to get this value.
Eclipse saves this information in the following file under the workspace:
.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
In that file, there are editor tags for the files being used in the workbench which associate them to the corresponding editors.

Eclipse insists on opening java files in Sublime

We recently upgraded our copies of Sublime. Problem is now our developers that use eclipse are having trouble opening java files. It seems that Eclipse has for one reason or another decided that half of the java files should be opened with "Java Editor" (when you right click and go to Open With) and the other half should open in "System Default" which as it turns out, is Sublime.
Where is the button I press to reset this stupid thing so Eclipse will open java files in Eclipse?
Eclipse "remembers" when files were "Open with"-ed with a certain Viewer and opens that file always with that Viewer from than on (it gets highlighted in the Options list and overrides the file-association).
You could try to change it back to the default by choosing "Default Editor" in the "Open with" context menu option in Project Explorer for each file that behaves strange.
The default editor for a file type can be set through Window>Preferences>General>Editors>File Associations. If multiple editors are set for .java and it's bugging out then possibly removing all editors except the default will help.

How can I change Eclipse color scheme for a specific file extension?

I've installed Eclipse Debugger Plugin for v8.
When a Javascript file is brought up from the remote connection, it has a .chromium extension.
Acutal color scheme for *.chromium files is not ideal but I haven't been able to figure out how to change it.
I went into Window > Preferences > General > Editors > File Associations and changed *.chromium file association from "JS Editor" to "JavaScript Editor" (used for .js files edition, and having the color scheme I want.)
However making this change had no effect.
I have the "Eclipse Color Theme" add-on installed and am using Eclipse version 4.2.1.M20120914-1800 running on windows 7.
Once I right clicked on one of the .chromium files and selected "Open With->JavaScript Editor" that file came up with the same editor as the js files. Doing this once must have fixed something in eclipse because now subsequently all .chromium files open up with the other editor.

Setting preferences for all Eclipse workspaces

How can I apply Eclipse preferences to all Eclipse workspaces?
For example if I go:
Window -> Preferences -> General -> Keys -> Add a Shortcut
I would like to use that shortcut in all of my Eclipse workspaces (different projects). Is there a way to apply preferences to all workspaces?
I would also like to configure what perspectives come up by default when I start a new workspace.
If you want preserve all your settings, simply copy the
.metadata/.plugins/org.eclipse.core.runtime/.settings
directory into your desired workspace directory
You can also export the preferences you set in the template workspace and then import them into other workspaces. This is the preferred method supported by Eclipse.
Go to
File->Export then choose General->Preferences
click Next then select the “Export all” radio button and fill in or browse to a file path where you want to save the preferences . Click Finish and your preferences are exported to that file.
Select
File->Switch Workspace,>… to switch to a different workspace.
When Eclipse restarts in the new workspace select File->Import then General->Preferences click Next and browse to your saved preferences file and click Finish to import your preferences into the current workspace.