Skip to content

Instantly share code, notes, and snippets.

@Sieboldianus
Forked from centic9/userDefineLang_Dockerfile.xml
Last active August 31, 2024 20:16
Show Gist options
  • Save Sieboldianus/b152fef22c4dce04c2b56236ce3e2dbf to your computer and use it in GitHub Desktop.
Save Sieboldianus/b152fef22c4dce04c2b56236ce3e2dbf to your computer and use it in GitHub Desktop.
Notepad++ syntax highlighting for Dockerfiles (Dark version)

Notepad++ syntax highlighting for Dockerfiles (Dark version)

Store userDefineLang_DockerfileDark.xml at %AppData%\Roaming\Notepad++\userDefineLangs\userDefineLang_DockerfileDark.xml and select Language > Dockerfile in Notepad++.

This color theme is specifically compatible with VS2015-Dark-Npp Theme.

Automatically apply style

Since Dockerfile has no extension, the style is not automatically applied.

A workaround is to use the Plugin PythonScript.

Once installed, select Plugins > Python script > Configuration and change Initialisation from LAZY to ATSTARTUP.

Create a new script: Plugins > Python script > New Script, copy the code below and save as Dockerfile.py:

def callback_BUFFERACTIVATED(args):
    if 'Dockerfile' in notepad.getBufferFilename(args['bufferID']):
        notepad.runMenuCommand('Language', 'Dockerfile')

notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED ])
notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])

Source: community.notepad-plus-plus.org/topic/1134

Once you switch tabs, the style will be automatically applied to all tabs with the name Dockerfile. Currently, this does however not work on file open - if you find a solution, please add a comment.

Clone this gist

git clone [email protected]:b152fef22c4dce04c2b56236ce3e2dbf.git
<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="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="7F9F7F" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="7F9F7F" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="FF0000" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="DFC47D" bgColor="1E1E1E" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="FF8040" bgColor="1E1E1E" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="008080" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="800000" bgColor="1E1E1E" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="808080" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="2048" />
<WordsStyle name="DELIMITERS2" fgColor="FF8040" bgColor="1E1E1E" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="DELIMITERS3" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS4" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS5" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS6" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS7" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS8" fgColor="FFFFFF" bgColor="1E1E1E" fontName="" fontStyle="0" nesting="0" />
</Styles>
</UserLang>
</NotepadPlus>
@jamesfpb
Copy link

jamesfpb commented Aug 31, 2024

Thanks for this.
Excessively bright dockerfile highlighting was doing my head in...

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