sandywp / plugins / html-editor-syntax-highlighter
HTML Editor Syntax Highlighter
Syntax highlighting for the Classic editor's Text tab and the block editor's Code Editor, shortcodes included, using CodeMirror.
Ready in seconds.
v3.0.0 60,000+ installs WP 6.5+ PHP 7.4+

What you get inside
5 screens-
Syntax highlighting in the Classic editor's Code (Text) tab, with WordPress shortcodes highlighted like HTML.
-
The settings panel: theme, key bindings, font and editor options, saved for each user.
-
Syntax highlighting in the block editor's Code Editor, block comments included.
-
Example code highlighting: shortcodes, More tags, inline CSS and JavaScript.
-
In the block editor, open the Code Editor from the Options menu, or press Ctrl+Shift+Alt+M (Cmd+Shift+Option+M on a Mac). Blocks in the visual editor are not…
About this plugin
Add syntax highlighting to the Classic editor’s Text (Code) tab and the block editor’s Code Editor using CodeMirror 6. HTML, inline CSS and JavaScript, and WordPress shortcodes are all highlighted.
Features
- Syntax highlighting in the Classic editor’s Text (Code) tab for posts and pages
- Syntax highlighting in the block editor’s Code Editor (not the Visual Editor)
- Syntax highlighting for WordPress
[shortcodes],[[escaped]]shortcodes and<!--more-->tags - Search and replace, code folding, bracket and tag matching, auto-closing tags and brackets
- Default, VS Code, Vim and Emacs key bindings
- Save your posts and pages by pressing
Ctrl+S(Cmd+Son Mac) - Restores the cursor position after the page reloads
- 13 themes and other settings, saved for each user
- Fullscreen mode in the Classic editor: toggle with
F11/Esc
If you would like to contribute to this plugin, view the github repo.
Questions
- Does it work with Gutenberg?
Yes! Partially… Since version 2.3.0, it works with the Gutenberg Code Editor, but only the Code Editor, not the Visual Editor. Press
Ctrl+Shift+Alt+M/Cmd+Shift+Alt+Mto switch between the Visual Editor and the Code Editor.It does not work with blocks in the Gutenberg Visual Editor. This means it does not highlight code in:
* The Edit as HTML section of every block
* The Custom HTML block
* The Shortcode blockIt may work with other code related parts of Gutenberg in the future. Track the progress here.
- How do I get the Classic Editor back!?
Since WordPress version 5.0, Gutenberg is the default editor. If you want this plugin to work the way it used to, you’ll have to download the Classic Editor plugin.
- Can I search and replace?
Yes.
Ctrl+F/Cmd+Fopens the search panel, which also replaces.Function: WINDOWS / MAC
Search and replace:Ctrl+F/Cmd+F
Find next:Ctrl+G/Cmd+GorF3
Find previous:Shift+Ctrl+G/Shift+Cmd+GorShift+F3
Select next occurrence:Ctrl+D/Cmd+D
Jump to line:Ctrl+Alt+G/Cmd+Opt+G- What happened to highlighting in the Theme & Plugin editors?
Since version 3.0 the Theme & Plugin file editors use WordPress’s own code editor, which highlights your code and checks HTML, JavaScript and JSON files for errors. Switch it on or off with Syntax Highlighting in your profile.
- Why are p and br tags are being removed?
WordPress has a feature called the ‘auto p’ filter which:
“Changes double line-breaks in the text into HTML paragraphs.”
For example, auto p will take some standard post content like this:
Some long text that has many lines. And paragraphs in it.and turn it into something like this:
<p>Some long text<br/> that has many lines</p> <p>And paragraphs in it.</p>Like your little brother, it thinks it’s helping, even if it isn’t.
What can I do about it?
* Disable auto p: There are several plugins you can use to disable auto p in the Classic Editor. I’d recommend Toggle wpautop.
* Show the p tags: The plugin TinyMCE Advanced has an Advanced Option to ‘Keep paragraph tags’. This option will still add the “auto p” tags but won’t strip them out of the visible code.You can read more about this issues this may cause in this support thread.
- Why is my code is being reformatting when I switch to the Visual Editor and back?
The WordPress Visual Editor needs to reformat code in order to function correctly. This is not something that this plugin can fix. You can disable the Visual Editor entirely by going to: Users > Your Profile > Visual Editor: check ‘Disable the visual editor when writing’.
- Scrollbars are not appearing! / Scroll position is not reset! / Code window is not resizable!
You may have the ‘Enable full-height editor and distraction-free functionality’ turned on. This is a native WordPress feature that changes the scrolling and fullscreen behavior of both the Code Editor and Visual Editor.
To Disable Full-height Editor: Go to ‘Screen Options’ (in the top right of the editor page), then uncheck ‘Enable full-height editor and distraction-free functionality’ in the Additional Settings section.
- How do I use Fullscreen?
In the Classic editor’s Text tab, the fullscreen button at the right of the toolbar, or
F11, makes the editor fill the window.Esccloses it (with Vim key bindings, use the button orF11).With ‘Enable full-height editor and distraction-free functionality’ on (in ‘Screen Options’ at the top right of the editor page), use WordPress’s own distraction-free button instead.
Spin up a real WordPress site in seconds.
Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.