Intellij project view: not show multiple classes i

2019-03-23 09:12发布

问题:

One frustrating thing I find in Intellij's project view is that it shows all the classes in a file instead of just the class for which the file is named.

The problem with this is that to open a file I have to double click twice: once to expand the file and show the classes in the file, and then a second time to actually open the file.

In most cases I don't want to see the classes inside of a file. I just want to see the file in the project view and when I double click on the file I want to open the file, not drill down into its structure.

Is it possible to configure my UI this way?

UPDATE: further explanation

Apparently people are having problems understanding this question. See the above picture of the Intellij Project navigation pane. Notice that some classes (the blue circles) have a + sign and others do not. The ones with a plus sign are files that have multiple classes inside of them.

The problem is that if you double click on a file with only one class (no plus sign) it opens (GOOD), but if you double click on a file with multiple classes in it (has plus sign) then the file does NOT open, it just expands the plus sign to show you the individual classes in the file as BoxArray.java, for example (BAD).

For example, if I double click on the file Coastline.java in the view above it will NOT open the file, it will expand the plus sign. I want it to open Coastline.java when I double click on Coastline.java, not expand it. I do not care about seeing the classes inside of a class file, I just want to open it in one double click.

I know that I can use the hotkey F4 to do this. I do not want to reach for the F4 key. I want to double click on the file and have it open.

回答1:

When you enable Autoscroll to Source in the little menu of your Project tool window (View > Tool Windows > Project), single clicking a collection (closed and opened) goes straight to the code as well as folding / unfolding it.

This works in IntelliJ 13.1 and 14 (in OSX and Linux)



回答2:

You could bind Jump to Source function to double click in Settings -> Keymap -> search for "Jump to Source" -> RMB click and choose "Add Mouse Shortcut". Now double clicking on file will open it. Drawback could be that from now if you double click on some code to select it you will always go to source..



回答3:

There is a way to open a file without unfolding/drill down via "jump to source" action. Unfortunately, you need a keyboard to do this. On Mac you use F4/⌘↓/⌘Enter, on linux/windows it is F4/Ctrl+Enter.



回答4:

go to file -> settings -> Editor -> General -> editor tabs in tab closeing policy and set tab limit and set it to what number you want.



回答5:

You can avoid navigating through mouse and even double clicking on the file by making use of the shortcut ctrl + shift + n and just start typing the file name or even just first letters of the words( ex: BA for BoxArray) and select the file. Which will open without asking the class name!!