Community
    • Login

    Only syntax highlight after period

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.5k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors