Fractal
Fractal

Reputation: 1897

notepad++ keyword only if at beginning of line

Is there a way to create a rule for a Keyword in your User Define Language that states that in order for this to be a keyword, it must be at the beginning of the line ... or at least be the first word on the line?

Upvotes: 2

Views: 1724

Answers (2)

Sergio
Sergio

Reputation: 126

Actually the built-in 'INI File' language option already highlights the first words ('Keys') up to the '=' sign (besides coloring 'section' names) but that's all. It may be useful for some uses but is certainly limited in applicability.

Upvotes: 1

miroxlav
miroxlav

Reputation: 12184

Note: I'm the guy who answered the question on SuperUser. The same answer:

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.

Upvotes: 5

Related Questions