Skip to content

Improved PHP support in Kate

Wednesday, 26 August 2009 | Milian Wolff


Not only KDevelop gets better and better PHP support — the Kate PHP syntax file also got a few new features and fixes over the last weeks. The good thing is of course that all users of KWrite, Kate, Quanta, KDevelop and other editors leveraging the Katepart benefit from these changes.

Improved HereDocs

screenshot of improved highlighting in PHP heredocs
screenshot of improved highlighting in PHP heredocs

I went over PHP related bugs on bugs.kde.org today and spotted one that was fairly easy to fix:

vim-like syntax highlighting support for heredocs in php.xml

With some magic (IncludeRules just rocks) I got it working fairly easy. You can see the results to the right.

Additionally I added code folding to heredocs, since often these strings include lots of text and hiding it often makes sense.

Better support for overlapping syntax regions

code folding with overlapping syntax regions
code folding with overlapping syntax regions

Another long standing bug (accommodate overlapping syntax regions (especially for php)) got fixed by James Sleeman.

Finally PHP templates with code such as

  1. <?php if ( true ) : ?>
  2. <!-- some html stuff -->
  3. <?php elseif ( false ) { ?>
  4. <!-- some other html stuff -->
  5. <?php } ?>

can be folded properly. This kind of spaghetti code is used quite often in simple templates and having the posibility to fold it properly is a huge win in my opinion. Thanks to James Sleeman again!