Cannot get HTML here-doc syntax to work in Perl file using Vim 7

7 views
Skip to first unread message

DwigtArmyOfChampions

unread,
Dec 30, 2025, 12:25:57 PM (yesterday) Dec 30
to vim_use
Using Vim 7.4, with the following Perl code: 

print <<"HTML"; 
<table> 
   <tr> 
     <td>I AM THE TABLE.</td> 
   </tr> 
</table> 
HTML 

 ...I want the syntax highlighting to display as HTML. I tried adding the following code to ~/.vim/after/syntax/perl.vim:

" Load HTML syntax
syntax include @html syntax/html.vim

" Highlight HTML inside <<HTML heredocs
syntax region perlHereDocHTML
      \ matchgroup=perlHereDocDelimiter
      \ start=+<<\s*["']\=HTML["']\=+
      \ end=+^HTML$+
      \ contains=@html
      \ keepend

But it is still not working. It is displayed as plain yellow text. How do I get it to highlight the HTML elements as if I were viewing a .html file?
Reply all
Reply to author
Forward
0 new messages