Eclipse:在两个编辑器中打开同一个文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2058784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:06:31  来源:igfitidea点击:

Eclipse: have the same file open in two editors?

eclipse

提问by David Wolever

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?

有没有办法用 Eclipse 做到这一点?

回答by YuppieNetworking

Open your file and then Window->New Editor(Note: in newer versions it will be called New Window)

打开您的文件,然后Window-> New Editor(注意:在较新的版本中,它将被称为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.

更新:正如 moschlar 所提到的,从 4.4 版开始,可以使用Window-> Editor->创建两个编辑器Clone

回答by moschlar

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

在 Eclipse Luna (4.4) 及更高版本中,这是开箱即用的支持:Window -> Editor -> Clone.

回答by Knyri

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 Editorwill split the editor horizontally or vertically.
Ctrl + _is horizontal and Ctrl + {is vertical. More precisely it's Ctrl + Shift + -and Ctrl + Shift + [.

Window -> Editor -> Toggle Split Editor将水平或垂直拆分编辑器。
Ctrl + _是水平的,Ctrl + {也是垂直的。更准确地说,它是Ctrl + Shift + -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.

Mars 注意:拆分编辑器似乎有点问题。JavaScript 编辑器喜欢在执行 while-you-type-validation 时将光标立即跳转到另一个窗格。

回答by Seth

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.

...除非您有较新版本的 eclipse,在这种情况下,请执行 Window -> New Editor。

回答by Rex the Strange

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

Window -> Editor -> Clone 在 Neon 2 中也可用,从其他评论来看似乎在所有较新的 Eclipse 中都可用。

It's my preferred solution.

这是我首选的解决方案。

回答by alveomaster

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)

为了使答案保持最新,我强调使用 Eclipse STS 执行此操作是使用 window -> Editor -> Toggle split editor (horizental) | Toggle split editor (vertical)

回答by william.eyidi

In Eclipse Marsthere is another way of doing it:

在 Eclipse Mars 中有另一种方法:

Window -> Editor -> Clone.

Window -> Editor -> Clone.

then drag the cloned tab to the corner to create a parallel window.

然后将克隆的选项卡拖到角落以创建一个平行窗口。

回答by cgts

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.

这似乎现在在文件-> 新建视图到文件中,它打开带有焦点的选项卡到同一组中的新选项卡中,然后您可以根据需要将其拖到另一个组中。