Change file association manually

Answered

I need to change manually a file type for my file "script" (no file extension), from plaintext to other type (Ruby, if you ask).

In previous versions of Idea, it was just a one-click no-brainer... In Idea 11, I've spent like 2 hours trying to find a f...ing action button and reading TFM to no avail... There is NO such action anywhere in the IDE. OK, this is just ridiculous. HOW can such a SIMPLE action become so ridiculously complicated?! Where the f... is this  f...ing thing?!

74 comments
Comment actions Permalink

My main point of frustration is broken workflow. Imagine, you are churning out dosens of small scripts daily, and a common one-click action to associate scripts file type suddenly becomes a detour into Settings complete with typing in patterns like "my_deployment_script_that_does_this_but_not_that". You get the picture, productivity loss is stupendous - thus my frustration.

Yes, either "Associate with file type" context action or hashbang-based autodetection would resolve this (there are not too many shebang variations out there, so it may be the best solution). Treating executable files as unknown binary by default may be another approach.

0
Comment actions Permalink

So what language are your scripts written in? We'd like to know where to put the hashbang detection first. :)

0
Comment actions Permalink

'#!/usr/bin/env ruby' is the only hashbang that is worthy of auto-detection, as far as I'm concerned. ;) Other esteemed gentlemen may disagree, though...

0
Comment actions Permalink

Dan Revel solution (using Refactor to temporarily rename the file) doesn't work for me (I'm in PyCharm Professional 2016.3). When renaming it back the syntax highlighting is lost.

I would also like an option in a file context menu to manually associate THAT file (and not all other files with same extension) to a particular language.

Now, I have some nginx configuration files that are named 'production.conf', 'preproduction.conf' and so on... And I can't and I don't want to rename them for many reasons. I just want to be able to say "this is an nginx config file" and go on with my work.

I find this is a point of frustration.

0
Comment actions Permalink

Can someone explain why I don't see File Types in my settings?

0
Comment actions Permalink

@Serge Baranov - yes! It had added that single file in there, removed that file as being text file type association and life is good again. Thanks for the quick reply!

0
Comment actions Permalink

This should be fixed, please vote for bug IDEA-97714

0
Comment actions Permalink

Changing the editor settings for FileTypes seems like a strange way to address one file somehow not matching the appropriate file type.

Something seems to be overriding the setting matcher in the project, yet I wiped out my projects and the mismatch still persists.

It would make sense to enable changing the override for the one file from the IDE without having to change the overall matcher settings.

0
Comment actions Permalink

I think I found it :-)

Click the file name, select "Rename", then change the extension and click "Refactor" on the dialog box..

Hope this helps..

Jack.

0
Comment actions Permalink

the refactoring thing did not work for me. the issue was the "*." registered path for text files. Removing it made my python scripts with no extension color like python

0
Comment actions Permalink

Why isn't IntelliJ using libmagic to determine file types?

 

It's freely available and incredibly effective.

 

0
Comment actions Permalink

Every week a new idea update, but this issue isn't fixed for years

0
Comment actions Permalink

We are working on it. Option should be available in nearest releases

0
Comment actions Permalink

Just 6 years to move from a discussion to a WIP? Not bad not bad, Jetbrains

0
Comment actions Permalink

In PYCHARM: Projects View, right click in the file without association, and Buala:

You can set a regular expression in Settings:

0
Comment actions Permalink

Ouch. I registered a new extension-less scripts with Bash before remembering I need it to be Python, and it's so, so much harder to "fix this" in IntelliJ than in any other editor I use regularly.

0
Comment actions Permalink

Go to Preferences->Editor->File Types, select the type of file it's recognized as and go to the bottom of the 'Registered Patterns' list. Remove the filename from there and you'll be good to go.

0
Comment actions Permalink

Thing is, even if you register a file type with your specific file, that pattern will be in every single project you make. The best example of why this is annoying is with YAML and YAML/ansible file types. It is very likely that between projects I have a YAML file that has the same name as an ansible file in another projects. But I will never be able to have those 2 files with the right syntax highlighting. 

0
Comment actions Permalink

Option is present in 2018.2.

0
Comment actions Permalink

@Yaroslav Bedrov

What do u mean the option is present.... how i can change the file-type on the fly live VM / Subline and many more.... Why is this feature so big for JetBRAINS ?????

!!!!!! Please install this standard in your software !!!!!

0
Comment actions Permalink

File | Associate with File Type...

0
Comment actions Permalink

sorry but in my version 2018.2 can't select Associate with File Type...

0
Comment actions Permalink

The action should be available for files which have been auto-detected as text or as a particular language. See https://youtrack.jetbrains.com/issue/IDEA-79574.

See also https://youtrack.jetbrains.com/issue/IDEA-186794.

0
Comment actions Permalink

Six years and this thread is still open.

0
Comment actions Permalink

I'm on IDEA 2018.2.5 Ultimate and I can now FINALLY change the language on the fly just the way @Marc suggested. It's not saved across restarts, but I can live with that.



0
Comment actions Permalink

I went to "File Types" in the "Settings" of the IDE and then checked the "Registered Patterns" for "Text" and my filename.extension were listed there. Removed it, applied and then it worked. Quite painful, when you would just want a rightclick on filename.extension -> format for language SQL.

0
Comment actions Permalink

I really don't know why you don't see the option to format it. I don't think I changed much from the defaults. But I will tell you if I find out more.

0
Comment actions Permalink

@Serge Baranov, as description of that plugin states: Useful for "unknown" files or files without extensions.

So for *.conf I can't change to nginx, *.html to twig, .....

Check issue of that in github: https://github.com/mfedko/idea-file-language/issues/2

0
Comment actions Permalink

I have found that I have .js files getting seen as plain text (among other files). I have been able to get it back to proper JS visual encoding by doing the following:

Every time this has happened to me, it's because the file I want to change somehow gets added to the 'Plain Text' list under Settings > Editor > File Types > Plain Text (NOTE: I am in . Going here and removing the file (you will probably see other files you recognize too) will then put that file back in it's original rendering category.

I hope that helps.

0

Please sign in to leave a comment.