How to set the default language in Notepad++

48

11

I mostly use Notepad++ for dealing with XML files. It would be good if Notepad++ parsed and colorized my files based on the XML language when I open the files. Instead, I have to open the file, pick XML from the Languages menu.

Is there a way to tell Notepad++ that XML is the default language and to treat the files accordingly.

AngryHacker

Posted 2009-10-22T02:30:28.747

Reputation: 14 731

Does it not recognize the .xml file extension? Or are you using some crazy extension for your files? – Sasha Chedygov – 2009-10-22T03:03:23.953

1@musicfreak: I believe AngryHacker is asking about the highlighting when they click File -> New file, which doesn't have an extension until you save it. – Joshua – 2009-10-22T03:08:10.997

It's a .config extension and I have Notepad++ set up to be the default app for that extension. – AngryHacker – 2009-10-22T03:35:40.970

Answers

67

In Notepad++ open the Preferences dialog box by clicking on Settings -> Preferences click on the New Document/Default Directory tab and change the Default Language to XML.

Notepad++ Preferences

EDIT: Just saw that you wanted it to apply to .config files as well. This can be done but you'll need to do it for every extension you want to override. Click on Settings -> Style Configurator scroll down to XML in the language section and add config to the User ext box. Save & Close and any new .config file opened will show up as XML. In fact, I've already done that for my installation as seen below:

Style Configurator

Joshua

Posted 2009-10-22T02:30:28.747

Reputation: 4 434

I must say they have the wrost GUI intuition ever. – Royi Namir – 2014-07-08T07:20:36.797

This seems to not work if there is a conflict, ie: if I select java and specify xml in User Ext (I want xml files to default to java), it does not work. – tbone – 2019-11-15T19:01:51.270

2Works for NEW files, not opening existing ones. Too bad. Thanks for suggestion. +1 – Felipe Alvarez – 2011-03-31T23:35:33.320

Thanks, I'd forgotten how to do this. Kept looking in Settings->Preferences instead of Settings->Style Configurator. -_- – alimbada – 2012-02-13T12:59:59.863

2This setting only applies to new files, not existing files your opening. – heavyd – 2009-10-22T03:10:50.397

1This does not work. The default language sticks between sessions, but the file is not syntax-colorized, until I manually select Language/XML. – AngryHacker – 2009-10-22T03:15:36.097

5Perfect, your edit worked. Computing nirvana. – AngryHacker – 2009-10-22T16:27:14.880

13

In the Notepad++ directory look for the langs.xml file.

Find a node like the one below and add "config" as shown.

<Language name="xml" ext="xml xsml xsl xsd kml wsdl config" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;" />

Restart Notepad++ Open a .config file. It should be formatted as XML.

Mike Chess

Posted 2009-10-22T02:30:28.747

Reputation: 5 583

What happens if there's a conflict, the same extension being associated with >1 language? – tbone – 2018-08-20T18:05:18.583

I tried that to add some more PHP file-types, but didn't seem to work. :-( – Simon East – 2011-07-21T23:11:15.130

You can do this through the GUI too, I believe. (It's been a while since I've used Notepad++ though.) – Sasha Chedygov – 2009-10-22T07:17:34.363

1Note that you may need to look for langs.xml in %APPDATA%\Notepad++ (rather than the program folder). – Sygmoral – 2014-02-14T17:01:27.580

5

Go to Settings > Styler Configurator. Choose XML from the left-hand scroll list. In the bottom of that dialog, there should be two boxes - one for default extensions and one for 'user extensions'. Add your .config to the 'user extensions' box and click 'Save and Close'.

NOTE: The 'user extensions' might not be available for all language choices (I KNOW it is available for C, since that's the syntax highlighting I use at work). So, if it is not available, you'll have to create your own language file.

Creepygeek

Posted 2009-10-22T02:30:28.747

Reputation: 616

3

This is how I did it:

Navigate to %APPDATA%\Notepad++ and open the langs.xml file

Find a node like the one below and add "config" as shown

<Language name="xml" ext="xml xsml xsl xsd kml wsdl **config**" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;" />

Restart Notepad++ Open a .config file. It should be formatted as XML.

And also make sure you don't have any other conflicting settings, i.e. anything else mapped to .config files

Jules345

Posted 2009-10-22T02:30:28.747

Reputation: 31

1

Solution :

The feature is avaible under preferences dialog box.

Go to Settings then Preferences then New Document/Default Directory

and finally edit Default Language to HTML.

Capture :

Notepad++ Preferences

intika

Posted 2009-10-22T02:30:28.747

Reputation: 839

-1

Settings > Styler Configurator > Choose XML - Add you Extension under + [ User Extensions ] - Save and close. Worked for me for .csproj

AdmiralThrawn

Posted 2009-10-22T02:30:28.747

Reputation: 1

I believe that this is the same as the second paragraph of the accepted answer. – G-Man Says 'Reinstate Monica' – 2015-04-29T03:57:59.277