50

I have a file in PyCharm and its used to be just a .txt file. Now I wanted to use .rst (reStructuredText).

I know that when I open a file without an ending for the first time PyCharm asks me what kind of file it is and how the syntax should therefore be interpreted.

Can I open up that dialog again somehow, or can I change the association in some other way?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
cwoebker
  • 3,158
  • 5
  • 27
  • 43

5 Answers5

111

Actually, @CrazyCoder is right: If you accidentally mis-labeled the file, PyCharm remembers it and sets a "pattern" for the new file based on the name.

So go to Settings | Editor | File Types, find the type you accidentally mislabeled and remove it from the "Registered Patterns" list.

For example, I mislabed "osm.py" as text file, so under "Text files" I have:

*.bat
*.cgi
.
.
.
osm.py

Remove it and you get your py file colors back! You can also register a file association where there is no extension. By default this is associated as "Text file".

More on File Types.

radtek
  • 34,210
  • 11
  • 144
  • 111
kalugny
  • 1,309
  • 1
  • 9
  • 9
  • i have multiple file types that a certain file may accidentally touch so im trying to fix that. how do i check which file type the active window is associated with? – dtc Jan 17 '23 at 20:04
14

See Settings| Editor | File Types.

Fish Monitor
  • 4,155
  • 3
  • 32
  • 53
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • i saw that but it doesn't help, my file does have the right ending I changed it to .rst from nothing. But it still doesn't recognize it... – cwoebker Jul 31 '11 at 17:05
  • 1
    If you remove the present extension from all the file types, then you will get the same dialog again when you try to open a file with unknown file type. – CrazyCoder Jul 31 '11 at 18:19
  • Also, just my opinion, why not associate it with html? – Jeff Feb 04 '14 at 14:37
3

In case someone still cannot find it: under Settings | Editor | File Types menu, look for: Files Opened In Associated Applications - see if you can spot there the full name of the problematic file and remove it.

hdsm23
  • 31
  • 4
2

I was having the same problem and noticed that if I 'Invalidate Caches' under the File menu I was able to trigger a re-asking of the file type.

Definitely not ideal.

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.

fuzzytake
  • 1
  • 3