37

For example, main in src/hello.c in the GNU Hello package ends like this:

   exit (EXIT_SUCCESS);
 }
 ^L
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sean Letendre
  • 2,623
  • 3
  • 14
  • 32
  • 12
    It means that the program's done ... to L with it! – Hot Licks Mar 17 '19 at 20:27
  • I'm wondering though if that is an actual FF and the editor simply shows it like ^L, or if it's the characters "^L". If I were an editor, I'd show an FF like "♀" or "␌". – Mr Lister Mar 18 '19 at 07:55
  • @MrLister: Then you would wonder if it's an actual FF or the characters ♀ or ␌. ;-) – tomasz Mar 19 '19 at 12:28
  • `^L` is a Control-L or ASCII FORM FEED, to eject the page. The C compiler normally ignores it, and the editor shows it as shown in your sample. – Luis Colorado Mar 20 '19 at 06:29
  • Possible duplicate of [Escape sequence \f - form feed - what exactly is it?](https://stackoverflow.com/questions/4334370/escape-sequence-f-form-feed-what-exactly-is-it) – phuclv Mar 21 '19 at 01:49
  • @phuclv it is different because the `^L` is not used here as an escape code in a string. – Sean Letendre Mar 21 '19 at 03:13

2 Answers2

60

Literally, it's a page break ("form feed") character. The compiler treats it as ordinary whitespace. But it's very useful for printing source code - it starts a new page (for example, use ^L between functions to force each call to get its own page).

In Vim/vi based editors, you can insert such a character within edit mode by typing Ctrl + V followed by Ctrl + L. It will look like ^L in the editor, but it's actually just one character (ASCII value: 12 or 0x0C).

In other words, ^L does this:

selbie
  • 100,020
  • 15
  • 103
  • 173
  • "it starts a new page" elaborate on this? What do you mean by a page exactly? – kepe Mar 17 '19 at 17:50
  • 7
    If you would print the source code on paper, the printer would… start a new page. – Hermann Mar 17 '19 at 18:11
  • 7
    Literally [this](https://media.giphy.com/media/1ODM8ZlEpcZl6/giphy.gif) – selbie Mar 17 '19 at 18:11
  • Some text editors have keystroke commands to jump to the next or previous `^L` character, and some can also hide all of the text between two `^L` characters. – zwol Mar 17 '19 at 18:27
  • This is the worst concept i have ever seen during my programming life. – Croll Mar 17 '19 at 19:34
  • 13
    @Croll Obviously that's been a short life. You've never had to deal with hundreds of pages of listing s from a line printer. You'd use it all right. – user207421 Mar 17 '19 at 19:49
  • 4
    @Croll Well, it's hardly the first time someone's used whitespace to make code format nicely, is it? – naomimyselfandi Mar 17 '19 at 19:53
  • Actually, you can do the same insertion with an ASR33 Teletype. – Hot Licks Mar 17 '19 at 20:28
  • 2
    @user207421 - I can remember the good ole days, when, if the compiler wasn't smart enough to automatically do it at the start of a procedure you'd insert `@eject` or some such, to get to the top of the next neatly folded page of form-feed paper. Made reviewing code **much** easier. – Hot Licks Mar 17 '19 at 20:30
  • Vertical tabs and form feed are still widely used, but for C we have a lot of pretty print alternatives. Very normal in the mainframe world too. – mckenzm Mar 17 '19 at 22:49
  • Ooh, so you use a device that resembles a 3D printer, but it prints very flat objects very fast... That's a pretty neat concept. I doubt you could find one for a reasonable price though because it looks like it caters to a very small niche market. – Matti Virkkunen Mar 18 '19 at 07:53
1

it is also called form feed.It is a page-breaking ASCII control character. It forces the printer to eject the current page and to continue printing at the top of another. It will also cause a carriage return. The form feed character code is defined as 12 (0xC in hexadecimal)