简体   繁体   English

如何使用 Eclipse IDE 中的键盘快捷键导航到 Project Explorer 视图中当前文件的父文件夹?

[英]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:应用此解决方案将添加以下功能:

  • SHIFT + : Go to parent. SHIFT + :转到父级。
  • : collapse current item. : 折叠当前项目。
  • : expand current item. : 展开当前项目。

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.

相关问题 如何使用键盘快捷键在Eclipse Project Explorer视图中查找当前文件? - How to locate current file in Eclipse Project Explorer view using keyboard shortcut? 如何在Eclipse IDE中打开不在项目浏览器中的文件的文件夹? - How to open folder of a file not in the project explorer in Eclipse IDE? Eclipse:如何使用键盘快捷键快速打开文件夹(在软件包,项目或资源管理器中)? - Eclipse: How do I quickly open a folder (in the package, project or resource explorer) with a keyboard shortcut? Eclipse Scala IDE 4.1.1-如何使用键盘快捷键在解释器中运行装入项目? - Eclipse Scala IDE 4.1.1 - How to run the load project in the interpreter using a keyboard shortcut? 在Eclipse中打开文件资源管理器的键盘快捷键是什么? - What is the keyboard shortcut for opening the file explorer in Eclipse? 需要知道键盘快捷键来导航而不在Eclipse中使用鼠标 - Need to know keyboard shortcut to navigate without using mouse in Eclipse 我们如何更改Eclipse IDE项目浏览器视图的默认标签提供程序以使用自定义标签呈现文件 - How can we change default label provider of eclipse ide's project explorer view to render file with customized label 如何使用键盘快捷键切换Eclipse中视图的可见性? - How to toggle visibility of a view in Eclipse with a keyboard shortcut? 如何使用键盘快捷键在 Eclipse IDE 中运行代码 - How can I run code in Eclipse IDE using keyboard shortcut keys Eclipse键盘快捷键打开当前项目的构建路径? - Eclipse keyboard shortcut to open build path of current project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM