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

languagenotepad

I have a number of files that I would like colored different ways even though they have the same extension. For example, I have some *.config files that are actually Python files and some that are XML files. When I open them I have to manually change the language to Python or XML.

It would be nice if, for example, Notepad++ would remember that c:\foo\bar\whatevs.config should use the Python styling, but c:\hey\ho\boo.config should use XML styling.

Any way in Notepad++ to say "remember the language that was used the last time the file was opened"? A plugin perhaps?

Best Answer

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.

Related Question