Associate file extensions to language in Notepad++

Software:
Notepad++ 7.8.6

If your writing code in languages that are based on a common language but their files names have an uncommon extension, for example, the 3D shading languages OSL, and HLSL, which are written in C syntax but have .osl and .hlsl, or .fx as file name extensions,
Notepad++ wont automatically recognize that the code in these files is actually C language and present their syntax properly.

To set Notepad++ to recognize specific file associations with a wanted language:

  1. Goto:
    Settings > Style Configurator:
    Annotation 2020-06-18 132154
  2. In the Style Configurator window:
    Select the wanted language in the language list on the left,
    And in the User ext. field, type a list of file extensions separated by spaces:
    These file extensions will be interpreted as the selected language.
    Annotation 2020-06-18 132359

 

Related:
Setup a GitHub to associate file extension with a  language
Display tabs in Notepad++

2 thoughts on “Associate file extensions to language in Notepad++

  1. I just wanted to add that after you add the extension to the “user ext” field, the file formatting will not be visible for a file until you close and re-open it. This must be done for each file – closing and reopening notepad++ won’t work). At least for my version Notepad++ v8.3.3. Hope this helps someone!

Leave a Reply to kodirCancel reply