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\>"
else
syn keyword perlConditional given when default
syn keyword perlRepeat break
endif
if exists("perl_fold")
syn match perlControl "\<BEGIN\|CHECK\|INIT\|END\|UNITCHECK\>" contained
else
syn keyword perlControl BEGIN END CHECK INIT UNITCHECK
endif

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

4 comments:

Marcus Ramberg 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: http://git.jrock.us/?p=elisp.git;a=blob_plain;f=cperl-mode.el

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