19

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

enter image description here

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.

Tyler Durden
  • 11,156
  • 9
  • 64
  • 126
  • Try to use the `Navigation Bar`, it is more useful than one migth think. If you click on a package it will list all files in it and you can go directly to the file (not the class...). – maba Oct 17 '13 at 08:32
  • @maba see further explanation above to understand the problem – Tyler Durden Oct 17 '13 at 13:24
  • I did understand the problem and the `Navigation Bar` is giving you access to files rather than classes... – maba Oct 17 '13 at 13:27
  • @maba I see, the actual Navigation Bar as opposed to the Navigation Pane. The problem with using just the bar is that it requires even more clicks than using the pane does. For example, if the class is nested 10 folders deep I might have to click 10 times before I can even see the file to click on it. – Tyler Durden Oct 17 '13 at 19:23
  • I have the same problem (feature). – Marcos Dec 10 '13 at 17:34
  • What version of IntelliJ are you using? Do you still have this problem? – mkobit Nov 19 '14 at 09:14
  • @MikeKobit I am using 13.1.4. Yes, the same problem exists. When you double click on a class that has multiple classes, it expands the class list, rather than opening the file. – Tyler Durden Nov 19 '14 at 23:25
  • This is also an issue for Scala. You also cannot copy a file that has multiple classes (or in the case of Scala, an associated Object) into the same folder because it doesn't let you specify the file name and then fails because the file already exists. Very annoying that Windows Explorer can do a better job because it's dumber than IntelliJ. – Kat Dec 02 '14 at 22:45
  • I've opened a feature request for the issue: https://youtrack.jetbrains.com/issue/IDEA-148825 – Eyal Roth Dec 02 '15 at 19:15

5 Answers5

3

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)

IntelliJ 14 project window config menu

Peter
  • 620
  • 6
  • 13
  • On my machine what Autoscroll to Source does is open the class source file when you SINGLE click on the class name, not double click it. – Tyler Durden Nov 19 '14 at 23:28
  • This is a step in the right direction, but does make the behaviour a bit weird unfortunately. It also seems to open up regular classes on single click too. – Seer Sep 14 '15 at 19:26
  • This is not a solution at all. It has a pretty nasty side effect... opening each and every file you hover over in the Project View. If you want that, sure, go for it, but this is not what was asked in the question. – Eyal Roth Dec 02 '15 at 18:00
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..

1

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.

Jump to source

Ilya Klyuchnikov
  • 3,149
  • 3
  • 18
  • 9
  • 1
    If you read the question, it says I am looking for a way to configure it so I can double click to open the file and not have to press F4 – Tyler Durden Jun 19 '14 at 22:11
  • is different; it will only "show source" (the focus will remain on the Project View, not the Editor). The "jump to source" is probably the best option, but the problem is that this binding is shared between the Editor and the Project View. I would expect to trigger this in the Project View, and to trigger it in the Editor (since has a totally different use in the Editor). – Eyal Roth Dec 02 '15 at 17:56
0

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

-1

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!!

Jet
  • 3,018
  • 4
  • 33
  • 48