如何在 Eclipse 中显示当前函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1514779/
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
How to Display Current Function in Eclipse
提问by Pascal Thivent
I miss a certain functionality in Eclipse. I would like to know the name of the current function the cursor is currently inside. This is useful when browsing unknown code using the search function, for example.
我想念 Eclipse 中的某些功能。我想知道光标当前所在的当前函数的名称。例如,这在使用搜索功能浏览未知代码时非常有用。
Any idea how to show it? Maybe a plugin?
知道如何展示它吗?也许是一个插件?
回答by antoni.rasul
I'm using the "Toggle Breadcrumb" option from toolbar:
我正在使用工具栏中的“切换面包屑”选项:
It shows a nice breadcrumb, ending with current function name.
它显示了一个不错的面包屑,以当前函数名称结尾。
It's quite handy for me, as Outline becomes cumbersome to use if you have zilions of functions.
这对我来说非常方便,因为如果您拥有无数功能,那么 Outline 使用起来会很麻烦。
It produces the following structure above your Java Editor (truncated at the picture below):
它在 Java 编辑器上方生成以下结构(在下图中被截断):
回答by Pascal Thivent
The "Outline" view shows the current function.
“大纲”视图显示当前功能。
It may be necessary to enable the 'Link to Editor' option in the Outline View dropdown menu. This might be off by default for CDT.
可能需要在大纲视图下拉菜单中启用“链接到编辑器”选项。对于 CDT,这可能默认关闭。
回答by cornelius
I was looking for something similar (Xcode-like bar at the top showing the current function, where you can also go to another function by clicking on it to open a popup list of functions). Here is what I settled on with Eclipse 3.5.1 CDT:
我正在寻找类似的东西(顶部的类似 Xcode 的栏显示当前功能,您还可以通过单击它打开功能的弹出列表来转到另一个功能)。这是我使用 Eclipse 3.5.1 CDT 确定的内容:
I moved the Outlineview to the top, resized it to make it a 1-line horizontal strip (don't make it too narrow), and selected "Link With Editor" in its menu, so that it always shows the current function. However, this doesn't open a popup list like Xcode. For that functionality, I assigned a shortcut to the "Show Outline" command which does open a popup list of all functions.
我将Outline视图移到顶部,调整其大小以使其成为 1 行水平条(不要使其太窄),并在其菜单中选择“ Link With Editor”,以便它始终显示当前功能。但是,这不会像 Xcode 那样打开弹出列表。对于该功能,我为“显示大纲”命令分配了一个快捷方式,该命令会打开所有功能的弹出列表。
回答by dls
The Eclipse function 'show outline' will pop up a list of outline objects, and it will highlight the object your cursor is inside in grey. It's typically bound to 'ctrl-o' (the letter 'o', not zero), but you can re-bind it as you see fit. I'm running Eclipse with the CDT plugin and it works pretty well for me.
Eclipse 功能“显示大纲”将弹出一个大纲对象列表,并以灰色突出显示光标所在的对象。它通常绑定到“ctrl-o”(字母“o”,不是零),但您可以根据需要重新绑定它。我正在使用 CDT 插件运行 Eclipse,它对我来说效果很好。
回答by pradipgarala
To enable the breadcrumb invoke Toggle Java Editor Breadcrumb in the toolbar or press Alt+Shift+Bin the Java editor.
要启用面包屑,请在工具栏中调用 Toggle Java Editor Breadcrumb 或在 Java 编辑器中按Alt+ Shift+ B。
回答by AKludges
You can also display the Quick Outline (ctrl+o). This way you see the context quickly without having to have a permanent Outline Window linked to the Editor.
您还可以显示快速大纲 (ctrl+o)。通过这种方式,您可以快速查看上下文,而无需将永久大纲窗口链接到编辑器。
回答by Sree Rama
Press Ctrl+o (cursor is currently inside a function at a particular line).
按 Ctrl+o(光标当前位于特定行的函数内)。
It highlights the current method, or name of the class if the cursor is outside the method body. You can click on highlighted method.
如果光标位于方法主体之外,它会突出显示当前方法或类的名称。您可以单击突出显示的方法。
It has got inline search feature ...start typing name of the method to navigate to the specified method or method with matching search pattern.
它具有内联搜索功能...开始输入方法的名称以导航到具有匹配搜索模式的指定方法或方法。
If you press again Ctrl+o to shows the inherited members/methods.
如果再次按 Ctrl+o 以显示继承的成员/方法。
回答by Nir
Use the "Link With Editor" option on the outline menu
使用大纲菜单上的“与编辑器链接”选项
回答by Olgun
Using outline with "link with editor" option worked also for me, thanks! Just an addition, you can move outline pane in to the same window group as search, progress etc. saves the space in your perspective instead of keeping it at another group.
使用带有“与编辑器链接”选项的大纲也对我有用,谢谢!补充一点,您可以将大纲窗格移动到与搜索、进度等相同的窗口组中。这样可以节省透视图中的空间,而不是将其保留在另一个组中。