How to navigate to parent folder of current file in Project Explorer view using keyboard shortcut in Eclipse IDE?

╄→гoц情女王★ 提交于 2020-03-02 14:19:30

问题


In Eclipse IDE, having a current file opened in editor, and having Project Explorer view linked to editor.

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.

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


回答1:


Finally, I found the answer! I combined answers from this post, restarted GNOME shell, restarted eclipse and it worked:

Edit ~/.config/gtk-3.0/gtk.css (create if doesn't exist):

@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.

Applying this solution will add the following functionality:

  • SHIFT + : Go to parent.
  • : collapse current item.
  • : expand current item.

I came up with the steps of restarting GNOME shell and eclipse. Not sure if just changing the configurations would do the trick right away or not. Haven't tried it :D

I'm using GNU/Linux Ubuntu 18.04.4 LTS.




回答2:


There is a key binding named "show in (project explorer)".(*) Define a key for this in Preferences->General->Keys menu. 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.

(*) If you want to do this in package explorer tree, define a key for "show in (package explorer)". (Rest is the same)



来源:https://stackoverflow.com/questions/53557348/how-to-navigate-to-parent-folder-of-current-file-in-project-explorer-view-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!