Only one editor per file in eclipse? - eclipse

Eclipse PDE documentation claims:
You can think of the input object as the document or file that is
being edited. Changes made in an editor are not committed until the
user saves them.
Only one editor can be open for any particular editor input in a
workbench page. For example, if the user is editing readme.txt in the
workbench, opening it again in the same perspective will activate the
same editor. (You can open another editor on the same file from a
different workbench window or perspective).
Obviously it is possible to open a file using different editors - for example .java file using default java editor, and then text editor (by 'open with'). Is this part of the documentation wrong? Or is IEditorInput different for these two editors? I'm just wondering.

It was like that originally, and I think their point was double-clicking on an already open file will just bring it to the front, not open a new editor with the same information. Tht's still true, but that's not the whole truth :-)
I believe that section needs to be expanded, as I'm pretty sure the capability you refer to has been there for years as well. There's a "New Editor" entry in the editor tab context menu that allows you to open the same file in the same type of editor too.

Related

In RubyMine, how to preview a file's contents by selecting it like in Sublime Text?

I'm new to RubyMine 7 on Mac.
I used to use Sublime Text 3 and I love RubyMine so far except its lack of file previewing.
In Sublime Text, when clicking a file in the sidebar (file explorer), the selected file content shows in an editor tab for temporary viewing.
If I select another file, then the same tab changes to the content of the newly selected file.
I've been searching for this preference setting in RubyMine, or in a plugin, but I've had no luck.
A similar feature is "Autoscroll to source" but this feature opens files rather than previewing them.
If anyone knows how to do Sublime Text-like file content previewing in RubyMine, I'd appreciate it.
RubyMine doesn't have a feature exactly like Sublime Text file previewing.
The Quick Definition action can sometimes meet the same need. When invoked on a file, it opens a popup with the file's contents. You can invoke it on a file in the Project or Find pane and probably other panes, dialogs, popups, etc. that list files. (You can also invoke it in an editor on an identifier such as a class, module, or variable; it will show the code that defines the identifier.) Invoke Quick Definition with ⌥-space or ⌘Y in the Mac OS X 10.5+ keymap; use ^⇧I on Windows or check Preferences → Keymap for other keymaps, or use ⇧⌘A qd ⏎. Hit Escape or click outside the popup to close it.
When you invoke Quick Definition on a file in the Project pane and navigate to other files in that pane (with down and up arrows to move between files, and right and left arrows or Enter to open and close directories), the Quick Definition popup will stay open and update to the currently selected file, which is relatively close to Sublime Text file previewing. You can also hit Enter to open a file, F4 to open a file and move focus to the editor, edit the file, ⌘1 to jump back to the Project pane, etc., all with the Quick Definition popup still open, until you choose to close it.
If that isn't close enough, there are two feature requests for Sublime Text-like file previewing in JetBrains IDEs which you can vote for:
Preview currently selected file in project window
File Preview features from Sublime

Preventing Eclipse from opening external program inside Eclipse editor

I have an Excel file in the directory of my Eclipse project. When I double-click that file in the Package Explorer, Eclipse opens an instance of Excel as a new tab inside its editor window to the right.
Unfortunately this seems to be quite a buggy setup if there is another instance of Excel open outside of Eclipse:
I can't bring the other instance into the foreground and thus I can't use it any more
Excel lost a bunch of changes that I saved inside the editor window in Eclipse
So, I would really like to prevent Eclipse from opening Excel- (and possibly other) files inside a tab of the Eclipse editor. They should always open in a separate program (just as if I had opened the file from Windows Explorer). Is this possible?
Go to Window >> Preferences >> General >> Editors >> File Associations, click 'Add' right to the File Types list, add .xls, OK.
Now select .xls from the list, click 'Add' right to the Associated editors list, select External Programs Check Box, select Microsoft Excel, OK.
You can tell Eclipse to open Word, Excel, PDF etc. with the default external Editor in general, without adding *.doc, *.docx, *.xls, *.xlsx etc. to the File Associations:
Window => Preferences => General => Editors
Uncheck "Allow in-plcae system editors"
Source: "Prevent in-place OLE editors" of Eclipse Tips and Tricks
Right click on Excel file -> Open With -> System editor
After the first time, Eclipse will remember that that Excel file needs to be opened with the system editor.

How can I use a non-IFileEditorInput as the default EditorInput in my plugin?

I am in the middle of creating an Eclipse plugin that will open an editor. Everything is mapped out well - my plugin.xml is set up correctly to open the editor for anything with the .xyz extension. The only thing holding me back is the IEditorInput.
I have a subclass of IEditorInput that I created for use with my editor. When I open the editor programmatically, I can create that EditorInput and open the editor correctly. However, when I open the editor using Project Explorer (Right click > Open With > My Editor), it is opened with a FileEditorInput.
How can I change the default behavior of Project Explorer to create the correct IEditorInput? Is there something in plugin.xml that I'm missing?
Thanks!
The editor doesn't get to choose the kind of editor input object it's given. It can use a IDocumentProvider to support different kinds of IEditorInput, but you should never artificially limit your editor to working with one kind of input, even if you do manage to change how the Project Explorer works.

How to make Eclipse Open Resource in the Current Editor Window?

I like having multiple editor windows in eclipse, and use Open Resource (Ctrl-Shift-R) a lot.
Unfortunately, I always expect (and want) the resource to be opened in the current editor window (the one with focus). However, if I currently have that resource open (as a tab) in another editor, that tab will fill that editor, rather than opening in the current editor.
This is incredibly frustrating behaviour as the file in the editor being replaced is often the very file that I want to reference while opening the new one. How do I stop it, and make Eclipse behave sanely?

How to set default editor tab in Eclipse?

I'm using the HTML editor resp. the Structured Text Editor in Eclipse. It always opens in the tab Visual/Source:
Is it possible to tell Eclipse it should always open this editor in the Source tab?
You seem to use a plugin which associates with HTML files. For example Eclipse normally loads XML files for the first time with Design tab, and once you switch to source tab, it remembers the next time to open any document associated with XML Editor in Source tab. I don't know remembering is up to Eclipse or up to the plugin associated with the file, but a quick workaround would be:
to right click on the HTML file in package explorer > Open With > choose another editor (e.g. text editor). This only associates with current file. If you want to change file association for all HTMLs:
goto Preferences (under menu Window) > General > Editor > File Associations and change HTML file association there.
In Eclipse goto Windows-->Preferences-->Type Editors change the associated editors for File Types after that click on OK
You didn't say what version of Eclipse you're using. My HTML / Structured Text editors didn't have the tabs the same as yours. I'm using 3.4.2.
You can extend that editor by writing your own plug-in for Eclipse. Outside of the 'create a plug-in project' stuff, start by finding the extension points for the target editor. Then your plug-in can just register as an extension and add a new property instead of writing a whole editor. The property should show up on a preference page and then your code can take care of switching the active view of the editor to the 'Source' tab based on that property.
Right click the file and then "open with" and open it in another HTML or texteditor.
And then map this editor as the default editor for this filetype by right clicking the document and setting the file extension.
I always do this to get rid of the memory greedy WYSIWYG editors.