Ctrl+J is a Newline

· jswank's blog


TLDR; Ctrl+J inserts a newline in Readline because J is the 10th letter of the alphabet and the tradition of all the dead generations weighs like a nightmare on the brain of the living.

Using Ctrl+J to insert a new line has a history that spans hardware engineering, OS design, and early text editors. Its lineage can be traced through three major layers: ASCII and Teletype hardware, Unix TTY drivers, and Emacs/GNU Readline.

The Hardware & ASCII Layer (1960s) #

In the ASCII character set (standardized in 1963), every letter corresponds to a number:

On physical teletypewriters, sending a Line Feed (Ctrl+J) instructed the hardware to roll the paper up by one line. Sending a Carriage Return (Ctrl+M, as M is the 13th letter) returned the print head to the left margin.

The Unix TTY Layer (1970s) #

When Unix was created, the developers chose to simplify text handling by using a single character for newlines: the Line Feed (\n, ASCII 10).

Because physical keyboard "Return" keys sent a Carriage Return (\r or Ctrl+M), Unix terminal drivers introduced a system configuration called ICRNL (Map Carriage Return to Newline on Input). When you press Enter, the Unix TTY driver translates that Ctrl+M (\r) into Ctrl+J (\n) before delivering it to applications.

As a result, in Unix, Ctrl+J is the raw, untranslated representation of a system newline.

The Emacs and Readline Layer (1970s–1980s) #

When terminal-based text editors were developed, they needed a way to distinguish between "submit/execute this command" and "insert a literal newline in this buffer."

Summary #

Ctrl+J inserts a newline because J is the 10th letter of the alphabet, mapping it directly to ASCII 10 (Line Feed). Unix adopted Line Feed as its native newline, and Emacs/Readline solidified it as the standard keyboard shortcut to bypass TTY submission and insert a physical line break.

last updated: