0

Possible Duplicate:
Force Content-Type on files with no Extension in EclipsePDT?

I'm currently working with Python files that are not saved with any file extensions. I have already added the following to the first line of these files: #!/usr/bin/env python

Unfortunately, Eclipse still doesn't understand to highlight it as a Python file. I already have PyDev installed and it highlights perfectly fine for files that have the .py extension. Not sure how I can get it to work without it. Help?

Community
  • 1
  • 1
JLYK
  • 391
  • 9
  • 22
  • Why do you want to have Python code in files without an extension? – Wooble Sep 25 '12 at 18:10
  • 1
    Have you looked at this? http://stackoverflow.com/questions/2009636/force-content-type-on-files-with-no-extension-in-eclipsepdt – Aaron McIver Sep 25 '12 at 18:11
  • So I tried to follow the link but it doesn't seem to work for me. The files that I'm working on are single Python scripts that are not bundled up in solution packages etc. so don't have them all listed out nav panel. I need to be able to open any Python script and have it do syntax highlighting. – JLYK Sep 25 '12 at 18:23
  • Eclipse only works on files within workspace really... – Antti Haapala -- Слава Україні Sep 25 '12 at 18:23

2 Answers2

4

Just right click on the file in for example project explorer / navigator view, and choose in the context menu "Open with" -> ("Other..." -> "Internal editors") -> "Python editor"

0

Window -> Preferences
General -> Content Types

Click "Python" in the "Content types:" list.

Then add any file associates by clicking Add...

and specify *.py or whatever extension you need

ddavison
  • 28,221
  • 15
  • 85
  • 110
  • Uh...my problem is that these files DON'T have an extension. – JLYK Sep 25 '12 at 18:42
  • Eclipse won't know without an extension. I suppose you could try and force it by following the same steps, but instead of "Python" content type, put it under "Text", and put "*" as the content type... not strongly recommended though – ddavison Sep 25 '12 at 18:47
  • Eclipse doesn't let you do that. You have to give it a file extension. It will not let you add a Context Type of just "*". – JLYK Sep 25 '12 at 18:54
  • Then there is no way for eclipse to know that you want Python syntax highlighting enabled on your file. sorry :/ – ddavison Sep 25 '12 at 18:59