On 01/26/2011 10:34 PM, Jean-Philippe Fleury wrote:
You can use a modeline, something like this:Ed Greenberg a écrit le 2011-01-26 12:59 :I have a circumstance under which I have to edit python source in files of type .txt. Not all the .txt files on my system are python files. Can anybody think of a way to bring up syntax highlighting? Is there a comment I can put at the top of the file, for example?I suppose you know that you can manually select highlight mode in the menu "View > Highlight Mode" when your file is open. But if you want that your Python files written in .txt files have automatically Python highlight mode, I don't know how to do this with a comment at the top of the file, # filetype=python at the top of your file (or bottom) should work (given that your gedit is recent enough and you have modeline plugin enabled). but if you have control on the files name, you could name them .py.txt and add a Python MIME type for .py.txt. In resume, if your files must end by .txt, you could actually end them by .py.txt and add a MIME type to recognize .py.txt files as Python files. To do that, put the attached file in the following folder (create it if it doesn't exist): /home/YOU/.local/share/mime/packages/ and update MIME type database with the following command: $ update-mime-database /home/YOU/.local/share/mime Regards, Jean-Philippe_______________________________________________ gedit-list mailing list gedit-list gnome org http://mail.gnome.org/mailman/listinfo/gedit-list |