48

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.

3
  • Does it not recognize the .xml file extension? Or are you using some crazy extension for your files? Oct 22, 2009 at 3:03
  • 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
    Oct 22, 2009 at 3:08
  • It's a .config extension and I have Notepad++ set up to be the default app for that extension. Oct 22, 2009 at 3:35

6 Answers 6

69

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

7
  • 3
    This setting only applies to new files, not existing files your opening.
    – heavyd
    Oct 22, 2009 at 3:10
  • 1
    This does not work. The default language sticks between sessions, but the file is not syntax-colorized, until I manually select Language/XML. Oct 22, 2009 at 3:15
  • 5
    Perfect, your edit worked. Computing nirvana. Oct 22, 2009 at 16:27
  • 2
    Works for NEW files, not opening existing ones. Too bad. Thanks for suggestion. +1 Mar 31, 2011 at 23:35
  • Thanks, I'd forgotten how to do this. Kept looking in Settings->Preferences instead of Settings->Style Configurator. -_-
    – alimbada
    Feb 13, 2012 at 12:59
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.

4
  • You can do this through the GUI too, I believe. (It's been a while since I've used Notepad++ though.) Oct 22, 2009 at 7:17
  • I tried that to add some more PHP file-types, but didn't seem to work. :-(
    – Simon E.
    Jul 21, 2011 at 23:11
  • 1
    Note that you may need to look for langs.xml in %APPDATA%\Notepad++ (rather than the program folder).
    – Sygmoral
    Feb 14, 2014 at 17:01
  • What happens if there's a conflict, the same extension being associated with >1 language?
    – tbone
    Aug 20, 2018 at 18:05
6

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.

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

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

-1

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

1

You must log in to answer this question.

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