Emacs: Display Formfeed ^L as Line

By Xah Lee. Date: . Last updated: .

Displaying Form Feed Character as Line

Emacs lisp uses the Form Feed character (Form Feed; ASCII 12) as source code section marker. It is displayed as “^L”.

emacs formfeed as line 2017 06 18
emacs, displaying formfeed as line

Here's a command to display the Form Feed character as a line.

(defun xah-display-control-l-as-line ()
  "Display the formfeed ^L char as line.
URL `http://ergoemacs.org/emacs/emacs_form_feed_section_paging.html'
Version 2017-06-18"
  (interactive)
  ;; 2016-10-11 thanks to Steve Purcell's page-break-lines.el
  (progn
    (when (not buffer-display-table)
      (setq buffer-display-table (make-display-table)))
    (aset buffer-display-table ?\^L
          (vconcat (make-list 70 (make-glyph-code ?─ 'font-lock-comment-face))))
    (redraw-frame)))

Insert Form Feed Character

To insert form feed character, press 【Ctrl+q】 then 【Ctrl+l】.

〔►see Emacs's Key Syntax Explained

Move Cursor to Prev/Next Formfeed

Move cursor to the prev/next page break:

You can set a more easy key that can be held down:

;; keys for moving to prev/next code section (Form Feed; ^L)
(global-set-key (kbd "<C-M-prior>") 'backward-page) ; Ctrl+Alt+PageUp
(global-set-key (kbd "<C-M-next>") 'forward-page)   ; Ctrl+Alt+PageDown

Using 【Ctrl+Alt】 makes it consistent with the default keys to navigate lisp code. 〔►see How to Edit Lisp Code with Emacs

For a detailed discussion of using the Form Feed character as page section marker, see: Emacs Form Feed (^L) Page Marker.

Thanks to Steve Purcell ( https://twitter.com/sanityinc ) for his page-break-lines.el package.

Like it? Buy Xah Emacs Tutorial. Thanks.