Emacs: Uncolor/Unfontify Region or Buffer

By Xah Lee. Date: . Last updated: .

This page shows you how to un-syntax-color a buffer or region.

Normally, you can call font-lock-mode to turn off syntax coloring.

But if you copied some text from another buffer into a new buffer, turning off font-lock-mode won't remove existing coloring.

Here's a command that lets removes syntax coloring.

(defun xah-unfontify-region-or-buffer ()
  "Unfontify text selection or buffer."
  (interactive)
  (if (region-active-p)
      (font-lock-unfontify-region (region-beginning) (region-end))
    (font-lock-unfontify-buffer)))
Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs