Emacs: Uncolor Region/Buffer

By Xah Lee. Date: . Last updated: .

Normally, you can Alt+x 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 removes syntax coloring.

(defun xah-unfontify-region-or-buffer ()
  "Unfontify text selection or buffer.
URL `http://xahlee.info/emacs/emacs/elisp_uncolor_region.html'
Version 2017-05-31 2021-10-04"
  (if (region-active-p)
      (font-lock-unfontify-region (region-beginning) (region-end))
ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Elisp Examples

Text Transform Under Cursor

Commands Do thing-at-point

Command to Insert Things

Script Examples