• Login
Community
  • Login

Custom Keyword highlighting

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 8.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ?
    A Former User
    last edited by Aug 5, 2016, 7:41 AM

    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…

    Thanks!

    C 1 Reply Last reply Aug 10, 2016, 1:06 AM Reply Quote 0
    • C
      Claudia Frank @A Former User
      last edited by Aug 10, 2016, 1:06 AM

      @Hans-de-Jager

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

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User
        last edited by Aug 10, 2016, 5:30 PM

        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?

        C 1 Reply Last reply Aug 10, 2016, 11:15 PM Reply Quote 0
        • S
          Scott Sumner
          last edited by Aug 10, 2016, 6:34 PM

          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.

          1 Reply Last reply Reply Quote 0
          • C
            Claudia Frank @A Former User
            last edited by Aug 10, 2016, 11:15 PM

            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.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User
              last edited by Aug 11, 2016, 9:11 AM

              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?

              C 2 Replies Last reply Aug 11, 2016, 11:23 PM Reply Quote 0
              • C
                Claudia Frank @A Former User
                last edited by Aug 11, 2016, 11:23 PM

                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.

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 0
                • C
                  Claudia Frank @A Former User
                  last edited by Aug 15, 2016, 9:59 PM

                  Hello Hans,

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

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  3 out of 8
                  • First post
                    3/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors