Automatic syntax highlighting for Python



  • I have a couple of .py files, in which I have python code. Syntax highlighting doesn’t seem to kick in, although I checked the langs.xml file and it contains the following lines:

    <Language ext=“py pyw” name=“python” commentLine="#">
    <Keywords name=“instre1”>and as assert break class continue def del elif else except exec False finally for from global if import in is lambda None not or pass print raise return triple True try while with yield</Keywords>
    </Language>

    So in theory it should recognize the file extension and apply python syntax highlighting. Yet it does not work, I have to set Python language for every new file with .py extension manually. How can I do this automatically or fix this problem?



  • Hello @Marcell-Lévai,

    did you install npp or do you use a zipped version?
    If you installed npp, did you use local configuration or %APPDATA%.
    If %APPDATA% was chosen, goto %APPDATA% directory and rename
    notepad++ directory then start notepad++. Does it still happen?

    Cheers
    Claudia



  • @Claudia-Frank thank you, I just did what you mentioned, and now it seems to work properly. I had a theme installed before, so the issue might have had something to do with that. Now I don’t have the theme. So I’ll try to achieve the same setting it up manually and seeing how that affects this. Thanks again for your help :)



  • @Marcell-Lévai

    oh, I see, that could simply mean that this theme hasn’t done any python styling.
    Which theme did you use, maybe it’s easier to modify the theme than to try to
    reconfigure the default theme.

    Normally you would load the theme, goto Settings->Style Configurator->select the language
    and set the styles.

    Cheers
    Claudia