How to Add HEREDOC Syntax Highlighting for PHP in Bluefish
Bluefish is a pretty good editor for programmers and web designers which supports syntax highlighting for many languages – PHP included. While I do like it, there is one little problem when it comes to highlighting PHP code that contains HEREDOC syntax.
I Googled around but failed to find a working solution so I decided to mess around with regular expressions to add my fix. Guess what? I got it working. Here’s how you can add HEREDOC syntax highlighting for PHP In Bluefish.
- In Bluefish, click Edit -> Preferences. Then select the Syntax Highlighting tab
- Select “php” from the filetype dropdown
- Type HEREDOC in “Pattern Name”. Don’t click “Add” yet.
- Choose “Only Start Pattern”
- Type <<<([A-Z]+)\n.*?\n\1; in the “Start Pattern” field
- Type ^PHP Block$ in the “Parentmatch” field
- Type #009900 in the Foreground color field
- Select the “force non-bold weight” and “force non-italic style” radio buttons
- Click “Add”
- Scroll down to the bottom, click HEREDOC and click “Up” until HEREDOC is placed just above “Operators”
- Now, select “Operators” and change its “Start pattern” to [\+\-\*\/\.<>=`!%]+?(?!\?php)
- Click “Apply” then click “OK”
Bluefish should now properly apply syntax highlighting to strings defined the HEREDOC way.

Thanks for this, you’re the MAN!!!! I just wish I would have read this when you first published it :(
In Bluefish 2.0.0 there is no “Syntax Highlighting” tab in Edit -> Preferences. I wonder what version of Bluefish is being discussed here? Some people might think that useful info. I will continue my search, going thru endless out of date web sites that will be stuck on the web for all eternity.