Monday, 21 January 2008

vim and Perl 5.10

If you use vim and want it to highlight correctly the new keywords in Perl 5.10, you can just drop the following syntax plugin script as ~/.vim/syntax/perl.vim :

so $VIMRUNTIME/syntax/perl.vim
syn keyword perlStatementStorage state
syn keyword perlStatementFiledesc say
if exists("perl_fold") && exists("perl_fold_blocks")
syn match perlConditional "\<given\>"
syn match perlConditional "\<when\>"
syn match perlConditional "\<default\>"
syn match perlRepeat "\<break\>"
syn keyword perlConditional given when default
syn keyword perlRepeat break
if exists("perl_fold")
syn match perlControl "\<BEGIN\|CHECK\|INIT\|END\|UNITCHECK\>" contained
syn keyword perlControl BEGIN END CHECK INIT UNITCHECK

An extension, not implemented here, could be to add a new highlight class for the new regexp verbs (MARK, SKIP, COMMIT, etc.)


Marcus said...

Lovely. Added to .vimrc, thanks :)

jrockway said...

Thanks. I forgot to add break and UNITCHECK to cperl-mode (for emacs). I'll add that tonight :)

jrockway said...

Fixed version of cperl-mode is at:;a=blob_plain;f=cperl-mode.el

Anonymous said...
This comment has been removed by a blog administrator.