Community
    • Login

    Language not being saved with file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jack WardJ
      Jack Ward
      last edited by

      How do I get NPP to remember normal text for a file?

      I create a new NPP file.
      I change the file’s Language to Normal Text from AutoHotKey below Define Your Language.
      The file’s text (on screen) changes to normal text.
      I save the file as Test.txt
      When I reopen it, the Language has reverted back to AutoHotKey and is NOT Normal Text.

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        NPP does not save a per-file language-lexer choice. The lexer used is determined by the extension lists in the settings for each Language > Define your language... > Ext : (for a given User Defined Language, UDL), and in the Settings > Style Configurator > User ext. and Default ext. (for a given Language lexer).

        A User ext. in the Configurator or an Ext. : in the UDL settings will override a Default ext.. If an extension isn’t found in the user extensions or UDL extensions, NPP will search the default extension lists, and hand the file off to the appropriate lexer, if found. If an extension isn’t in any of the lists, then it will be handled as a Normal text file.

        So, if you’ve set Ext. : = txt in the User-Defined Language AutoHotKey, then NPP will use the AutoHotKey UDL for the highlighting whenever you open a .txt file, rather than going thru the list of priorities down to the Normal text.

        If you don’t want NPP to apply the AutoHotKey formatting to .txt files, you have to make sure that you remove txt from the User-Defined Language settings for the AutoHotKey (and any other user-defined language or style-configurator language).

        If you want NPP to apply AutoHotKey to some .txt files, but Normal Text to others, that’s more than NPP is programmed to do. You will have to toggle some of the .txt files manually; or you might be able to figure out a way to program a PythonScript or LuaScript to recognize the specific content when a .txt file is opened, and to have the script tell NPP to either use the AutoHotKey highlighting or Normal Text…) Notepad++'s expectation is that files that want different highlighting will have different extensions (so maybe choose .ahk for AutoHotKey files – though, since I don’t know how AHK works, I don’t know if it has a default file extension, or whether it doesn’t care, or whether it only accepts .txt files).

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors