105

I've associated .xul with Notepad++ so if I double-click on a .xul file, it will open in Notepad++. But Notepad++ doesn't know that XUL is just a particular type of XML, so I then have to manually click on "Language > XML" to get XML syntax highlighting. Is there a way that I can tell it: "every time you open a file with the extension .xul, automatically switch to the XML language"?

1

4 Answers 4

135

All you have to do is tell Notepad++ that "xul" files are actually "XML" files.

  1. Go to Settings > Style Configurator
  2. Under Language, scroll down and highlight "XML"
  3. At the bottom, under User ext. type in "xul"
  4. Press Save & Close
  5. Open your file and it should now highlight properly.

Some other helpful links:

7
  • 18
    And if you want to add more than one (for example, I'm also adding 'rdf' -- yup, I'm doing Firefox extension development) then just separate them with spaces.
    – Tyler
    Jun 11, 2010 at 22:21
  • 1
    I'm saving it and it works for the session but it doesn't persist. When I restart Notepad++, it's not there anymore.
    – strider
    Mar 27, 2014 at 15:31
  • 4
    Run it as Administrator and it persists.
    – strider
    Mar 27, 2014 at 15:37
  • 3
    Note that for user-defined languages, the same can be done from the language configuration window in Language > Define your language... > user language : <your language> in the Ext. field.
    – yco
    Apr 20, 2016 at 9:54
  • Awsome! +1 for you! Nov 11, 2016 at 17:55
10

Here is the instructions for user defined languages. With pictures.

Select: Language --> Define Your Language:

Select: Language --> Define Your Language

Make sure you omit "." from extension in the Ext. box, or it wont work:

Make sure you omit "." from extension in the Ext. box, or it wont work.

2
  • 1
    Please read the question again carefully. Your answer does not answer the original question. This is an answer to some other question.
    – DavidPostill
    Jan 29, 2017 at 15:35
  • 4
    And yet it is very useful. Often when searching for a specific question you will find a more generic question. That's what happened to me. The first answer didn't solve my problem because I was looking for a slight variant of the issue (a user defined language). This answer helped me where the accepted one did not. Feb 21, 2019 at 14:29
0

Update for version 7.5+ and for multiple extensions

1) Settings > Style Configurator

2) look under "Languages:" , choose your target language.

3) look at textbox under "User ext. :"

Simple type the extension you wish to associate for that language. For multiple file extensions, it should be separated via SPACE. Do not use any "." period/dot characters.

EG. for SQL i used the following extensions for table, view, stored proc and user defined functions:

tab viw prc udf
2
  • The only thing that I can see that you’re adding to the accepted answer is that the user can specify multiple extensions, separated by spaces — and that was posted as a comment to the accepted answer nearly nine years ago. Feb 18, 2019 at 0:56
  • @Scott Obviously, the multiple extension was the answer i was looking for that was not provided by the answer. I even indicated it in my first sentence. And the separator which is space is not even common parlance which is normally comma or semicolon. Either way i had to dig in further just to extract the answer. The box is also misleading because it is SMALL looking as if it can only support 1 extension. If you don't appreciate this kind of input, then whatever.
    – Earl
    Feb 18, 2019 at 6:10
0

See Doltknuckle's answer which is great. This answer may help should you find syntax highlighting going a bit haywire. Based on x64 v7.8.6 on Windows.

NPP keeps styling configuration in two files in %APPDATA%\Notepad++:

  • langs.xml
  • stylers.xml

langs.xml is used for built-in languages (like C++ and XML). To find the current "in-built" file types associated with XML, search for name="xml". In the ext section you will find the file types that use XML syntax highlight. In v7.8.6, xul is already assigned to XML so no action is required.

stylers.xml is used for the actual styling applied to each language. It is also where user extensions (User ext.) are saved. To see the extra extensions that have been assigned to XML, search for name="xml".

Many applications re-cycle file extensions. For example .ts files are Javascript files, but also XML files used by Qt Linguist. You may find yourself assigning EXTA to STYLEA (or EXTA may already be assigned to STYLEA), forgetting about it, and later assigning EXTA to STYLEB. NPP will not warn you and you may start to see unexpected syntax highlighting.

This background information may help you find and correct the problem.

As an concrete example, assign cpp to Verilog (clearly a mistake, it is just by way of example). Now all .cpp files will have Verilog and not C++ highlighting.

This may or may not be a bug/limitation in NPP. Certainly a "conflict warning" when you load Settings > Style Configurator... would help. But with so many file extensions out there this may not be possible to resolve. Be aware and hope this helps someone!

You must log in to answer this question.

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