Emacs: How to Move Cursor Around Source Code Section (^L)

By Xah Lee. Date: . Last updated: .

This page is a tutorial on how to make the Form Feed ^L character display as line, and how to move cursor in emacs lisp source code by section.

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 page break lines mode screenshot 2012-11-15
Emacs page-break-lines-mode screenshot

You can make emacs display the Form Feed character as a horizontal line. You need to install Steve Purcell's page-break-lines.el. It's also in MELPA package repository. 〔►see Emacs: How to Install Packages Using ELPA, MELPA

Typing the Form Feed Character

In emacs, you can type the char by pressing 【Ctrl+q】 then 【Ctrl+l】. 〔►see Emacs's Key Syntax Explained

Keys for Navigating Source Code Section

Emacs has keys to jump to the Form Feed char. By default, the keys are:

It's hard to use and hard to remember. You can set a more convenient key. For example:

;; 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

Emacs Lisp Commands to Navigate Paragraphs

See: Emacs: Move Cursor by Text Block.

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 tips.

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs