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
Avatar
Permanently deleted user

Go to Settings - Editor - FileTypes: Now find your file type in "recognized file type" section and then in "registered patterns" section, add a new pattern by hitting "+" button. Now enter the whole file name as a pattern. IDEA will then ask you this pattern is already assigned to text file, do you want to reassign. Say yes. Then you are done!

-5
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

@Pjandot: This is fixed! See Amsharma's answer (2 posts up).

-1
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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

 

It's freely available and incredibly effective.

 

0
Avatar
Permanently deleted user

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

0

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

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

You can set a regular expression in Settings:

0

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
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

I love this thread. Six whole years of people trying to be helpful but entirely missing the point that file associations should not be this hard.

2

Option is present in 2018.2.

0
Avatar
Permanently deleted user

@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

File | Associate with File Type...

0
Avatar
Permanently deleted user

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

0

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
Avatar
Permanently deleted user

Sorry what is the problem, to change files on the file?

Put in the corner a simple-menu with the types like, php, html, twig, js..... This would be the best feature ....
I think many people have some files who looks .html but seems like .php .... and many many more.

3
Avatar
Permanently deleted user

I am on  IDEA version 2018.2.4.

I have quite a few files without extensions, many of them are executable bash and lua scripts.

Bash scripts with hashbang are recognized even without an extension but lua scripts, even with #!/usr/bin/env lua, fail to be recognized.

I understand the option "associate with file type..." but it registers a pattern using filename. This poses a problem because, in my case, I have bash and lua scripts with the same filename and associating the filename with one type makes all the files, in any project, open with that type's syntax highlighting.

I been a long time user of IDEA, I love it but lack of this feature frustrates me. I don't want to jump through mouse-clicks, menu-items and patterns. I just want to open the "action menu", type "set syntax lua", enter.

At this point I don't even care if IDEA remembers the file type syntax. I will set syntax manually every time I open the file.

Hope you add this feature.

3
Avatar
Permanently deleted user

Six years and this thread is still open.

0
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

@Kohlia

That's really good news! Thanks for posting.

I am using IntelliJ IDEA 2018.2.5 (Ultimate Edition)
Build #IU-182.4892.20, built on October 16, 2018

And I don't any language setting on the bottom toolbar. I have a lock icon and then settings icon. No language drop down menu.

Any advice?

Thanks

1
Avatar
Permanently deleted user

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

@Kohlia @category6 Same version as @category6, same result -- I don't see anything at the bottom to change the format. I do appreciate that I can now handle this stuff with the Registered Patterns of file types, but it's definitely much clunkier than in any other editor that I'm used to.

1
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

The problem is when you try to use for example Jekyll, where everything is *.html, but all is Liquid. There's not even a but of Liquid support, but I still want to open them as Twig, because essentially they are the same. But I can' do that!!! ANY text editor can do that. I don't get it why we're talking about associations, when often I just want to change highlighting/autocompletion on the fly. That should've been implemented many years ago.

Edit: I also have nothing like the screenshots above. I'm using latest stable IntelliJ, RubyMine, Android Studio, AppCode.

1
Avatar
Permanently deleted user

Wow, 7 years and jetBRAINS still doesn't get what we need. Will try to provide few more use cases where file type/syntax select is needed:

  • config files for apache, nginx, supervisord and many more use *.conf extension
  • yml files have different structure, possible value and restrictions for symfony, docker, ....
  • files without extension can contain ANY content

 

In these cases EASY and FAST function to change file type/syntax temporary (without creating file match pattern) is CRUCIAL!!!

1

请先登录再写评论。