How to change the file type of a single file?

Answered

Hi!

I created a model using New->File and named it blah.rb. Then I copied the class contents to it. But RubyMine still thinks it is a plain text file. How to change that? I was searching for this basic feature for more than 30 minutes now!

iGEL

6
10 comments

Hello Klaus,

Settings | File Types, remove the name of the file from the list of associations
for Plain Text file type.

I created a model using New->File and named it blah.rb. Then I copied

the class contents to it. But RubyMine still thinks it is a plain text
file. How to change that? I was searching for this basic feature for
more than 30 minutes now!


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


13
Avatar
Permanently deleted user

Hi!

Thanks for the answer, now it works. Still I think it's hard to find that solution and I would not expect, that creating a file will change my (global) IDE settings.

Why don't you add a "Change file type" option to the files context menu?

iGEL

6

Any update on this? 

Why not just select the syntax for a single file? Like in Sublime. Sometimes I have files with extension (Linux script for example, with a shebang) and simply to set the correct syntax would be so much easier...

Since script like this don't need to have an extension). So a generic .cgi extension can almost be any language.

1

Hello Roger,

there seems to be a usability problem related, please take a look:

https://youtrack.jetbrains.com/issue/RUBY-18277

0

@olga, thanks that clears is up!

0

Use case for being able to change the file association on a whim...

I'm using PyCharm to edit a Jinja2 template file.  The file will result in an XML output but the template file has an extension of .j2.

Usually I edit the file as a javascript file.  Sometimes I want to see the file as an XML.  Where's the option to see my file highlighted as an XML when the extension is .j2?  And no, going into preferences to change the association is not a reasonable answer.

Where's the resistance to simply add this very useful feature?

What I do now is bounce out to Sublime...  very tedious.

1

@..., we have a corresponding feature request on our tracker so please add your vote there https://youtrack.jetbrains.com/issue/IDEA-113835

1

I accidentally caused this exact same problem with one of my HTML files, thank goodness for this thread!

0
Avatar
Permanently deleted user

I had a similar problem with a terraform.tf file and tried to use the original suggestion, to remove the file from the "Plain Text" list. The list in Settings is "Text" and my file did not appear in it. 
A bit more hunting and I found it in "Auto-detect file type by content". Which, when I tried to set it to "Mark as Plain Text" and then revert it, it said "Make as Auto-Detect..."  My file should have said "Mark as Terraform config file", so that was my hint that the file was not in "Text" but in "Auto-Detect".

0

For future reference for those finding this post, the ability to force change the detected type of a file (e.g. with wrong/no extension) is available since 2021.2 from the tab context menu -> Override File Type. 

4

Please sign in to leave a comment.