30

Several times I see ^L in (mostly Emacs Lisp) source codes that looks like are separators of larger logical groups. Is it their real purpose? And if so, how can I use them? Is there a built-in Emacs functionality that utilize it?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
viam0Zah
  • 25,949
  • 8
  • 77
  • 100
  • 1
    None of the answers have mentioned that `^L` is just the default value. You can set a buffer-local `page-delimiter` regexp to anything you want, to get page navigation functionality using some custom value. – phils Aug 20 '17 at 09:52
  • This is the [form feed character](https://en.wikipedia.org/wiki/Page_break#Form_feed), often represented as `\x0c` or `\f` – Boris Verkhovskiy Feb 13 '21 at 23:35

5 Answers5

39

The Emacs commands backward-page and forward-page (C-x [ and C-x ]), among others, take advantage of ^Ls placed in the code as separators.

The habit did not propagate much to languages other than Emacs-lisp, but most languages treat ^L as a blank, so you can use these separators in your favorite language if you like the idea. You can type your own ^Ls with C-q C-l.

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
29

This is a page break.

[...]

A page break can also be used for a logical separation of source-code sections. Emacs has commands and key bindings that use page breaks, such as ‘forward-page’ (C-x ] or C-]), ‘backward-page’ (C-x [ or C-[), and 'narrow-to-page' (C-x n p). Other functions, such as ‘mark-page’, operate on the content of a page. See also PageMode.

6

When exploring a big file with multiple of such "pages" the function "narrow-to-page" (C-x n p) is handy: it hides everything not in the current page. Then for example searching for a function name to see the callers only leads to matches in that section, so you can really focus on understanding the narrowed region.

Use widen (C-x n w) to see the whole file again.

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
zut
  • 806
  • 4
  • 12
5

See also Pretty Control-L if you want to change how Control-l characters appear -- e.g., use a highlighted line instead of just ^L.

Drew
  • 29,895
  • 7
  • 74
  • 104
2

That is indeed a page break character, which on older line printers skipped to the next page or paper. Code-wise, it does nothing; it is only there to split the code into larger sections. There are convenient Emacs commands to jump to the next and previous "page", and inserting these characters takes advantage of that.

Teddy
  • 6,013
  • 3
  • 26
  • 38