Change file association manually

已回答

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

27

@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

Tomas,

There is separate request for on-the-fly association switching: https://youtrack.jetbrains.com/issue/IDEA-103297

1

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

In Emacs: Oh, this config.conf file looks like YAML, I will just set it to YAML mode. It isn't YAML ? well, just type M-x json-mode or xml-mode, or whatever you want it to be

 

In Idea: Welp, screw you, change file name or forever assign .conf files to be YAMLs till you go and manually change it to something else

0

Not sure if this helps the OP (or others), but I had a similar issue to today where i have a swagger.json file that wasn't actually being parsed as swagger due to the "generic" extension. I clicked that select box at the bottom of the file and re-associated it and now as you can see, it is parsed by the Swagger Plug-in properly and gives me the intellisense as expected. Although what I don't see is the icon change to the "swagger" green {} one that I'd expect (and a co-workers shows the same file properly too even) -- so there must be some other setting i'm missing? But cosmetics aside, at least it works code-wise.

0

I was having the same issue... and getting frustrated... I found the menu on Webstorm 2018 but it was greyed out.

Using Webstrom EAP (2019.02) Fixed the issue. you just need to install jetbrains toolbox and download EAP builds.

 

I hope it helps.

0

File name endings to determine file type are an anti-pattern on unix systems.  The end user doesn't care what a script is implemented in. The system uses the shebang line to determine this association between interpreter and file.

It would be immensely helpful on a daily basis to have this functionality when IntelliJ opens (or creates) a file. As it stands, this is a daily pain point for me.

I love IntelliJ, but when I encounter this problem then I consider trying out VSCode.

1

Must say that on this one I share the same frustration of Ar Vicco in 2012, now in 2019.
I have a toml file that was saved in the codebase with conf extension. Was not able to quickly figure how to make Pycharm understand that that specific file is a toml file.

This should not take over half hour to figure out by googling and getting to read here.

The action "Associate with file type" is found under the File menu (at the bottom of the list of menu items) after selecting the file in question. It is not present in the right-click contextual menu, which is the most obvious spot.

0

"Associate with file type..." dialog can be accessed through actions menu (shift-shift-shift or cmd+shift+A).

But its' name have to be entered fully "Associate with file type".

Partial search isn't working for this dialog for unknown reason 🤷‍♂️

0

PyCharm > Preferences > Editor > File Type > Recognised file types > Select one (e.g., Javascript) > Registered Patterns (+ add wildcard * > apply > - remove wildcard).

This worked for me to get my files associated with the right type.  

 

0

The action "Associate with file type" is found under the File menu (at the bottom of the list of menu items) after selecting the file in question. It is not present in the right-click contextual menu, which is the most obvious spot.

Good news for you folks: the action will be available in the context menu of the Project view in IntelliJ IDEA 2021.2 (EAPs should be available publicly around May 2021). 

2

Just remove the mapping that is given in the error

0

I had a similar problem, but for me, the problem was that the “File properties” menu option does not appear in the project explorer's context menu for the file. Instead, I had to go to the Main menu to find that option. Then it was quite straightforward to associate my file withtout a filename extension to the file type I wanted. I agree that it's not a good idea to associate all files without extension to plaintext for example, since many binary files do not have an extension, but in unix, it is very common that, for example, shellscripts and perl scripts don't have a .sh or .pl extension, but then the shebang usually will do the trick.

0

I have just started using Intellij after working mostly in Rider (C#).

I cannot believe this is still so complicated. I have taken to just deleting the file and creating a new one with the correct extension.

That you can't actually just rename a file's extension beggars belief. I understand the OP's frustrations.

0

请先登录再写评论。