Community
    • Login

    Only syntax highlight after period

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.2k 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.
    • pieterjanvcP
      pieterjanvc
      last edited by

      Hi,

      I was wondering how I can setup my user defined language to have some keywords only highlighting when they are prefixed by a period (like when you’re calling an attribute of something).

      Example:

      MyObject.length --> ‘length’ should be highlighted

      length = 5 --> ‘length’ should NOT be highlighted

      Thanks for any input!

      1 Reply Last reply Reply Quote 0
      • Jim DaileyJ
        Jim Dailey
        last edited by

        @pieterjanvc
        Under Language->Define your language … click on the Keywords Lists tab. In the 1st group, click on Prefix mode and then enter a period in the text box. Use the Styler button to choose the way you want the text to look.

        1 Reply Last reply Reply Quote 1
        • pieterjanvcP
          pieterjanvc
          last edited by

          Hi,

          Thank you for the reply, but unfortunately, what you suggest does’t work for the following reasons:

          • Using the period as a prefix for highlighting only works if it’s preceded by a space (which is useless in the code). ‘MyObject .length’ will highlight, but ‘MyObject.length’ won’t
          • If you use it as a prefix, you can’t set it as a deliminator anymore so anything after a period will highlight, not just the words you want

          Any other ideas?

          PJ

          1 Reply Last reply Reply Quote 0
          • Jim DaileyJ
            Jim Dailey
            last edited by

            @pieterjanvc
            Last thing I can think of that may (but probably will not) work for you is to define a Delimiter style having:

            Open: .
            Escape:
            Close: ((EOL))
            

            This will highlight every period to the end of the line.

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