Syntax Highlighting with fixed-format files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax Highlighting with fixed-format files

Alec Wood
Hey all --

I have a question about syntax highlighting...

I'm working with a file format very similar to the UNIX passwd file, and
I'd like to have vim highlight each field with a different color, eg.
username might be Identifier, password might be Comment, etc.

My problem is that I can't figure out how to match the fields based on
position... I've tried things like this:

syn region passwdUsername start=/^/ end=/:/me=s-1 oneline
syn region passwdPassword start=/^[^:]\+:/ms=e+1 end=/:/me=s-1 oneline
...

The first one matches fine, but the second won't.  Am I
misunderstanding vim's regex engine, or is it something else?

Any guidance would be greatly appreciated.

Cheers,
Alec
Reply | Threaded
Open this post in threaded view
|

Re: Syntax Highlighting with fixed-format files

Nikolai Weibull-2
Alec Wood wrote:

> I'm working with a file format very similar to the UNIX passwd file, and
> I'd like to have vim highlight each field with a different color, eg.
> username might be Identifier, password might be Comment, etc.
>
> My problem is that I can't figure out how to match the fields based on
> position... I've tried things like this:

Take a look at syntax/passwd.vim in CVS.  It was added recently (written
by me).  It should show you exactly how to do this.  Perhaps the syntax
is similar enough to just use it verbatim?,
        nikolai

--
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
Reply | Threaded
Open this post in threaded view
|

Re: Syntax Highlighting with fixed-format files

Alec Wood
Thus spake Nikolai Weibull:
>
> Take a look at syntax/passwd.vim in CVS.  It was added recently (written
> by me).  It should show you exactly how to do this.  Perhaps the syntax
> is similar enough to just use it verbatim?,

Perfect! Many thanks!

Cheers,
Alec