Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Using vim for highlighting in Perl

by tachyon (Chancellor)
on Mar 26, 2003 at 22:19 UTC ( #246113=note: print w/replies, xml ) Need Help??


in reply to Using vim for highlighting in Perl

You are probably aware that the default perl syntax highlighting in vim explodes on things as simple as  s!https?://!! as it does not believe in regex delimiters other than / # or [ (at least in my version). It is also pretty qq!! blind as well amongst other things. Perltidy does a considerably better job (on perl) as it needs (and has) a much better parser/tokeniser. You have to hack the perl.vim syntax config file to fix some of these issues if it does not work properly for your style of coding.

Personally I would use vim for generating everything but Perl syntax highlighted HTML as it does a fine job on more rigidly structured code

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Using vim for highlighting in Perl
by zakb (Pilgrim) on Mar 27, 2003 at 12:26 UTC

    The default perl syntax highlighting does break on some things, but it does allow the regex delimiters (!/# etc) you mention (vim 6.1.422, $VIMRUNTIME/syntax/perl.vim 30 Dec 2002). qq!! does not highlight correctly, but qq##, qq() etc do.

    I have emailed the maintainer a patch to handle the ! delimiter in q, qq, qw, qr expressions.

    You can download the latest syntax files from ftp://ftp.vim.org, or http://www.van-laarhoven.org/vim/syntax/perl.vim for the perl syntax specifically.

      Thanks for that. I have a slightly earlier version of 6.1. Would you be able to post your patch here perhaps? I ma sure I am not the only one who does qq!<var="blah">! and the like so it would have general appeal.

      Speaking of patches have you also patched the pod implementation by chance. This chunk of pod looks rather odd in vim. It is one =head1 and one =cut but confuses vim no end.

        The patch is on my scratchpad, assuming you have diff/patch. Unfortunately, the maintainer of the syntax file says that adding the patch slows down vim on his 160MHz machine, so he's not going to add it - which I find a little strange to be honest. He suggests using the the pipe character | instead. To my mind, the ! is more common, but TMTOWTDI I suppose. Anyway, the patch doesn't seem to slow vim down at all on my machine (700MHz, Win2K).

        Your pod seems to be fine in both set ft=perl and set ft=pod, provided I make it say =cut at the end and not =cu. That's with the latest perl.vim from the link I gave earlier, dated 23 Mar 2003. What filetype are you using (:set ft?)?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246113]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-09-27 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (118 votes). Check out past polls.

    Notices?