314

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?

3 Answers3

396

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.

T. Kaltnekar
  • 8,484
78

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.

alex
  • 18,247
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..