Warning: Undefined array key "pmwiki" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 14

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 14

Warning: Undefined array key "pagename" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 225

Warning: Undefined array key "pagename" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 253
hltPHPLikeVim - Cookbook - PmWiki

hltPHPLikeVim

Summary: Hilite PGP code like Vim
Version: 20260414
Prerequisites: Preferably PHP Version 8.5 but as low as 8.2, anything older has reached PHP "End of life" and might work, I do not support PHP version 5
Status: ready
Maintainer: gnuzoo
License: GNU General Public License as published by the Free Software Foundation http://www.fsf.org either version 2 of the License or (at your option) any later version
Categories: Uncategorized
Users: (view / edit)
Discussion: HltPHPLikeVim-Talk
Downloads: hltPHPLikeVim.php

Questions answered by this recipe

I use the greatest text editor in the world - Vim.
I love the color it has, but it appears there is no way
to hilite code that looks even close to what I see in Vim.
How do I make PHP code display just like it is in Vim?

Description

Make your PHP code look great in PmWiki pages

This is based on a custom state machine that mimics Vim's line-by-line
regex engine. It directly puts colors into html rather than CSS because
bandwidth is not an issue like it was 25 years ago.

Installation

Add one line to you config.php file.

    require_once("hltPHPLikeVim.php");

Usage

Around PHP code put page directives like this:

(:hltPHPLikeVim:)
      <?php echo "Hello world" ;?>
(:hltPHPLikeVimEnd:)

Your code will display in the beautiful colors that Vim displays.

Click to see this image full size:

Click this image to see the full beautiful PHP code colors

Change log / Release notes

Initial Release: Version 20260414

Comments

See discussion at HltPHPLikeVim-Talk

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.