Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Are you running into problems somewhere by using the correct file extensions? – iglvzx Dec 2 '11 at 19:07
I have a Python app that uses .config files that are really Python files, and .NET uses .config files that are really XML files. As another example, I have markdown files that use the .txt extension because they sync with an Android app that doesn't understand what .md files are. – mhenry1384 Dec 2 '11 at 19:12
I see. Does it remember the language you set when you close Notepad++ with the file open, and then reopen Notepad++? – iglvzx Dec 2 '11 at 19:15
Actually it does, if you have "Remember current session for next launch" checked (which I don't). But it forgets it when you close the file and reopen it. – mhenry1384 Dec 2 '11 at 19:21

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.

share|improve this answer
it doesn't save it though. once you close and reopen notepad++, the changes are gone. – r3wt Jan 26 '15 at 18:39
@r3wt I believe you need to run as administrator otherwise it won't have permissions to save the preferences to your user profile. – wweicker Feb 4 '15 at 18:02
This will not work for in-built file extensions. You have to manually remove the extension from the ext part of the language in the langs.xml file. That file can live in %APPDATA%/Notepad++ or the Notepad++ install directory or in your cloud Storage i.e. DropBox, OneDrive or GoogleDrive if you have thhe Settings in the Cloud option enabled. – Ian Stanway Jun 29 '15 at 11:06

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++
share|improve this answer
worked for me, and it was the only way i could get notepad++ to permanently store the relationship. thanks – r3wt Jan 26 '15 at 18:47

To add fixed connection between extension and language, open NPP folder (e.g. C:\Program hFiles\Notepad++), there are several XML files there. Edit them (I don't remember which exactly, langs.xml or langs.model.xml).

Example: <Language name="cpp" ext="h hpp hxx cpp cxx cc">

Find the language you want and add the extension.

However I don't know how to make the same extension vary per-folder.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .