How to remove default file type association once it gets added by the unknown file type popup?

Answered

Hello,

I accidentally added an entry to the TEXT default file type association via the unknown file type popup (can't remember what the actual title of the popup was, so will refer to it as this from now on). Now I cannot create a java source file because intellij thinks it is a TEXT file type. To be honest, I can't remember the exact steps I took to get into this situation, but i'll summerize as best as I can.

Instead of going to the normal way of creating a java class file  (right-click->New->Java Class), I accidentally used the new file option in the  dropdown (right-click->New->File). I gave it my file name but forgot the file extension. For example, I will use "SomeFileName" as the file name.  Once I clicked ok, it gave me a popup to select the file type I wanted to associate with it. I selected Java Source File (.java) and hit ok. But found that for some reason or another it wasn't recognising it as a java source file. So I tried renaming it to a regular file with no extension again. I also tried deleting the file and recreating it as a java source file (right-click->New->Java Class). Unfortunately, at this point I got the following error message in a popup "Unable to parse template "Class"
Error message: Selected class file name 'SomeFileName.java' mapped to not java file type 'Text files'". From there I check the File Type associations via IntelliJ Idea->Preferences->IDE Settings->File Types, and sure enough, if I click on the "Text files" under the recognized file types section and scroll to the bottom, I see "SomeFileName.java" in the list of patterns. Strangely, if I click on the "Java Source files" under the recognized file types section, I also see "SomeFileName" in the list of patterns.

Unfortunately, It looks like I am unable to remove these patterns as both "Java Source files" and "Text files" have the Edit button disabled since they are default file types. So my question is, do I have to completely reinstall intellij idea to remove these entries, or is there some config file in the install I can manually remove these patterns from?

I have tried deleting my .idea directory completely, closing the project, and then recreateing the project from the pom file, but this doesn't seem to affect the file type associations. I have also tried deleting the .iml file in the project, which also  seemed to do nothing (though why there is a .iml file in the first place  i'm not sure, since the project is a .idea folder based project). This makes sense since the file type associations are a global ide setting, not a project specific one. My idea install is on MacOSX 10.7.4, idea version 11.1.5 (build 117.1037), running on java 1.6.0_37 64-bit.

Also, I am wondering if this should be filed as a bug, since I would think if you were able to add an entry into these default file types, you should be able to remove that same entry. I understand not being able to remove or edit the actual default patterns in the default file type, but I think you should be able to remove any pattern you add via the unknown file type popup.

9 comments
Comment actions Permalink

Hi Nick,

You do not need "Edit" button at all. Instead you need to use "-" (Minus) button in Registered Patterns area:

  1. Select required file type in top list (Recognized File Types) -- do it for "Text files"
  2. In bottom list (Registered Patterns) select undesired pattern -- "SomeFileName.java"
  3. Click on "-" (Minus) button to remove pattern from the list
  4. Repeat 1-2-3 for other undesired patterns


If desired, you can also do this manually by editing config file while IDE is closed. Because it's IDE-wide setting, it is not stored in .idea folder (which has project settinsg only) -- the file to look for is called filetypes.xml and shoudl be located in ~/Library/Preferences/IntelliJIdeaXX/options ( see http://devnet.jetbrains.net/docs/DOC-181 for other OS etc )

3
Comment actions Permalink

Hi Andriy,

Now that you point it out, I don't know how I missed it. I was able to remove the patterns I needed to. I was also able to locate the raw xml file in case I do ever need to manually edit it.

Thanks!

0
Comment actions Permalink

Okay, now I got into the same problem. Except I do not see the Idea->Preferences->IDE Settings menu. I have went manually though all the items in the preferences and still don't see it. I use version ... well can someone tell me how to find the IDE version? It's the community edition that I am using..

0
Comment actions Permalink

>well can someone tell me how to find the IDE version?

"Help | About"

>Except I do not see the Idea->Preferences->IDE Settings menu.

For the last 2 years or so (after Settings re-design) it's now "Settings (Preferences on Mac) | Editor | File Types"

 

1
Comment actions Permalink

I would really really like this behaviour changed. If I make:

Component

...and I get prompted for the file extension, but rather than scrolling through I just append, ".jsx" and hit the "OK" button I get a file that thinks it is a plain text file with no extension.

Component

But, apparently, the filetypes.xml has: "Component.jsx" as a matching TEXT file type? I am perplexed by this.

So, I try to: Rename, Delete, make a new file and then rename it to have the desired file name, delete that file because that attempt also failed, edit the .idea/workspace.xml to remove all traces of the file, restart, delete the .idea directory in the project, restart, search for an answer, chuckle like a madman in the midst of teammates and other teams... and finally found this through the correct combo of search terms.

And, the above solution works (I took the manual option). BUT, why would the IDE just be smart and say, hey, the user put a valid extension on the file name, accept it! Maybe even make the choice below align to the extension? And, if I delete a file that fully matches a new "pattern" in IDE-wide filetypes.xml, well, delete or prompt to delete that pattern?

Also, if you hit Cancel in the extension-picker dialog, why does the file still get created, again with TEXT type?

Using: 2018.1

Thank you,

Neil

0
Comment actions Permalink

Hi. Please raise a feature request at https://youtrack.jetbrains.com/issues.

1
Comment actions Permalink
  1. Select required file type in top list (Recognized File Types) -- do it for "Text files"

 

Huh? Where are you?!!  A "top list" somewhere. Try finding that in the docs. argh ;)

0
Comment actions Permalink

Look in File-Settings-Editor-File Types

If you can't find the group of recognized file types like me: there is also a group of recognized file types called Files opened in associated applications. That is where IJ put the file association in my case.

2
Comment actions Permalink

For IJ 2019, if you associated a file with the wrong type: 

- Figure out the current file type association for the file ("Mark As" on the context menu worked for me)

- Go to Preferences (this varies by OS), Editor, File Types 

- Find the file type, remove (with - button) the association in "registered patterns" section

0

Please sign in to leave a comment.