Eclipse:获取当前文件的位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1711012/
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:00:18  来源:igfitidea点击:

Eclipse: Get location of the current file?

eclipse

提问by David Wolever

If I've got a file open in Eclipse, how can I figure out where it is on the filesystem?

如果我在 Eclipse 中打开了一个文件,我如何确定它在文件系统上的位置?

For example, in Vim I would use :pwd.

例如,在 Vim 中我会使用:pwd.

回答by Alexandre Pauzies

Use the Eclipse menu:

使用 Eclipse 菜单:

File->Properties

文件->属性

or the shortcut:

或快捷方式:

Alt-Enter

Alt-Enter

You should be able to see the Location associated with the Resource

您应该能够看到与资源关联的位置

回答by tangens

Just hit Alt-Enter.

只需按 Alt-Enter。

回答by CT Liv

The other solution ("File-->Properties" or "Alt+Enter") didn't work for me.

另一个解决方案(“文件--> 属性”或“Alt+Enter”)对我不起作用。

I use:

我用:

  • Right Click (in current editor) --> Show In (shortcut: Alt+Shift+W) --> Project Explorer
  • 右键单击(在当前编辑器中)--> 显示在(快捷键:Alt+Shift+W)--> 项目资源管理器

This shows in Project Explorer the location of the file. If the file is a class in a referenced library, the dependency tree is automatically opened.

这会在项目资源管理器中显示文件的位置。如果文件是引用库中的类,则依赖树会自动打开。

回答by Topher Fangio

Eclipse also has the ability to link the explorer view with the current file, so that whenever you change a file, it is expanded and selected in the explorer view.

Eclipse 还能够将资源管理器视图与当前文件链接起来,这样无论何时更改文件,它都会在资源管理器视图中展开并被选中。

Just look for the following image at the top of the view: alt text

只需在视图顶部查找以下图像: 替代文字

回答by Grundlefleck

What you're looking for is the 'Properties' dialogue for the current file. This can be activated in two ways:

您正在寻找的是当前文件的“属性”对话框。这可以通过两种方式激活:

  • Selecting from the menu: File -> Properties
  • Using the shortcut: Alt + Enter
  • 从菜单中选择:文件 -> 属性
  • 使用快捷键:Alt + Enter

This gives you a dialogue which contains both the full path of the document, as well as the relative path from the workspace root.

这为您提供了一个对话框,其中包含文档的完整路径以及工作空间根目录的相对路径。

The dialogue can be quite handy: it allows you to highlight and copy the file path.

对话非常方便:它允许您突出显示和复制文件路径。

回答by mr.maga

Linking to Project Explorer won't work if you have many files - it will select the right file in the list, but it won't "scroll" to that portion so it is visible.

如果您有很多文件,链接到 Project Explorer 将不起作用 - 它会在列表中选择正确的文件,但不会“滚动”到该部分,因此它是可见的。

You'd have to manual scroll the Project Explorer view to see where the file is. It could also be nested so deeply that the full location will be obscured by truncation.

您必须手动滚动 Project Explorer 视图以查看文件所在的位置。它也可能嵌套得太深,以至于整个位置将被截断所掩盖。

Another way to quickly (keyboard-free) see the path is to hover over the file type icon (on top of the open editor window).

另一种快速(无键盘)查看路径的方法是将鼠标悬停在文件类型图标上(在打开的编辑器窗口的顶部)。