Syntax Highlightning for folder path in custom language
-
Hey, i am new in npp and need your help, how can i highlight full folder path in custom language?
I added " C:\ C:/ E:\ E:/ D:\ D:/ " in keywords lists, and it works only if path without spaces like
C:\Users\Mad\TextOne.txt
if i am using path
C:\Users\Mad\Text Two.txt
its highlight only C:\Users\Mad\Text
-
The User Defined Lanauge (UDL) system is not that powerful on its own.
If you use the EnhanceAnyLexer plugin, you can use a regular expression to define it.
But good luck in coming up with a regex that can distinguish between two similar (or identical) sets of text which mean two different things:
I want to rename c:\path\filename as blah.txt I want to rename c:\path\filename as blah.txtIn the first instance, it’s really implying “I want to rename
c:\path\filename as blah.txt” to mean a single filename with spaces. The second is really implying “I want to renamec:\path\filenameasblah.txt”And by “good luck”, I meant, “that’s an impossible task, without caveats”.
If you have the caveat of “each line that starts with a drive letter then a colon then forward-or-backward-slash is a single filename, which may or may not include spaces, all the way to the end of the line”, then it’s easy. Something like
^[A-Z]:[\\/].*?$will handle that.Or if you defined that all filenames with spaces must have double-quotes around (like the cmd.exe prompt and Windows > Run dialog require), then it’s also not too bad: Something like
[A-Z]:[/\\]\S+|"[A-Z]:[/\\].+?"might work (the left half of the alternation before the|is for filenames without spaces, and the right half is for filenames in quotes, which might contain spaces.Or if you always have a three-letter extension, then
[A-Z]:[/\\].*\.[A-Za-z]{3}would likely work.
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