693

How can I switch between opened windows in Eclipse? There is Ctrl+F6, but it's asking me which one I want, but I want switch it like tabs in browser or window in operating system (Cmd/Win+Tab) without file-selection from the list. How to do this easy thing in Eclipse?

I've tried to assign hotkey for events:

  • forward
  • forward history
  • next page

but it doesn't work the way I want.

Skay
  • 8,744
  • 6
  • 24
  • 26

22 Answers22

923
  • CTRL+E (for a list of editor)
  • CTRL+F6 (for switching to the next editor through a list)
    You can assign another shortcut to the 'Next Editor' key.

are the two official shortcuts, but they both involve a list being displayed.

CTRL+Page Up / CTRL+Page Down can cycle through editors without displaying a list.

What is interesting with that last set of shortcuts is:
they are not listed in the Eclipse Keys shortcuts to be defined.
They may be inherited from the multipage editor, making them an OS specific shortcut.


Regarding shortcuts on Mac OS (OSX), Matt Ball complained in Sept. 2011 to not being able to remap CTRL+Page Up/CTRL+Page Down:

It drives me nuts to not be able to flip through open tabs as I can in pretty much every other tabbed program in OS X (-Left and -Right).

Well, in March 2012, Arthur replied:

, I've just downloaded the latest version of Eclipse (3.7+). I've been able to bind "Previous/Next tab" to (-Left and -Right) when in Editor, which I'm pretty sure I couldn't do before.
So I guess they heard you.
It works just as you expect, tabs going from left to right and vice-versa, not on a history basis or some nonsense like that.

Matt Ball confirms:

oh wow, selecting "Editing Java Source" actually worked!
Now, unfortunately this means that I'm SOL if I nav into a non-Java file (JSP, XML, JS, etc.).
The fix for this is to "copy command" for this pair, and select all the "whens" that I want.
So far it's at least working beautifully for Java and JSP files.
This is a major PITA to set up, but it's just a one-time thing.

His exported preferences are available here for you to try.
Once imported, you should see, for all the relevant types of document:

Mac Os key bindings

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 7
    On OSX, replace CTRL with CMD for the first two keyboard actions. But you will still need to use CTRL with PgUp or PgDown to cycle through editors. Another set of useful KB shortcuts I just found while trying out some of the suggestions below: you can use ALT+Up or ALT+Down to move an entire line of code. – Tyler Aug 24 '11 at 02:30
  • 5
    No chance that there's now a way to remap `CTRL+Page Up`/`CTRL+Page Down` in Indigo, is there? It drives me nuts to not be able to flip through open tabs as I can in pretty much every other tabbed program in OS X (`⌘-Left` and `⌘-Right`). – Matt Ball Sep 26 '11 at 15:08
  • 24
    On an non-extended OSX keyboard: fn+ctrl+up_arrow / down_arrow by default. – Ben Flynn Dec 17 '11 at 20:56
  • 1
    @MДΓΓБДLL On OS X, I've just downloaded the latest version of Eclipse. I've been able to bind "Previous/Next tab" to (⌘-Left and ⌘-Right) when in Editor, which I'm pretty sure I couldn't do before. So I guess they heard you. It works just as you expect, tabs going from left to right and vice-versa, not on a history basis or some nonsense like that. – Arthur Mar 11 '12 at 11:18
  • @Arthur I just updated my Indigo installation to 3.7.2 and I still couldn't get this shortcut to work. All it does it move the cursor to the start/end of the line. I don't see an "editor" choice for the "When:" dropdown, so that might be part of the problem. http://i.stack.imgur.com/EXHuZ.png `::frustrating::` – Matt Ball Mar 11 '12 at 20:08
  • 1
    @MДΓΓБДLL ouch... I guess I should have said that I was on Eclipse for [C/C++](http://i.imgur.com/Xt6ZX.png). Sorry, didn't cross my mind. Doesn't it work with "Editing Java Source"? If that can dampen your pain, when I'm at the far right tab, ⌘-Right won't take me to the far left one... Also, I'm getting really annoying "false errors" (errors are displayed but everything compiles perfectly) since the update. Hope you don't get that too! – Arthur Mar 11 '12 at 20:51
  • @Arthur oh wow, selecting "Editing Java Source" actually worked! Now, unfortunately this means that I'm SOL if I nav into a non-Java file (JSP, XML, JS, etc.). The fix for this is to "copy command" for this pair, and select all the "whens" that I want. So far it's at least working beautifully for Java and JSP files. This is a major PITA to set up, but it's just a one-time thing. Thanks! – Matt Ball Mar 11 '12 at 21:22
  • 1
    @MДΓΓБДLL: thank you for the fix for non-java files. I have included it in the answer for more visibility. – VonC Mar 11 '12 at 21:46
  • One more thing: I've now set up [what _should_ be all the necessary hotkeys](http://i.stack.imgur.com/FmAaR.png) (in my Eclipse for JEE installation; YMMV), and exported my key bindings to save others some time: https://gist.github.com/2022533 – Matt Ball Mar 12 '12 at 15:08
  • Had no idea about Ctrl+PageUp and Ctrl+PageDown. In OS X, you can use Keyboard Maestro to override Eclipse altogether and just make Cmd+Shift+] do Ctrl+PageDown and Cmd+Shift+[ do Ctrl+PageUp. – duma Jun 23 '14 at 02:50
  • This answer is about switching editors. I'd love an answer to the question - about switching /windows/. – ChrisJJ Nov 04 '18 at 13:39
  • bloody hell... Eclipse is not consistent. i was looking everywhere for those CTLR page up and page Down shortcuts. i love eclipse but what a mess – Mordan Jan 26 '19 at 19:34
  • 1
    I remapped `ctrl-f6` to `ctrl-tab` and `ctrl-e` to `ctrl-p` to be consistent with the rest of the world. It's quite nice :) – gosukiwi Jul 03 '20 at 02:52
193

If you go to Preferences (e.g. Window→Preferences) and view General→Keys

and then search for “Next Tab” and “Previous Tab”, you can remap them.

Next Tab command in Eclipse Preferences, before rebinding

Rory O'Kane
  • 25,436
  • 11
  • 86
  • 123
victor
  • 6,378
  • 7
  • 39
  • 46
  • 15
    I've added "next tab" -> "Ctrl + Tab" "previous tab" -> "Ctrl + Shift + Tab" like it is in Firefox – Bruno Bieri Aug 18 '12 at 05:29
  • 19
    This is not exactly the right thing. This just cycles through the tabs in the order they appear on the tab bar vs. most recently switched to order. – Hafthor Sep 14 '12 at 18:13
  • Works great, except for the Android layout editor, which seems to absorb/ignore these commands. It's always something! – SMBiggs Oct 27 '12 at 19:50
  • 25
    @Hafthor: I am used to Notepad++, so I wanted the Ctrl+Tab to switch between the *last active* tabs/editors. To do this, remove the default Ctrl+F6 from "Next Editor" and Ctrl+Shift+F6 from "Previous Editor" commands and insert Ctrl+Tab and Ctrl+Shift+Tab for those commands instead. Note that I had to *remove* the old commands for some reason (which I didn't need to do in other cases where I changed keys), but glad that it works now! Also, while playing around, Eclipse (Juno) acted weird and I couldn't switch tabs using any of the usual or changed key combinations, but a restart fixed that. – FriendFX Mar 08 '13 at 01:08
  • 1
    I've added "next tab" -> "Ctrl + Tab" "previous tab" -> "Ctrl + Shift + Tab" like it is in Visual Studio – Memet Olsen Dec 16 '13 at 18:45
  • Excellent.When you are doing the same make sure you dont make any conflicts with assigned keys. I have always been looking for this one and never came across this question(Regrets). Assigned CTRL+Tab and CTRl+Shift+Tab as with Chrome. – Ajith Memana Jan 23 '14 at 10:41
  • Setting Scheme to Microsoft visual studio is the best choice for whom having .net back ground. You can easily navigate between tabs using Ctrl + tab keys. – Vahid Ghadiri Sep 19 '14 at 12:32
  • @FriendFX, thanks for your idea! Note that I had to clear the "Binding" of "Toggle Source/Header" (that was "Ctrl+Tab") in order to prevent conflict. – elady Jan 13 '15 at 20:20
108

Switch like Windows in OS (go to window which last had focus)

CTRL-F6 in Eclipse, like ALT-TAB (on windows), brings up a list of tabs/windows available (if you keep the CTRL / ALT key depressed) and highlights the one you will jump to when you let go of this key. You do not have to select the window. If you want to traverse several tabs at once hold down the CTRL button and tap the TAB button. This is identical behaviour to ALT-TAB on Windows.

In this sense, CTRL-SHIFT-F6 in eclipse is the ALT-SHIFT-TAB analog. Personally, I change these bindings in Eclipse to be like Visual Studio. I.e. CTRL-TAB and CTRL-SHIFT-TAB and I do it like this:

Window>Preferences>General>Keys

Then set "Next Editor"=Ctrl+Tab and "Previous Editor"=Ctrl+Shift+Tab. Don't forget to click "Unbind Command" before setting the new binding.

Switch like browser (go to tab on the right of current tab)

This is CTRL-PageDown to go right, CTRL-PageUp to go left. Frustratingly, when you get to the end of the list of tabs (say far right hand tab) and then try to go right again Eclipse does not cycle round to the first tab (far left) like most browsers would.

Hulk1991
  • 2,557
  • 11
  • 29
  • 44
Robino
  • 3,413
  • 2
  • 27
  • 36
  • 12
    This is the most under-rated answer in this thread. Especially since Juno changes which tabs are shown to be a pure list and not the recently used editors. – Jason Axelson Nov 08 '12 at 19:19
  • This works 90% of the time. It fails if your mouse cursor happens to be where the list of tabs pops up. Whatever unlucky tab pops up in front of the cursor gets selected. – User1 Jan 03 '13 at 21:54
  • Eclipse version 3.6.2 works 100% of the time, wherever the mouse is. It is, after all, Eclipse's natural behaviour re-mapped to different keys! Haven't tried ancient Eclipse versions though... – Robino Jan 16 '13 at 11:36
  • 1
    You don't have to unbind the "Next Editor" command. Just click "Copy Command" and edit the copy and bind it to `CTRL-TAB`. – Gillfish Dec 22 '14 at 18:35
  • It works after eclipse restart for me. Oxygen.3a Release (4.7.3a) I think this answer must be accepted. – omerhakanbilici May 17 '18 at 08:04
  • 1
    The unbind reminder is key. In eclipse 2019-03, it didn't work until the original command was removed, it seems to no longer support multiple bindings. – Liam Steele Jun 11 '19 at 04:57
  • @Robino wrote: "*Eclipse does not cycle round to the first tab*" You can configure Eclipse to do this! *Preferences > General > Appearance*, uncheck *Show most recently used tabs*. See here for [more info](https://stackoverflow.com/a/44959669/452775). – Lii May 15 '20 at 08:23
55

You can use ALT+Left to go to your previous tab, or ALT+Right to go to forward. This method is using tab-switching like history, though, so it will go to the previous tab you had open, and forward if you've gone "back" once or more. A bit weird, I know, but it works. You can always "reset" the history by clicking through every tab once.

peirix
  • 32,055
  • 22
  • 90
  • 125
  • 5
    Not useful when there are actions recorded in history, such as going to method definition in the same class. – SiN Jul 14 '11 at 13:16
  • this used to be useful, for eclipse helios this works as SiN mentioned – Toskan Sep 20 '11 at 12:13
  • 2
    I actually like the behavior where it goes to actions such as going to method definition, it's a useful way to go back and forth when navigating around a lot of files. – Ibrahim Oct 03 '12 at 01:44
  • 1
    This works great when cycling back and forth between editing windows. I like to split my screen in 2 and the other methods only cycle 1 tab grouping, (except ctrl-F6, but I find that cumbersome). – RestingRobot Nov 05 '13 at 20:14
15
  • Right side move : Ctrl + page Down
  • Left side move : CTRL + page Up

Additional

  • get list of open tabs : Ctrl + F6

Eclipse others Short Cuts

Jubin Patel
  • 1,876
  • 18
  • 37
13

CTRL + F6 is good to use. If you want to switch to next/previous tab, you need to do CTRL+Page Down / CTRL+Page Up.

Chetan Bhagat
  • 542
  • 4
  • 19
fastcodejava
  • 35,219
  • 24
  • 124
  • 181
  • 2
    Yes, I often use this one. However, when the editor proposes multiples views (for example when you work on a `XML` or `properties` file), it switches between the different views, and you are not able to switch between tabs anymore :( – Romain Linsolas Feb 25 '10 at 08:12
  • "CTRL + F6 is good to use." Does nothing here, on Eclipse Photon in Windows. – ChrisJJ Nov 04 '18 at 13:40
12

The default is Ctrl + F6. You can change it by going to Window preferences. I usually change it to Ctrl + Tab, the same we use in switching tabs in a browser and other stuff.

Chandrayya G K
  • 8,504
  • 4
  • 35
  • 65
asgs
  • 3,718
  • 6
  • 36
  • 49
  • I'm not a down-voter, but I question your ability to map a key binding with Ctrl + Tab together on Windows Vista, using Eclipse Indigo. It's impossble! If I were to press Tab, it would simply change the focus on the buttons and drop-down list. – tom_mai78101 Sep 07 '12 at 14:16
  • @tom_mai78101 Sorry, I'm not aware of this issue with Windows Vista. You can try a different mapping of your choice, though it's successful in XP. – asgs Sep 07 '12 at 15:55
6

Custom KeyBinding sequence example : CTRL + TAB to switch between visilble Modules or Editors Forward direction using Eclipse RCP.

you press CTRL + TAB second time to open another editor and close previous editor using RCP Eclipse.

package rcp_demo.Toolbar;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;

public class Forward_Editor extends AbstractHandler{

    static String Editor_name;  //  Active Editor name store in Temporary 
    static int cnt;             //  close editor count this variable
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
        IWorkbenchPage page = window.getActivePage();

        UserEditorInput std_input = new UserEditorInput();
        EmployeeEditorInput emp_input=new EmployeeEditorInput();
        ProductEditorInput product_input=new ProductEditorInput();

        IEditorReference[] editors = page.getEditorReferences();

        //Blank Editor Window to execute..
        if(editors.length==0)
        {
            //First time close editor can open Student_Editor
            if(cnt==1 && Editor_name.equals("Student_Editor"))
            {
                try {
                    page.openEditor(emp_input, EmployeeEditor.Id);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }       
            }
            //First time close editor can open Employee_Editor
            else if(cnt==1 && Editor_name.equals("Employee_Editor"))
            {
                try {
                    page.openEditor(product_input,ProductEditor.ID);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name); 
                } catch (PartInitException e) {e.printStackTrace();
                }
            }
            //First time close editor can open Product_Editor
            else if(cnt==1 && Editor_name.equals("Product_Editor"))
            {
                try {
                    page.openEditor(std_input, UserEditor.ID);
                    System.out.println("student Editor open");
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("Close::"+Editor_name);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
            //First Time call // empty editors 
            else{
                try {
                    page.openEditor(std_input, UserEditor.ID);
                    System.out.println("student Editor open");
                    Editor_name=page.getActiveEditor().getTitle();
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
        }//End if condition

        //AvtiveEditor(Student_Editor) close to open Employee Editor
        else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
        {
            try {
                //page.closeAllEditors(true);
                page.closeEditor(page.getActiveEditor(), true);
                page.openEditor(emp_input, EmployeeEditor.Id);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Employee_Editor) close to open Product Editor
        else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
        {
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);

                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);

            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Product_Editor) close to open Student Editor
        else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
        {
            try {
                page.closeAllEditors(true);
                page.openEditor(std_input, UserEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("stud>>Len:: "+editors.length+"..EDi::"+Editor_name);
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        //by default open Student Editor
        else 
        {
            try {
                page.closeAllEditors(true);
                page.openEditor(std_input, UserEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("stud_else>>Len:: "+editors.length+"..EDi::"+Editor_name);
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

>Custom KeyBinding sequence example : <kbd> SHIFT + TAB </kbd> to switch between visilble Modules or Editors **Backword** direction using Eclipse RCP.


package rcp_demo.Toolbar;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;

public class Backword_Editor extends AbstractHandler{

    static String Editor_name;   // Active Editor name store in Temporary 
    static int cnt;

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
        IWorkbenchPage page = window.getActivePage();
        //Three object create in EditorInput 
        UserEditorInput std_input = new UserEditorInput();
        EmployeeEditorInput emp_input=new EmployeeEditorInput();
        ProductEditorInput product_input=new ProductEditorInput();

        IEditorReference[] editors = page.getEditorReferences();
        System.out.println("Length : "+editors.length);

        if(editors.length==0)
        {
            //First time close editor can open Student_Editor
            if(cnt==1 && Editor_name.equals("Product_Editor"))
            {
                try {
                    page.openEditor(emp_input, EmployeeEditor.Id);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }               
            }
            //First time close editor can open Employee_Editor
            else if(cnt==1 && Editor_name.equals("Employee_Editor"))
            {
                try {
                    page.openEditor(std_input, UserEditor.ID);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("Student>>Len:: "+editors.length+"..student::"+Editor_name);

                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
            //First time close editor can open Product_Editor
            else if(cnt==1 && Editor_name.equals("Student_Editor"))
            {
                        try {
                            page.openEditor(product_input,ProductEditor.ID);
                            cnt=1;
                            Editor_name=page.getActiveEditor().getTitle();
                            System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);

                        } catch (PartInitException e) {
                            e.printStackTrace();
                        }
            } 
            //First Time or empty editors to check this condition
            else{
                try {
                    page.openEditor(product_input,ProductEditor.ID);
                    System.out.println("product Editor open");
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
        }
        //AvtiveEditor(Product_Editor) close to open Employee Editor
        else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
        {
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(emp_input, EmployeeEditor.Id);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("Employee Editor open");
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Employee_Editor) close to open Student Editor
        else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
        {
            System.out.println("Emp:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(std_input, UserEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("student Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Student_Editor) close to open Product Editor
        else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
        {
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //by default open Student Editor
        else 
        {
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
}

Custom KeyBinding sequence example : SHIFT + TAB to switch between visilble Modules or Editors Backword direction using Eclipse RCP.

package rcp_demo.Toolbar;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;

public class Backword_Editor extends AbstractHandler{

    static String Editor_name;   // Active Editor name store in Temporary 
    static int cnt;

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
        IWorkbenchPage page = window.getActivePage();
        //Three object create in EditorInput 
        UserEditorInput std_input = new UserEditorInput();
        EmployeeEditorInput emp_input=new EmployeeEditorInput();
        ProductEditorInput product_input=new ProductEditorInput();

        IEditorReference[] editors = page.getEditorReferences();
        System.out.println("Length : "+editors.length);

        if(editors.length==0)
        {
            //First time close editor can open Student_Editor
            if(cnt==1 && Editor_name.equals("Product_Editor"))
            {
                try {
                    page.openEditor(emp_input, EmployeeEditor.Id);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }               
            }
            //First time close editor can open Employee_Editor
            else if(cnt==1 && Editor_name.equals("Employee_Editor"))
            {
                try {
                    page.openEditor(std_input, UserEditor.ID);
                    cnt=1;
                    Editor_name=page.getActiveEditor().getTitle();
                    System.out.println("Student>>Len:: "+editors.length+"..student::"+Editor_name);

                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
            //First time close editor can open Product_Editor
            else if(cnt==1 && Editor_name.equals("Student_Editor"))
            {
                        try {
                            page.openEditor(product_input,ProductEditor.ID);
                            cnt=1;
                            Editor_name=page.getActiveEditor().getTitle();
                            System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);

                        } catch (PartInitException e) {
                            e.printStackTrace();
                        }
            } 
            //First Time or empty editors to check this condition
            else{
                try {
                    page.openEditor(product_input,ProductEditor.ID);
                    System.out.println("product Editor open");
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
        }
        //AvtiveEditor(Product_Editor) close to open Employee Editor
        else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
        {
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(emp_input, EmployeeEditor.Id);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("Employee Editor open");
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Employee_Editor) close to open Student Editor
        else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
        {
            System.out.println("Emp:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(std_input, UserEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("student Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //AvtiveEditor(Student_Editor) close to open Product Editor
        else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
        {
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //by default open Student Editor
        else 
        {
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                cnt=1;
                Editor_name=page.getActiveEditor().getTitle();
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
}

Key Sequence

M1 means CTRL

M2 means SHIFT

plugin.xml


<extension point="org.eclipse.ui.commands">
        <command
                defaultHandler="rcp_demo.Toolbar.Forward_Editor"
                id="RCP_Demo.Toolbar.Forward_editor_open_cmd"
                name="Forward_Editor">
        </command>
        <command
                defaultHandler="rcp_demo.Toolbar.Backword_Editor"
                id="RCP_Demo.Toolbar.backwards_editor_open_cmd"
                name="Backword_Editor">
        </command>
    </extension>
<extension point="org.eclipse.ui.bindings">
        <key
                commandId="RCP_Demo.Toolbar.Forward_editor_open_cmd"
                schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
                sequence="M1+TAB">
        </key>  
        <key
                commandId="RCP_Demo.Toolbar.backwards_editor_open_cmd"
                schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
                sequence="M2+TAB">
        </key>              
</extension>
Chetan Bhagat
  • 542
  • 4
  • 19
5

3 line AutoHotKey script (on Windows, anyway):

#IfWinActive ahk_class SWT_Window0
^+Tab::^PgUp
^Tab::^PgDn

Put this in your startup folder (save it as *.ahk, must have AutoHotKey installed) and Eclipse tabs will now work like Chrome or Firefox.

Zook
  • 497
  • 8
  • 20
3

Solved!!

Change Scheme to Microsoft Visual Studio

Window>Preferences>General>Keys

Look for Schemes dropdown

My eclipse version:

Eclipse Java EE IDE for Web Developers.

Version: Juno Service Release 1 Build id: 20120920-0800

sumitarora
  • 570
  • 4
  • 17
3

Nobody will ever read my answer, but anyway... If you are on Mac OS X you will love multi touch gestures for history navigation in Eclipse: http://sourceforge.net/apps/mediawiki/eclipsemultitch/

borisdiakur
  • 8,405
  • 7
  • 58
  • 92
  • 1
    I read *all* entries [every single day](http://meta.stackexchange.com/q/122976/6309) ;) And "Eclipse Multi-Touch" looks nice, so +1. But it seems inactive since 2010. Would it still work with recent Eclipse 4.x like Juno? – VonC Jul 13 '13 at 06:31
3

Shortcut key to back to the previous tab

Alt + LeftArrow to go back.

Sunil Garg
  • 10,122
  • 12
  • 92
  • 133
2

On windows if you have a 5 button mouse, you can use forward and back in lieu of ALT+Left and ALT+Right.

ajon
  • 6,725
  • 10
  • 43
  • 81
1

For some reason my Eclipse settings were corrupted so I had to manually edit the file /.plugins/org.eclipse.e4.workbench/workbench.xmi

I must have previously set Ctrl+Tab to Browser-like tab switching, and even resetting all key bindings in Eclipse preferences wouldn't get rid of the shortcuts (they were not displayed anywhere either). I opened the above mentioned file and removed the <bindings> elements marked with <tags>type:user</tags> related to the non-functioning shortcuts.

Chetan Bhagat
  • 542
  • 4
  • 19
friederbluemle
  • 22,961
  • 11
  • 88
  • 92
1

You can set the hotkeys in Preferences -> General -> Keys (or just type "keys" into the filter field at the top of the Preferences dialog.

Once the Keys section is selected, find Next Tab and Previous Tab and assign them your own hotkey by clicking in the "Binding" field and then typing your hotkeys.

Hit Apply or OK to finish the process.

grigb
  • 1,061
  • 8
  • 14
1

One way to do it is to use the VI Plugin, and then you just do :n (and :N) to go between files.

That's what I do.

Ajmal M A
  • 1,506
  • 20
  • 43
CPerkins
  • 8,729
  • 3
  • 31
  • 46
1

I quote VonC response, adding something.

  • Ctrl+PgUp(PgDn) to switch between tabs in the current stack (both editors and view)
  • Ctrl+E to switch between tabs in the current stack, using a filtered list
  • Ctrl+F6 to switch between editors, no matter which stack
  • Ctrl+F7 to switch between views, no matter which stack

Plus, there is Bug 206299 open to request using Ctrl+Tab for switching tabs instead of Ctrl+PgUp(PgDn).

  • As this would break accessibility, the user should set a preference for this. Perhaps there should be a question in the Welcome Questionnaire during to the Oomph installs.

If not satisfied, you can assign yourself the Key Binding, from Window > Preferences > General > Keys.

psuzzi
  • 1,709
  • 1
  • 16
  • 18
1

If you want to simply switch between your current and your previous tab selections, using CTRL + F6 will switch you back and forth. To navigate to a tab further back in your history, you need to use the UP / DOWN keys while the Editors window is open. This works with Helios (Eclipse 3.6); not sure if this is true for older versions of Eclipse.

Chandrayya G K
  • 8,504
  • 4
  • 35
  • 65
1

Right to left : ctrl+ shift + 9 or ctrl + shift + Page Up or ctrl + Page Up

Left to right : ctrl + shift + 3 or ctrl + shift + Page Down or ctrl + Page Down

Mwiza
  • 4,494
  • 2
  • 33
  • 30
Parth Patel
  • 639
  • 1
  • 10
  • 20
0

Hold CTRL and press F6 until you reached the editor you want, then release. The UI is not as pretty as the window selection, but the functionality is the same.

Chandrayya G K
  • 8,504
  • 4
  • 35
  • 65
Christopher Oezbek
  • 17,629
  • 3
  • 48
  • 71
0

On a SLES12 machine you can use Ctrl+PageUp and Ctrl+PageDown to navigate between tabs by default. You can always change these keys from Preferences window by browsing through "keys" section under "General" category. This process is well explained by Victor and VonC above.

Chetan Bhagat
  • 542
  • 4
  • 19
0

How can I switch between opened windows in Eclipse

CTRL+F7 works here - Eclipse Photon on Windows.

ChrisJJ
  • 1,904
  • 1
  • 24
  • 34