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?

link|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
feedback

2 Answers

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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