如何在 Eclipse 中打开的窗口之间切换?有Ctrl+ F6,但它问我想要哪一个,但我想像浏览器中的选项卡或操作系统(Cmd/ Win+ Tab)中的窗口一样切换它,而无需从列表中选择文件。如何在 Eclipse 中做这个简单的事情?
我试图为事件分配热键:
- 向前
- 前进历史
- 下一页
但它不按我想要的方式工作。
是两个官方快捷方式,但它们都涉及正在显示的列表。
CTRL+ Page Up/ CTRL+Page Down可以在不显示列表的情况下循环编辑器。
最后一组快捷键的有趣之处在于:
它们没有列在要定义的 Eclipse Keys 快捷键中。
它们可以从多页编辑器继承,使它们成为特定于操作系统的快捷方式。
关于 Mac OS (OSX) 上的快捷方式,Matt Ball在 2011 年 9 月抱怨无法重新映射CTRL+ Page Up/ CTRL+ Page Down:
它让我发疯,无法像在 OS X 中几乎所有其他选项卡式程序中那样翻阅打开的选项卡(⌘</kbd>-Left and ⌘</kbd>-Right).
嗯,在 2012 年 3 月,亚瑟回答说:
, 我刚刚下载了最新版本的 Eclipse (3.7+)。我已经能够将“上一个/下一个选项卡”绑定到(⌘</kbd>-Left and ⌘</kbd>-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.
马特·鲍尔证实:
哇哦,选择“Editing Java Source”真的有效!
现在,不幸的是,这意味着如果我导航到非 Java 文件(JSP、XML、JS 等),我就是 SOL。
解决方法是为这对“复制命令”,然后选择我想要的所有“时间”。
到目前为止,它至少可以很好地处理 Java 和 JSP 文件。
这是一个主要的 PITA 设置,但这只是一次性的事情。
他导出的首选项可在此处供您尝试。
导入后,您应该会看到所有相关类型的文档:
如果您转到首选项(例如窗口→首选项)并查看常规→键
然后搜索“下一个选项卡”和“上一个选项卡”,您可以重新映射它们。
CTRL-F6在 Eclipse 中,就像ALT-TAB(在 windows 上)一样,会显示可用选项卡/窗口的列表(如果您按住CTRL/ALT键)并突出显示当您松开此键时您将跳转到的那个。您不必选择窗口。如果要一次遍历多个选项卡,请按住CTRL按钮并点击TAB按钮。ALT这与-TAB在 Windows 上的行为相同。
从这个意义上说,CTRL--SHIFTF6在eclipse中是ALT--SHIFTTAB模拟的。就个人而言,我将 Eclipse 中的这些绑定更改为类似于 Visual Studio。即CTRL-TAB和CTRL-SHIFTTAB我这样做:
窗口>首选项>常规>键
然后设置“下一个编辑器”= Ctrl+Tab和“上一个编辑器”= Ctrl+ Shift+Tab。在设置新绑定之前不要忘记单击“取消绑定命令”。
这是CTRL-PageDown向右走,CTRL-PageUp向左走。令人沮丧的是,当您到达选项卡列表的末尾(比如最右边的选项卡)然后尝试再次向右移动时,Eclipse 不会像大多数浏览器那样循环到第一个选项卡(最左边)。
您可以使用ALT+Left转到上一个选项卡,或使用ALT+Right转到前进。但是,此方法使用类似于历史记录的选项卡切换,因此它将转到您打开的上一个选项卡,如果您“返回”一次或多次,则前进。有点奇怪,我知道,但它有效。您始终可以通过单击每个选项卡一次来“重置”历史记录。
Right
侧移:Ctrl+page DownLeft
侧移:CTRL+page Up额外的
Eclipse 其他快捷方式
CTRL+F6很好用。如果要切换到下一个/上一个选项卡,则需要执行CTRL+ Page Down/ CTRL+ Page Up。
默认值为Ctrl+ F6。您可以通过转到Window 首选项来更改它。我通常将其更改为Ctrl+ Tab,就像我们在浏览器和其他东西中切换选项卡时使用的一样。
自定义 KeyBinding 序列示例:使用 Eclipse RCP在 CTRL + TAB 可见模块或编辑器之间切换。
您按CTRL + TAB 第二次打开另一个编辑器并使用 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;
}
}
自定义 KeyBinding 序列示例:使用 Eclipse RCP SHIFT + TAB 在可见模块或编辑器Backword方向之间切换。
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;
}
}
键序列
M1 表示 CTRL
M2 表示SHIFT
插件.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>
3 行 AutoHotKey 脚本(在 Windows 上,无论如何):
#IfWinActive ahk_class SWT_Window0
^+Tab::^PgUp
^Tab::^PgDn
把它放在你的启动文件夹中(保存为 *.ahk,必须安装 AutoHotKey),Eclipse 选项卡现在将像 Chrome 或 Firefox 一样工作。
返回上一个选项卡的快捷键
Alt+LeftArrow返回。
没有人会读到我的答案,但无论如何......如果你在 Mac OS X 上,你会喜欢在 Eclipse 中使用多点触控手势进行历史导航:http: //sourceforge.net/apps/mediawiki/eclipsemultitch/
解决了!!
将方案更改为 Microsoft Visual Studio
窗口>首选项>常规>键
查找方案下拉菜单
我的日食版本:
面向 Web 开发人员的 Eclipse Java EE IDE。
版本:Juno Service Release 1 内部版本 ID:20120920-0800
在 Windows 上,如果你有一个 5 键鼠标,你可以使用 forward 和 back 来代替ALT+Leftand ALT+Right。
如果您只想在当前和以前的选项卡选择之间切换,使用CTRL+F6将来回切换。要导航到历史记录中更早的选项卡,您需要在编辑器窗口打开时使用UP/键。DOWN这适用于 Helios (Eclipse 3.6);不确定这是否适用于旧版本的 Eclipse。
一种方法是使用VI Plugin,然后您只需执行 :n (和 :N)即可在文件之间切换。
我就是做这个的。
您可以在 Preferences -> General -> Keys 中设置热键(或者只需在 Preferences 对话框顶部的过滤器字段中输入“keys”。
选择“键”部分后,找到“下一个选项卡”和“上一个选项卡”并通过单击“绑定”字段然后键入您的热键为它们分配您自己的热键。
点击应用或确定以完成该过程。
由于某种原因,我的 Eclipse 设置已损坏,因此我不得不手动编辑文件/.plugins/org.eclipse.e4.workbench/workbench.xmi
我以前必须将Ctrl+设置Tab为类似浏览器的选项卡切换,甚至在 Eclipse 首选项中重置所有键绑定都不会摆脱快捷方式(它们也没有显示在任何地方)。我打开了上述文件并删除了<bindings>
标记为<tags>type:user</tags>
与无效快捷方式相关的元素。
我引用 VonC 的回应,添加一些内容。
此外,还有一个错误 206299可供请求使用Ctrl+Tab来切换选项卡,而不是Ctrl+ PgUp( PgDn)。
如果不满意,您可以从Window > Preferences > General > Keys为自己分配 Key Binding 。
从右到左:ctrl+ shift+9 或 ctrl+ shift+Page Up或ctrl+Page Up
从左到右:ctrl+ shift+3或ctrl+ shift+Page Down或ctrl+Page Down
按住CTRL并按住F6直到你到达你想要的编辑器,然后释放。UI 不像窗口选择那么漂亮,但功能是一样的。
在 SLES12 机器上,默认情况下您可以使用Ctrl+PageUp和Ctrl+PageDown在选项卡之间导航。您始终可以通过浏览“常规”类别下的“键”部分从“首选项”窗口更改这些键。上面的 Victor 和 VonC 很好地解释了这个过程。
如何在 Eclipse 中打开的窗口之间切换
CTRL+F7 在这里工作 - Windows 上的 Eclipse Photon。