Use a custom language definition to mark an entire line if it contains an operator



  • I have a situation where I need to mark any line that contains a particular operator (in this case “@”). The operator may not necessarily appear at the start of the line, but I want to highlight the entire line nonetheless.

    For example I would like to be able to mark the whole line below. I can get it to mark from the “@” to the end of the line, but don’t know how to pick up the words before the operator.

    in a@Lush Forest

    Thanks in advance!



  • @mvancleave99

    open find dialog, goto mark tab and put the following into find what: (?-s).*@.*
    check regular expression and press mark all.



  • Thanks for the quick response!

    That works once, but won’t work for new text entries that meet the criteria. Mark was probably a bad choice. “Custom format” would be more correct.

    I have created a User Defined Language definition, which has worked well for most of my needs. This is the only one that is giving me a bit of a headache.



  • @mvancleave99

    actually the title says it, my bad, sorry.
    No, I don’t think you can do this with udl.
    What you can do is using a scripting language in combination with your udl
    like described here.



  • @mvancleave99
    I have to add that this solution, using pythonscript in combination with udl, works only if
    you use a 64 bit npp version < 7.x or a 32bit version of npp.



  • @Ekopalypse

    Where does the trouble lie with PS and N++ >7.x and 64 bits? To make it work fully, does it require a PS code change, a N++ code change, or both? (If you know)



  • @Alan-Kilborn

    a PS code change is needed for the callbacks as scintilla >=7.x introduced a different
    notification structure, like int fields, formely 32bit, became int_ptr now 64bit on 64bit OS
    and 32bit on 32bit OS.



  • @Ekopalypse

    No worries! People (especially newbies) never post their actual question. Instead they post what they think their question is, so your original answer was quite reasonable. :-)

    Yeah. I think I’ll live with what is a minor anomaly for me. The scripting solution will be above my head … ;-)


Log in to reply