312

In the current version of Notepad++ opening .sql files results in Notepad applying SQL syntax highlighting to it. I'd like Notepad++ to do the same for other extensions as well, is there some setting where I can define this?

5
  • It doesn't already? It should do so by default.
    – D'Arvit
    Commented Sep 14, 2009 at 10:11
  • 2
    It does for .sql files, not for other files
    – Sathyajith Bhat
    Commented Sep 14, 2009 at 10:12
  • 4
    I wish Notepad++ just remembered the language selected from the menu for each file, or offered to add your extension to that language's style configurator on the second time you associated the extension with a language. Commented Dec 3, 2014 at 3:35
  • Note that you can also modify your extension's language colors via the Language/Define Your Language... menu.
    – wip
    Commented Feb 8, 2017 at 5:05
  • 1

3 Answers 3

392

When you open a file in notepad++ it will attempt to load syntax highlighting for the contents based on file extension.

If you use a custom extension for one of the existing languages you can add the custom extension in Settings -> Style Configurator. Select language and add the extension in the "User extension" edit box. To add multiple extensions separate them using Space.

You then need to re-open your file to see the syntax highlighting applied.

You can also change syntax highlighting style by selecting a different language from the language menu.

6
  • I have tried this, but it assigns only to 1 extension, I want to assign multiple extensions.
    – Sathyajith Bhat
    Commented Sep 14, 2009 at 11:39
  • 27
    you can add multiple extensions by separating them with space, added that into my post Commented Sep 14, 2009 at 12:23
  • 24
    Note that making this change will not effect files that are currently open in Notepad++. Also, closing and re-opening Notepad++ still will not effect files that remain open between sessions. The individual files must be closed and re-opened for the effect to be seen.
    – mwolfe02
    Commented May 10, 2012 at 16:12
  • This method also does not work for user-defined languages. For those, see the answer below, but instead of the langs.xml, edit the userDefineLang.xml Commented Jun 12, 2014 at 16:15
  • 3
    This method seems to be working only when opening Notepad++ as an administrator. See this issue: github.com/notepad-plus-plus/notepad-plus-plus/issues/67 Also it seems to persist the changes in program files (that's why the permission issue) in C:\Program Files (x86)\Notepad++\themes\SelectedTheme.xml which means this setting is not used when you switch themes. Commented Aug 18, 2017 at 8:31
77

Find the langs.xml file (usually under C:\Users[username]\AppData\Roaming\Notepad++), open it with Notepad++, find the line that begins with <Language name="sql" ext="sql" and add the extensions you want in the ext field, separating them with a space.

To do this for a user-defined language, look instead for userDefineLang.xml and edit ext="".

If you installed notepad++ in "portable"-mode, then the langs.xml and userDefineLangs.xml will be directly in the folder where notepad++ is located.

5
  • 7
    This approach works fine as well, but T. Kaltnekar's approach is a bit more user friendly, thanks!
    – Sathyajith Bhat
    Commented Sep 14, 2009 at 13:59
  • 1
    It's the only way I knew how :).
    – alex
    Commented Sep 14, 2009 at 14:01
  • 2
    Nice, I prefer this approach, I've got a lot of custom extensions and its easier to copy and past them in this way.
    – James
    Commented Feb 28, 2011 at 19:27
  • 2
    This method worked for me. I don't understand why adding the extension with the GUI does not work. "C:\users(user)\appdata\roaming\notepad++\langs.xml"
    – jmmr
    Commented Jul 18, 2012 at 16:42
  • I do not have Notepadd++ installed, just unzipped, so the lang.xml file is in application directory ;-)
    – Betlista
    Commented Nov 26, 2015 at 14:19
1

In case one is using Notepad++ session files (I named them *.nppxml) you could edit them and change the <File lang="..."> attribute, e.g.

<File ... lang="Normal Text" ... filename="httpd.conf"
<File ... lang="Normal Text" ... filename="some.log"

to:

<File ... lang="Powershell" ... filename="httpd.conf"
<File ... lang="log" ... filename="some.log"

to get nice default (or user-defined as in my case with *.log files) syntax highlighting immediately without reopening each single file etc..

You must log in to answer this question.

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