Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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
2  
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

3 Answers 3

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

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.