Is there a way to recognize certain text as a keyword Only if it is the first text in the row?

I don't see such an option within the 'User Defined Language' -> 'Keywords Lists' options

1 Answer 1


I am afraid this is not possible. You can consult UDL2 documentation to learn about User Defined Language capabilities. It is intentionally restricted in order to be easy enough giving a compromise between usability for ordinary users and efficiency.

Solution: The only thing I can advise to you beyond UDL2 is to create your own build of Notepad++. If you get the source, you can see that all built-in language highlighters are implemented procedurally using .lex files. You can create yours and there you have unlimited highlighting possibilities. Then you need to add color definitions to existing XML files, menu item and necessary bindings and you should be done. Hint: built-in Batch language is already highlighting first word on the line so maybe it is a good point to start from.

Workaround: if highlighting of first word on line is sufficient to you, just switch langugage to Batch. :)

Another solution: In these cases, user RProgram always suggests people to switch from Notepad++ to SynWrite editor. Its user-defined languages have much wider capabilities. Maybe this will be the fastest way how you can get to desired result without going too deep.

  • 1
    thanks miroxlav. Yes, i had been looking at the UDL2 documentation and was hoping I just overlooked that section of the documentation. I put a bounty on the same question over in stack overflow, "notepad++ keyword only if at beginning of line". If you put the same answer over there you can have the bounty.
    – Fractal
    Feb 24, 2015 at 2:29
  • 1
    @Fractal - I have enhanced the answer for you.
    – miroxlav
    Feb 24, 2015 at 7:19
  • thanks for the additional information. According to stack overflow I have to wait two hours to give the 50 points for some reason.
    – Fractal
    Feb 24, 2015 at 14:24
  • @Fractal - sure, I know that too... Stack Overflow engine wants to give time to others to possibly beat the best answer. No problem. In the meantime, I have checked SynWrite. (It is not needed to install it, just unzip.) Menu Options > Customize lexers library... > icon New will take you into UDL definition environment. What I could see, the possibilities are huge, but difficulty is high, too (as always, these things go hand in hand).
    – miroxlav
    Feb 24, 2015 at 14:36
  • Thanks miroxlav. I appreciate all the advice. It helped out a lot. :)
    – Fractal
    Feb 24, 2015 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.