[英]How to navigate to parent folder of current file in Project Explorer view using keyboard shortcut in Eclipse IDE?
INFO: Problem occured on Ubuntu.信息:Ubuntu 上出现问题。
In Eclipse IDE, having a current file opened in editor, and having Project Explorer view linked to editor.在 Eclipse IDE 中,在编辑器中打开当前文件,并将 Project Explorer 视图链接到编辑器。
I would like to navigate back from parent to parent folder in Explorer view, using keyboard only .我想在资源管理器视图中从父文件夹导航回父文件夹,仅使用键盘。 (where each folder may have hundreds of files) (每个文件夹可能有数百个文件)
Alternately, I would like to toggle (close) parent folder of selected file in Explorer view.或者,我想在资源管理器视图中切换(关闭)所选文件的父文件夹。
To demonstrate with a screenshot, here is the start state:为了演示截图,这里是开始状态:
and where I want to go, parent folder selected / or closed.以及我想去的地方,选择/或关闭父文件夹。
Mouse workaround鼠标解决方法
As a workaround, my current workflow is use mouse to scroll up explorer until parent folder, then I close it using - button to its left.作为一种解决方法,我当前的工作流程是使用鼠标向上滚动资源管理器直到父文件夹,然后使用-左侧的按钮将其关闭。
Because of linked with editor mode, Explorer view is scrolled down to current file, which makes parent folder not visible in explorer.由于与编辑器模式链接,资源管理器视图向下滚动到当前文件,这使得父文件夹在资源管理器中不可见。
Having to do this makes the mouse way not very effective.必须这样做会使鼠标方式不是很有效。
Another keyboard workaround另一个键盘解决方法
Navigate approximatively to parent using key PAGE-UP to scroll up, but depending on files count, it is also not effective.使用PAGE-UP键向上滚动大致导航到父级,但根据文件数,它也无效。
Is there an existing keyboard, or a way to do it?是否有现有的键盘,或有办法做到这一点?
Note: using Oxygen.3a Release (4.7.3a) on Ubuntu 18.04.1 LTS注意:在 Ubuntu 18.04.1 LTS 上使用 Oxygen.3a Release (4.7.3a)
Finally, I found the answer!终于,我找到了答案! I combined answers from this post , restarted GNOME shell, restarted eclipse and it worked:我结合了这篇文章的答案,重新启动了 GNOME shell,重新启动了 eclipse 并且它起作用了:
Edit ~/.config/gtk-3.0/gtk.css
(create if doesn't exist):编辑~/.config/gtk-3.0/gtk.css
(如果不存在则创建):
@binding-set MyTreeViewBinding
{
bind "<shift>Left" { "select-cursor-parent" () };
bind "Left" { "expand-collapse-cursor-row" (0,0,0) };
bind "Right" { "expand-collapse-cursor-row" (0,1,0) };
}
treeview
{
-gtk-key-bindings: MyTreeViewBinding;
}
To restart the GNOME shell: hit ALT + F2 .要重新启动 GNOME shell:按ALT + F2 。
Applying this solution will add the following functionality:应用此解决方案将添加以下功能:
I came up with the steps of restarting GNOME shell and eclipse.我想出了重新启动 GNOME shell 和 eclipse 的步骤。 Not sure if just changing the configurations would do the trick right away or not.不确定仅更改配置是否可以立即解决问题。 Haven't tried it :D没试过:D
I'm using GNU/Linux Ubuntu 18.04.4 LTS.我正在使用 GNU/Linux Ubuntu 18.04.4 LTS。
joker's answer worked for me, Thanks joker!小丑的回答对我有用,谢谢小丑! I've tested this in Arch Linux and Eclipse 2022-03.After making changes in gtk.css file, restarting the eclipse applied the changes.我已经在 Arch Linux 和 Eclipse 2022-03 中对此进行了测试。在 gtk.css 文件中进行更改后,重新启动 eclipse 应用了更改。
Instead of using Shift + Left
to go parent node.而不是使用Shift + Left
去父节点。 I've modified it like this.我已经这样修改了。 This way the cursor goes to parent node and collapses the node.这样光标会转到父节点并折叠节点。
@binding-set MyTreeViewBinding
{
bind "Left" {
"select-cursor-parent" ()
"expand-collapse-cursor-row" (0,0,0)
};
bind "Right" { "expand-collapse-cursor-row" (0,1,0) };
}
treeview
{
-gtk-key-bindings: MyTreeViewBinding;
}
There is a key binding named "show in (project explorer)".(*) Define a key for this in Preferences->General->Keys
menu.有一个名为“show in (project explorer)”的键绑定。(*) 在Preferences->General->Keys
菜单中为此定义一个键。 This will select the file you working on in the project explorer.这将选择您在项目资源管理器中处理的文件。 (alternatively you can manually select by mouse) (或者您可以通过鼠标手动选择)
After this You can use left arrow key ( ← ) to go to parent of the currently selected file.在此之后,您可以使用左箭头键 ( ← ) 转到当前选定文件的父级。 Pressing this key again will close the currently selected folder.再次按此键将关闭当前选择的文件夹。 (and pressing again will go up a level in the project explorer tree) (再次按下将在项目浏览器树中上一级)
Ps: Right arrow key ( → ) can be used to open the currently selected folder. Ps:右箭头键( → )可以用来打开当前选中的文件夹。
(*) If you want to do this in package explorer tree, define a key for "show in (package explorer)". (*) 如果您想在包资源管理器树中执行此操作,请为“显示在(包资源管理器)”中定义一个键。 (Rest is the same) (其余相同)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.