All articles
Linux
Sat, Apr 18, 2026

Inline PHP Syntax Check in JOE Editor

Inline PHP Syntax Check in JOE Editor

If you are an classic PHP developer like me, you probably use JOE (Joe’s Own Editor) as your text editor on Linux. Fast, lightweight, always available on any server. Sure, it lacks the bells and whistles of VS Code or PhpStorm, but when you are connected via SSH to a remote server, JOE gets the job done reliably.

One limitation I have always felt, though, is the absence of built-in PHP syntax checking. With modern IDEs you get errors highlighted in real time, whereas with JOE you have to save, exit, run php -l filename.php from the terminal, then reopen the editor… tedious and disruptive.

So I decided to dig into JOE’s macro system and, after a few hours of experimentation (the documentation is practically non-existent!), I came up with a solution that:

  • Runs the syntax check on the in-memory buffer, without saving the file
  • Displays the result in colour directly in the terminal
  • Restores the cursor to exactly the line you were working on
  • Is entirely inline, with no external scripts
  • Is triggered by a customisable keyboard shortcut

How It Works

The solution relies on JOE’s filt command, which pipes the current buffer to an external shell command and then replaces the buffer with the command’s stdout. The trick is to redirect the output of php -l to /dev/tty instead of back into the buffer, so the file contents are never altered.

To save and restore the cursor position, the pattern markl + tomarkb + nmark is used: the current line is marked as a block mark before the check, the cursor returns to that mark afterwards, and finally the mark is cleared so the line does not remain highlighted.

Colours are added using ANSI escape codes via sed: green for “no errors”, red background for Parse errors.

Configuration

Open (or create) ~/.joerc and add these lines at the end:

:def phpcheck markl,filt,"cat >/tmp/joephp$$.php;printf '\\n' > /dev/tty;(php -l /tmp/joephp$$.php 2>&1 | sed 's/No syntax errors.*/\x1b[32m&\x1b[0m/;s/Parse error.*/\x1b[41;97m&\x1b[0m/') >/dev/tty;printf '\x1b[1m--- Press ENTER---\x1b[0m\\n' >/dev/tty;read dummy </dev/tty;cat /tmp/joephp$$.php;/bin/rm /tmp/joephp$$.php",rtn,retype,tomarkb,nmark
:main
phpcheck ^[ p

Save the file and restart JOE. The shortcut ^[ p corresponds to ESC then P. On a standard UK or US keyboard, simply use the [ key directly followed by P. (Keys may vary on international keyboards. On an Italian keyboard this is AltGr+è followed by P, since that key produces the [ character which represents ESC in JOE’s notation.)

What You See

Press the shortcut whilst editing a PHP file and the coloured result appears immediately:

  • Green: no syntax errors detected
  • Red background, white text: Parse error with the offending line number

A bold ”— Press ENTER—” prompt then appears and waits. Once you press Enter, JOE redraws the screen and the cursor returns to exactly the line you were on. The file has not been touched.

Technical Notes

A few non-obvious things discovered along the way:

  • In JOE 4.6 sections are declared with :main, not [Main] as one might expect
  • Key bindings are written as command-then-shortcut, not the other way round
  • psh/pop in JOE saves block markers, NOT the cursor position — a subtle trap
  • printf with a double backslash is the only portable way to emit ANSI escapes; bash-style echo $'...' syntax does not work because JOE uses plain sh
  • Single quotes inside sed work correctly within the double quotes of a JOE macro

Hopefully this saves a few headaches for other die-hard JOE fans out there!


Mauro Longone – Stylesoft.it

StyleSoft Team

Editor

Share:
Scrivici su WhatsApp!