Custom Keyword highlighting

  • Hello,

    I have some textfiles.
    In these textfiles I have marked keywords like this: {name} or {color}
    Afterwards I replace these keywords automatically with values from another program.

    How can I make these keywords {bla} stand out?
    Highlight in a specific color for example…


  • @Hans-de-Jager

    sorry don’t get the point - do have an example what exactly should be achieved?


  • Hi Claudia,

    Thanks for your response.
    I have text files that contain instructions for my customers. In these text files I have added variables, marked with {…}
    Afterwards I use a process to replace {name} with an actual customer name. And {city} with the actual customer city.

    I would like Notepad++ to highlight these ‘variables’… So any string starting with { and ending with } should be highlighted with font color red for example.

    Is this possible?

  • A lot of things are possible, but the easy way to do this is to use the “Mark” feature (part of find). In the “Find what” field of the Mark tab (in the Find dialog), enter \{.+?\}. Make sure “Search Mode” is set to “Regular expression”. I also would advise checking the “Wrap around” checkbox.

  • Hello Hans,

    Scotts solution might be the easiest.
    Another attempt would be to define your own UDL.
    Open UDL (Language->Define your language…)
    open tab Operators&Delimiters
    In Delimiter 1 style put { in Open: field
    and } in Close: field.
    Press the Styler button and select the foreground color of your choice.
    Save it with a meaningful name and close it.
    Your UDL should now be visible under the Language menu.
    When ever it is needed, select your user defined language (UDL) and everything between {} should be colored.


  • Thank you both for the response.
    I was looking for the solution provided by Claudia.
    One more question, is it possible to add this highlight to the existing HTML language?

    So to keep the default HTML syntax highlighting, but add this custom format to it?

  • Hello Hans,

    unfortunately not.
    You can only have one lexer active at a time.

    Not sure if you can hijack the lexer and do some lexer coloring
    using another plugin in a reliable way. Some could mark a text, like Scott said,
    but using styling … ???

    Let me think about it.


  • Hello Hans,

    sorry, unfortunately I didn’t find a reliable way to style text while a lexer is active.


Log in to reply