Skip to content

Instantly share code, notes, and snippets.

@centic9
Last active February 26, 2026 12:20
Show Gist options
  • Select an option

  • Save centic9/deef9d855493eceaf4f8 to your computer and use it in GitHub Desktop.

Select an option

Save centic9/deef9d855493eceaf4f8 to your computer and use it in GitHub Desktop.
notepad++ syntax highlighting for Dockerfiles, store at something like C:\Users\[user]\AppData\Roaming\Notepad++\userDefineLangs\userDefineLang_Dockerfile.xml
<NotepadPlus>
<UserLang name="Dockerfile" ext="Dockerfile" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="1" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="yes" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00# 01 02 03 04</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
<Keywords name="Numbers, extras1"></Keywords>
<Keywords name="Numbers, extras2"></Keywords>
<Keywords name="Numbers, suffix1"></Keywords>
<Keywords name="Numbers, suffix2"></Keywords>
<Keywords name="Numbers, range"></Keywords>
<Keywords name="Operators1">= :- :+ : [ ] ,</Keywords>
<Keywords name="Operators2"></Keywords>
<Keywords name="Folders in code1, open"></Keywords>
<Keywords name="Folders in code1, middle"></Keywords>
<Keywords name="Folders in code1, close"></Keywords>
<Keywords name="Folders in code2, open"></Keywords>
<Keywords name="Folders in code2, middle"></Keywords>
<Keywords name="Folders in code2, close"></Keywords>
<Keywords name="Folders in comment, open"></Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">FROM MAINTAINER ENV RUN CMD ADD EXPOSE COPY ENTRYPOINT VOLUME USER WORKDIR ONBUILD LABEL ARG STOPSIGNAL HEALTHCHECK SHELL AS</Keywords>
<Keywords name="Keywords2">$ ${</Keywords>
<Keywords name="Keywords3">--platform --from --chown&#x000D;&#x000A;</Keywords>
<Keywords name="Keywords4"></Keywords>
<Keywords name="Keywords5"></Keywords>
<Keywords name="Keywords6"></Keywords>
<Keywords name="Keywords7"></Keywords>
<Keywords name="Keywords8"></Keywords>
<Keywords name="Delimiters">00&quot; 00&apos; 01\ 02&quot; 02&apos; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
</KeywordLists>
<Styles>
<WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="FF8040" bgColor="FFFFD9" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="2048" />
<WordsStyle name="DELIMITERS2" fgColor="FF8040" bgColor="FFFFD9" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
</Styles>
</UserLang>
</NotepadPlus>
@ignaciosolergarcia
Copy link

ignaciosolergarcia commented Mar 9, 2018

Just to help others that may try to install this language definition copy this xml file into
C:\Users\[user]\AppData\Roaming\Notepad++\userDefineLang.xml

@hansdg1
Copy link

hansdg1 commented May 2, 2018

Shorter version of the above path:
%APPDATA%\Notepad++\userDefineLang_Dockerfile.xml

@veerun14
Copy link

veerun14 commented Nov 9, 2018

after copying to the location mentioned (C:\Users[user]\AppData\Roaming\Notepad++\userDefineLang.xml), and restarting notepad++, I don't see the language Dockerfile in the D section. any ideas?

@Aypahyo
Copy link

Aypahyo commented Jan 21, 2019

User defined Languages are not sorted into subcategories but appended at the bottom. You should see Dockerfile in Language. Look at the last few entries in Language.

@pkjaer
Copy link

pkjaer commented Mar 1, 2019

I also had to manually import the file afterwards, by selecting Language | Define your language... and then clicking Import and choosing the userDefineLang_Dockerfile.xml file. After restarting Notepad++ it showed up at the bottom of the Language menu.

It would be nice if this feature could be simplified to just putting the XML file in the directory and have it pick it up automatically :)

@PedroWitzel
Copy link

Shouldn't SHELL be a keyword as well?

@centic9
Copy link
Author

centic9 commented Aug 12, 2019

Thanks for the note, I have now added a few more keywords that were missing.

@surarijit01
Copy link

Using NPP 7.7.1, I have placed the file under C:\Users[user]\AppData\Roaming\Notepad++\userDefineLangs folder. Dockerfile entry showing automatically after NPP restart.

image

@pictureaday
Copy link

After importing the file in npp I had to restart it. Then Dockerfile was available from the Language dropdown menu.

@stefankip
Copy link

This sucks if you have a dark theme (white background for all lines of text)

@DaRolla
Copy link

DaRolla commented Oct 29, 2019

C:\Users\[user]\AppData\Roaming\Notepad++\userDefineLang.xml is wrong if using Notepad++ V7.7.1

C:\Users\[user]\AppData\Roaming\Notepad++\userDefineLangs\userDefineLang_Dockerfile.xml is working.

@GrimaceOfDespair
Copy link

Thanks for this!

image

@oimoit
Copy link

oimoit commented Jan 3, 2020

This sucks if you have a dark theme (white background for all lines of text)

It does, but it is a great sample!

You can change to below and it should be ok for Dark Themes:

<NotepadPlus>
    <UserLang name="Dockerfile" ext="Dockerfile" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">03 04 00# 01 02</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1"></Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">FROM MAINTAINER ENV RUN CMD ADD EXPOSE COPY ENTRYPOINT VOLUME USER WORKDIR ONBUILD LABEL ARG STOPSIGNAL HEALTHCHECK SHELL</Keywords>
            <Keywords name="Keywords2"></Keywords>
            <Keywords name="Keywords3"></Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00&quot; 01 02&quot; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="C0C0C0" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="008000" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="FF8040" bgColor="212121" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="800000" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

@ducttapecoder-vt
Copy link

ducttapecoder-vt commented Sep 2, 2020

This sucks if you have a dark theme (white background for all lines of text)

It does, but it is a great sample!
You can change to below and it should be ok for Dark Themes:

I like your idea but based on the recommendations here (notepad-plus-plus/notepad-plus-plus#2662) I gave it another crack at being more theme friendly. I ran through the default themes and it works reasonably well for most of them. The light gray for comments isn't amazing in some, particularly the hellokitty theme, but who uses those themes anyways? ;)

<NotepadPlus>
    <UserLang name="Dockerfile_themefriendly" ext="Dockerfile" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">03 04 00# 01 02</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1"></Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">FROM MAINTAINER ENV RUN CMD ADD EXPOSE COPY ENTRYPOINT VOLUME USER WORKDIR ONBUILD LABEL ARG STOPSIGNAL HEALTHCHECK SHELL</Keywords>
            <Keywords name="Keywords2"></Keywords>
            <Keywords name="Keywords3"></Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00&quot; 01 02&quot; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="FFFFFF" bgColor="212121" colorStyle="0" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="C0C0C0" bgColor="212121" colorStyle="1" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="008000" bgColor="212121" colorStyle="1" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="FF8040" bgColor="212121" colorStyle="1" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="AE0000" bgColor="212121" colorStyle="1" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="FFFFFF" bgColor="212121" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

@TheCaptain989
Copy link

TheCaptain989 commented Oct 11, 2020

FWIW, I made the following changes:

  • Edited the colors to more closely match other Notepad++ built-in languages (like bash)
  • Added 2nd and 3rd Keyword Lists for variables and known double-hyphen options
  • Changed comments to be forced to beginning of line
  • Added Escape to Delimiter 1
  • Added single quote to Delimiter 1
  • Added Operators 1 and allowed Keywords 2 to nest in Delimiter 1
<NotepadPlus>
    <UserLang name="Dockerfile" ext="Dockerfile" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="1" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="yes" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00# 01 02 03 04</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">= :- :+ : [ ] ,</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">FROM MAINTAINER ENV RUN CMD ADD EXPOSE COPY ENTRYPOINT VOLUME USER WORKDIR ONBUILD LABEL ARG STOPSIGNAL HEALTHCHECK SHELL AS</Keywords>
            <Keywords name="Keywords2">$ ${</Keywords>
            <Keywords name="Keywords3">--platform --from --chown&#x000D;&#x000A;</Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00&quot; 00&apos; 01\ 02&quot; 02&apos; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="FF8040" bgColor="FFFFD9" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="2048" />
            <WordsStyle name="DELIMITERS2" fgColor="FF8040" bgColor="FFFFD9" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

@Sieboldianus
Copy link

Sieboldianus commented Jul 20, 2022

This sucks if you have a dark theme (white background for all lines of text)

Another solution: Notepad++ syntax highlighting for Dockerfiles (Dark version)

Does someone know how to make Notepad++ automatically assign this theme to all files labelled Dockerfile? I have to manually select Language > Dockerfile each time I open a file, the highlighting is not applied automatically.

@LostOnTheLine
Copy link

Does someone know how to make Notepad++ automatically assign this theme to all files labelled Dockerfile? I have to manually select Language > Dockerfile each time I open a file, the highlighting is not applied automatically.

I know this is old, but as the question was never answered I'll answer it for future searchers like myself who come across it

Notepad++ uses extensions to automatically determine what Language to use, as Dockerfile has no extension, to my knowledge, it's beyond the scope of Notepad++ to be able to recognize it

@LostOnTheLine
Copy link

  • Changed comments to be forced to beginning of line

I'm curious as to why this was done? As it is now comments are only colored correctly if they follow a new line & start at position 0... Which is in no way required in Dockerfile... Maybe it was at the time, I'm not sure, I just know it currently isn't because they often are between things in the Dockerfiles I've worked with with no opening space & are sometimes indented. I'm not sure if they can be used at the end of a line like in YAML, as I haven't seen that so far. Is that the intent?

@biblia19
Copy link

biblia19 commented Feb 9, 2024

curl -o %appdata%\Notepad++\userDefineLangs\userDefineLang_Dockerfile.xml https://gist.githubusercontent.com/centic9/deef9d855493eceaf4f8/raw/c8ab6ed07279cb149d93acd4c9db0ea422d79aaa/userDefineLang_Dockerfile.xml

one-line command to add the configuration

@GadgetSteve
Copy link

Does someone know how to make Notepad++ automatically assign this theme to all files labelled Dockerfile? I have to manually select Language > Dockerfile each time I open a file, the highlighting is not applied automatically.

I know this is old, but as the question was never answered I'll answer it for future searchers like myself who come across it

Notepad++ uses extensions to automatically determine what Language to use, as Dockerfile has no extension, to my knowledge, it's beyond the scope of Notepad++ to be able to recognize it

@LostOnTheLine and any that follow on to reading this!

There is a Python Script plugin for Notepad++ and a plugin for that available as Mode Line which can do any, or all, of:

  • Set the language based on any python fnmatch rule(s) that you set, e.g. fnmatch.fnmatch('dockerfile*'). If you add the script to your Notepad++ python scripts start-up entry then this will work for any matching filename, not just extension, without needing to change any of the files.
  • Set the language, (built-in or custom), to use based on a shebang, e.g. #! /usr/bin/env docker or #! /usr/bin/env podman, on the first line of each file. It is not a bad practice to have a shebang in each of your files anyway.
  • Set the language &/or other settings based on Vim modeline entries in the file. Only really works if you are also using vim!

If you install the Python script plug-in, then follow the steps for installing the Mode Line plugin, set it to run on start-up as described and then edit either, or both, of the sections of %appdata%\Local\Notepad++\plugins\PythonScript\lib\ModelineLanguageDetectors.py for file name based or shebang detection then restart Notepad++ it works very nicely.

I would like to add my thanks to Dominik @centic9 for the original language file, Francois Francois-R.Boyer@PolyMtl.ca for the Mode Line plugin, Dave @davegb3 for the Python Script Plugin and Don Ho @donho for Notepad++ all of the nearly 400 other contributors to Notepad++ and the Python community for all of their hard work and for their generosity in sharing their efforts with us all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment