Re: Simple Text Editor with Synatx highlighting?
Frank Barknecht hat gesagt: // Frank Barknecht wrote:
> Shao Zhang hat gesagt: // Shao Zhang wrote:
>
> > The worst case that I have seen in vim, is the multiline regexp
> > with quotes in it. And it is even worse if I only want to match
> > the beginning quote. See example below:
> >
> > $hello =~ s{
> > \"hello world
> > }{
> > hello
> > }gex;
> >
> > Anyone have a solution for this? This really prevents me using
> > this nice perl feature.
>
> Uhhm, well, this indeed is a big problem even on my Vim. Further
> investigation needed...
OK, investigation done! The problem Vim syntax has with the above code lies
in the syntax file /usr/share/vim/vim56/syntax/perl.vim
(Maybe there is a newer one.)
It just looks for s///, s### and s[][] like the following excerpt shows:
" Last Change: 1999 Dec 27
[...]
" Substitutions
" caters for s///, s### and s[][]
" perlMatch is the first part, perlSubstitution is the substitution part
syn region perlSubstitution matchgroup=perlMatchStartEnd start=+/+ end=+/[xosmigecd]*+ contained contains=@perlInterpSQ
syn region perlSubstitution matchgroup=perlMatchStartEnd start=+#+ end=+#[xosmige]*+ contained contains=@perlInterpSQ
syn region perlSubstitution matchgroup=perlMatchStartEnd start=+\[+ end=+\][xosmige]*+ contained contains=@perlInterpSQ
So if you rewrite the sample code to
$hello =~ s[
\"hello world
][
hello
]gex;
it gets colorized correctly. Or one could change the syntax file to include
{} pairs in substitutions also.
bye
--
__ __
Frank Barknecht ____ ______ ____ __ trip\ \ / /wire ______
/ __// __ /__/ __// // __ \ \/ / __ \\ ___\
/ / / ____/ / / / // ____// /\ \\ ___\\____ \
/_/ /_____/ /_/ /_//_____// / \ \\_____\\_____\
/_/ \_\
Reply to: