Spyder: Add option to set syntax highlighting language for a file

Created on 29 Jun 2016  Â·  16Comments  Â·  Source: spyder-ide/spyder

Syntax highlighting is not switched on if the extension is py2 instead of py. Is there an option I can configure to switch the sytax highlighting on? Thanks!

Why?
I am translating some python2 code into python3 and found it useful to have the python2 version of spyder alongside the python3 version (latest dmgs for MacOS). I have also found it useful to change the python2 code extension to .py2. And I recolored the spyder icon and have the standard red icon for spyder3 and blue for spyder2!

Editor Duplicate Enhancement

Most helpful comment

+1 same with me

All 16 comments

There is currently no way to change the highlighting language for a file.

This will be solved by adding a menu to let users do this. However, I don't see it as an easy task, so we won't do it in in the immediate future.

i guess this is like the notepad++ functionality, right?

Yep, exactly. But we need to generate that menu dynamically according to
the available Pygments lexers. And we also need to add a way to change
the highlighting language on the fly.

El 29/06/16 a las 19:41, Gonzalo Peña-Castellanos escribió:

i guess this is like the notepad++ functionality, right?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/3270#issuecomment-229530004,
or mute the thread
https://github.com/notifications/unsubscribe/AAWS7fN56xaqq_9wZZXKtyf-S2Zhqs4Nks5qQxDJgaJpZM4JBcho.

I think that there is an old issue about it already. (on my phone right now, not easy to search…)

Thank you :-)

Found it: #638

@Nodd, Actually my request was rather simpler: to prevent switching off syntax highlighting for files not ending in .py. The file assocation mentioned in #638 is working for me: I can open .py2 files within spyder and they will also open when I double-click on them.

The title of the issue was edited by someone else, my request was less precise, something like: how to keep syntax highlighting on

How often is spyder used to edit files that are not .py? If the answer is very rarely, then a simple solution is to treat all text presented to the editor as python code and have the syntax highlighting switched on at all times.

I think it's way more common to edit non python files than editing python files with an extension different than .py.

The issue is still that the user should be able to choose the syntax highlighting himself. In your specific case it's for .py2, but for us the problem is more general.
A menu is just the most obvious way to do it.

@Nodd, I also recalled we had an old issue about this, but I couldn't find it! Good searching powers my friend!

@ptoche, as @Nodd said, the easiest and more intuitive way to solve this for our users is to add a menu that will let them select the highlighting they prefer.

@ccordoba12 , sure, can't argue with that. I didn't realize that spyder was often used to edit code other than python, but reading the description I see that the editor is described as "multilanguage", so yes your approach makes sense! Thanks.

It has been a couple of years now, is there currently a way to set (or at least turn on the default) syntax coloring for non *.py files?

I am also curious if this is possible now or will be in the future. My use case is *.pyt files which are Python Toolbox files for ArcGIS.

I am also curious if this is possible now or will be in the future. My use case is *.pyt files which are Python Toolbox files for ArcGIS.

+1, as I'm running into this too!

+1 same with me

I'm having the same issue as svHatch and tjhallum, this would be a great feature for GIS developers.

Sorry, this is a duplicate of issue #638. Please add further comments there.

Was this page helpful?
0 / 5 - 0 ratings