Default Langauage for Files with No Extension



  • How can I set the default Language (XML, or JSON) for files with no extension?



  • @waynecnr said in Default Langauage for Files with No Extension:

    How can I set the default Language (XML, or JSON) for files with no extension?

    I don’t think you can, at least not with the configuration options available to you. In the case of XML or JSON, when you go to settings, style configurator, then select xml or json in the language box, you can ONLY add additional file extensions. There isn’t an option to remove the default ones, which is essentially what you want.

    I ran a small test and got these results:
    You can run Notepad++ from the commandline with additional arguments. So
    notepad++ -lxml d:\temp\this-is-an-xml-file-with-no-ext
    would load the named XML file (which has no extension) and then command Notepad++ to colourise it using the XML lexer.

    If the XML file had (on it’s first line) some code such as
    <?xml version="1.0" encoding="UTF-8" ?> (taken from the config.xml file, part of Notepad++ installation)
    then Notepad++ would automatically use the XML lexer as it does attempt to interpret the language to use by the content of the file. I presume a JSON file would also need to have some unique (to JSON) coding at/near the start so it could also be automatically recognised.

    Terry


Log in to reply