0

Is it possible to change the colour for a specific character in Notepad++? Let's assume you're using a defined language like KIXstart or Tex and you need every ";" in red colour.

1 Answers1

1

You can use UDL (User Defined Language) to set up whatever syntax highlighting you want, by going Language > User Defined Language > Define your language....

For the example you gave, you'd do:

  1. Create new... and give it a name ("red semicolons")
  2. Go to the Operators & Delimiters tab and enter your operator ";" in the Operators 1 field enter image description here
  3. Press the Styler button right on top of it and select red for the Foreground Color enter image description here
  4. Then on your file, go to Language and select your new language (red semicolons from the bottom of the list

Or you can do the same by added an XML file (red_colons.xml) containing the style to the Notepad++ userDefineLangs directory (%AppData%\Roaming\Notepad++\userDefineLangs). Something like (the specific rule is in the Keywords name="Operators1" and style in WordsStyle name="OPERATORS"):

<NotepadPlus>
<UserLang name="red semicolons" ext="" 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"></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">&quot;;&quot;</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"></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 01 02 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" fontStyle="0" nesting="0" />
        <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="LINE COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="OPERATORS" fgColor="FF0000" bgColor="FFFFFF" fontStyle="7" nesting="0" />
        <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS1" fgColor="FF0000" bgColor="FFFFFF" fontStyle="7" nesting="0" />
        <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
    </Styles>
</UserLang>
Yisroel Tech
  • 13,220