Eclipse: have the same file open in two editors? - eclipse

When I'm editing a large file, I often want to have it open in two editing windows at once (eg. for reference, or because I'm working on two different parts of the file at once).
Is there any way to do this with Eclipse?

Open your file and then Window->New Editor (Note: in newer versions it will be called New Window)
Then, click on its tab and drag it somewhere else to have two editors of the same file
Update: as mentioned by moschlar, From version 4.4, two editors can be created with Window -> Editor -> Clone.

In Eclipse Luna (4.4) and above, this is supported out of the box: Window -> Editor -> Clone.

I realize he specified a new editing window. Showing an alternative for those, like me, that do not want a new editor but would like to be able to look at the file in two places at the same time in the same tab.
Window -> Editor -> Toggle Split Editor will split the editor horizontally or vertically.
Ctrl + _ is horizontal and Ctrl + { is vertical. More precisely it's Ctrl + Shift + - and Ctrl + Shift + [.
I had issues with it in Mars (see note below) that seem to have cleared up in Neon.
Mars Note: The split editor seems a bit buggy. The JavaScript editor likes to jump the cursor to the other pane momentarily when it does a while-you-type-validation.

Right click on your editor tab and select "New Editor".
... unless you have a newer version of eclipse, in which case do Window -> New Editor.

Window -> Editor -> Clone is also available in Neon 2 and, judging from the other comments seems to be available in all newer Eclipses.
It's my preferred solution.

In order to keep answers up to date i underline that with Eclipse STS this action is performed using window -> Editor -> Toggle split editor (horizental) | Toggle split editor (vertical)

In Eclipse Mars there is another way of doing it:
Window -> Editor -> Clone.
then drag the cloned tab to the corner to create a parallel window.

This seems to now be in the File-> New View Into File which opens the tab with focus into a new tab in the same group where you can then drag it to another group if you wish.

Related

How do you split and unsplit a window/view in Eclipse IDE?

How do you split a window/view in Eclipse IDE? I want to edit code while viewing the different code in the same file.
If there is a trick to open the same file twice, this might do, but I would rather just split the one current view instead of having two of the same which might get confusing.
This is possible with the menu items Window>Editor>Toggle Split Editor.
Current shortcut for splitting is:
Azerty keyboard:
Ctrl + _ for split horizontally, and
Ctrl + { for split vertically.
Qwerty US keyboard:
Ctrl + Shift + - (accessing _) for split horizontally, and
Ctrl + Shift + [ (accessing {) for split vertically.
MacOS - Qwerty US keyboard:
⌘ + Shift + - (accessing _) for split horizontally, and
⌘ + Shift + [ (accessing {) for split vertically.
On any other keyboard if a required key is unavailable (like { on a german Qwertz keyboard), the following generic approach may work:
Alt + ASCII code + Ctrl then release Alt
Example: ASCII for '{' = 123, so press 'Alt', '1', '2', '3', 'Ctrl' and release 'Alt', effectively typing '{' while 'Ctrl' is pressed, to split vertically.
Example of vertical split:
PS:
The menu items Window>Editor>Toggle Split Editor were added with Eclipse Luna 4.4 M4, as mentioned by Lars Vogel in "Split editor implemented in Eclipse M4 Luna"
The split editor is one of the oldest and most upvoted Eclipse bug! Bug 8009
The split editor functionality has been developed in Bug 378298, and will be available as of Eclipse Luna M4. The Note & Newsworthy of Eclipse Luna M4 will contain the announcement.
You can open a new editor from the Window menu.
This will give you your current editor once again.
If you right click on one of the tabs, one of the options should be New Editor (for me, it's at the bottom). Select that, and then drag the new tab onto the bottom scroll bar of the code editor, which will split the editor panel in two.
Just click and drag editor title to left, right, top or bottom
I tried the above solutions in Eclipse Luna 4.4.1 but couldn't open two (or multiple editor windows for different files side by side).
Simplest Solution:
Open all files you want in a single window.
Drag the tab of each of the files to right or to the left, eclipse will automatically display a split screen display and will split the editor into two windows once you leave the mouse button.
repeat for each file/tab.
Happy Coding!
Side by side editors in single Eclipse window.
You have an Eclipse window showing a single editor.
Window -> new editor. You now have two editor tabs.
Click and drag one tab towards the right and a green outline of a vertical screen appears (drag tag towards the bottom and an outline of a horizontal screen outline appears). You can let go as soon as the outline appears.
Open file of choice in 2nd editor (recent files show up at bottom of file menu).
ADT/Eclipse:Build: v22.3.0-887826
You might want to check an eclipse plugin called HandySplit
It allows to split an editor into two and move tabs from one editors stack to another with keyboard shortcuts only.
That works on Eclipse Juno or higher.
For the previous Eclipse versions check this out
Simply go to Window > New Window
This will open up a new window of the same Workspace in eclipse.
You can open up separate files in each Window.
Below are the steps to split editor horizontally or vertically
go to:
Window -> Editor -> Toggle Split Editor (Horizontal)
to split editor horizontally or
Window -> Editor -> Toggle Split Editor (vertical)
to split editor vertically.
It will open two editors side by side or will pileup tow.
If you want to see two different files in same eclipse you can,
Right-click a tab -> Detach
Now you can see both files at the same time without opening new eclipse and you can drag and reatach to tabs again.
On Mac OS, the key combination to toggle spit/unsplit for horizontal split is ⌘ ⇧ - ("cmd"+"shift"+"-"), whereas for vertical split, it is ⌘ ⇧ [ ("cmd"+"shift"+"[")

Eclipse: After Editing Long Lines Editor Window Automatically Scrolls to Beginning of Line

Some of my Javascript lines of code are longer than the editor window view. I have recently upgraded to the Helios version of Eclipse and noticed that after editing one of these long lines (I am scrolled to the right), after a few seconds the editor window will automatically scroll back to the left to the beginning of the line. It breaks my concentration and it's so annoying!
Does anyone know how to stop this behavior? I've searched around and haven't been able to find anything other than others being annoyed by this same issue!
I am not willing to turn on word wrap and wrap my lines :).
I was having the same issue and found these open bugs for it on the Eclipse Bugs.
No sign there of having a fix for it, but you can prevent it from happening when you switch the Code Folding off and reload the file.
For java in eclipse :
Windows -> Preferences -> Java ->Editors ->Folding -> Enable Folding (uncheck)
For HTML, JSP, XML etc in eclispe :
Windows -> Preferences -> General -> Editors -> Structured Text Editors -> Enable Folding (uncheck)
If you're using Mac OSX, press OPTION + COMMAND + O to turn off "Toggle Mark Occurrences" - it looks like a highlighter in the toolbar.
I turned off Toggle Breadcrumb, and it fixed my problem.

How to enable duplicate tabs in Eclipse? (i.e. duplicate windows)

If there's one thing I miss about emacs it's having 4 windows of the same file open, each at a different location in that file, for super quick referencing. Is there a way to get Eclipse to present multiple tabs of the same file?
On the Window menu choose Editor, then Clone (since 4.4.x) or New Editor (earlier versions). You can then drag the title bar around to get side-by-side views.
Another way would be to split the code editor view twice
But this will only be possible with Eclipse Luna 4.4 M4, as detailed by Lars Vogel in "Split editor implemented in Eclipse M4 Luna", in Bug 8009:
The split editor functionality has been developed in Bug 378298, and will be available as of Eclipse Luna M4. The Note & Newsworthy of Eclipse Luna M4 will contain the announcement.
Current shortcut for splitting is:
Ctrl + _ for split horizontally, and
Ctrl + { for split vertically.
Depending on your keyboard layout:
Andrew adds in the comments that you can need Ctrl + Shift .
el-teedee mentions (also in the comments) that, when pressing CTRL+{ in my Javascript editor, it inserts ''.
To fix this, I need to press CTRL+ALTGR+{ (Linux Ubuntu French keyboard),
Yeah, just right-click on the editor tab you want, and select "New Editor". It'll create a new tab editing the same file. You can then drag this new tab to the left or right edge of the view to get them in a "split screen" state. It's really very flexible.
I figured it out. Right-click tab > New Editor.
Other answers explain how to open multiple editors or split editor. If we are talking about other tabs/views that are not editor, it depends on the implementation.
TLDR: search for pin toggle or create new view button/option in view!
History view, Search view and other pinnable tabs - have "Pin this XXX View" toggle:
If you pin it it will keep the content and new Search (or history show) will show in new history view.
History view also has "Reuse Compare Editor" option so compares can be opened in same or separate tabs:
Markers view has option "New Markers View":
This view can be named and you can set custom filter for each view.
Similar is "Terminal View" that has button to open new terminal view:
Some tabs do not have any option to be duplicated. Tested with Eclipse 2019-12 (4.14.0)
I faced similar problem, but not with the main edit tabs: I wanted to have duplicate tabs in additional view panel (exactly: two junit views to compare different test runs).
In my case the only possible way to achive such thing was creating separate window: Window > New Window and openning new view there.
p.s. I'm using eclipse kepler 4.3.1.
For eclipse kepler , you can try right-click > open-with > any other like text editor
select window menu, then editor option, then clone

How to open the 'Projects' panel in Netbeans

In Netbeans, to the top left of where the code is, there used to be two panels, one called 'Projects' where you could click a project name to open a tree of all the directories and files in it, and you could double click a file to edit it.
Below it is the navigation panel which shows the class names, methods, etc contained in the file you're viewing.
I accidently clicked the close button on the projects panel and can't figure out how to get it to open again, any ideas?
In Netbeans 6.8 on Windows, going to Window -> Projects brings it back for me. CTRL + 1 works as the shortcut.
Click Window > Reset Windows will give you back the old state of all windows!
just go to Window in menu bar and select Projects
Window -> Projects
In NetBeans 8.2 Go to Window->Navigator in menu bar or press Ctrl+7 and select Projects
it will open a folder as work space .

Eclipse: keyboard shortcut to move tabs around?

Is there any way to setup an Eclipse keyboard shortcut which will split the current editor vertically and put the current tab on one side? For example, turning this:
before http://img.skitch.com/20100118-1n5xeuywunri6b91nfjpgdxxne.png
Into:
after http://img.skitch.com/20100118-t2c7g3nctx3w8bth4hq1rpqp9k.png
Not directly with eclipse (3.4 or 3.5)
The closest plugin I have found which might enable what you are looking for is the Split file Editor
Ctrl+6
Usage: Open a file in Eclipse, then select Window -> New Split Editor from the main menu to open a split editor of the file.
(not exactly what you want but:)
Split editor opens in a new tab as opposed to appearing within the existing tab
(so while there may be 2 instances of the same file editor, you still have a situation with one file on one side, and the other files on the other tab group)