Make Notepad++ remember a particular language for a particular file?

Solution 1:

There is a GUI option to set up a static link between file extension and language (instead of manually editing the %APPDATA% langs.xml file or %PROGRAMFILES% langs.model.xml file as @jakub.g suggested):

If you go to Settings -> Style Configurator -> select the language on the left, then at the bottom of the screen two textboxes appear:

Style Configurator

In this example, I added "config" to the User ext. textbox so any time I open a file with a .config file extension the XML syntax highlighting will be automatically selected under the Language menu.

I know this doesn't solve the problem of remembering which syntax highlighting to apply to a single specific file, but it is an easy way to set up highlighting for all file extensions.

If you want to remember the syntax highlighting selection for an individual file I believe the only option is to select the checkbox: Settings -> Preferences -> MISC -> Remember current session for next launch.

Solution 2:

This isn't quite what you're asking for, but applies to your comment regarding .txt files as Markdown files. One possible option is to set Markdown as the language for all .txt files.

This assumes markdown_npp is installed. Edit the following files at your own risk (make backup copies before editing these files):

  • Open langs.xml from %appdata%\Notepad++
    • Remove txt extension from normal language:
      • Before: <Language name="normal" ext="txt" />
      • After: <Language name="normal" ext="" />
  • Open userDefineLang.xml from %appdata%\Notepad++
    • Add txt extension to Markdown language:
      • Before: <UserLang name="Markdown" ext="md">
      • After: <UserLang name="Markdown" ext="md txt">
  • Restart Notepad++