Language not being saved with file
-
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. -
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 theSettings > Style Configurator
> User ext. and Default ext. (for a givenLanguage
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 LanguageAutoHotKey
, then NPP will use theAutoHotKey
UDL for the highlighting whenever you open a .txt file, rather than going thru the list of priorities down to theNormal 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).