Line Feed (LF)

Move the cursor down one line, scrolling if at the bottom margin.

  1. 0x0A
    LF

Hex: 0x0A. ASCII: ^J (Ctrl+J).

Move the cursor down one row. The column is preserved unless linefeed mode (LNM, mode 20) is enabled, in which case LF also performs a carriage return so the cursor ends at column 1 of the next row.

If the cursor is on the bottom row of the scrolling region, LF scrolls the region up by one line. When the scrolling region spans the full screen, the scrolled-off line is committed to scrollback. Outside the scrolling region, the cursor moves down only when it is not already on the last row of the screen.

This sequence always unsets the pending wrap state without performing the deferred wrap.

Note

LF is the single-byte execution path for index (IND): both produce the same cursor and scroll behavior. The same dispatch is also used for VT (0x0B) and FF (0x0C). LF then layers LNM on top.

Tip

Most modern shells and Unix tooling expect LF alone to end a line and rely on the terminal driver (not LNM) to add the carriage return on output. Leave LNM off unless you are talking to an application that needs the legacy newline behavior.

Validation

LF V-1: Basic Down Move

printf "AB"
printf "\n"
printf "X"
|AB________|
|__X_______|

LF V-2: Scroll at Bottom Margin

rows=$(tput lines)
printf "\033[${rows};1H" # move to bottom-left
printf "A"
printf "\n"
printf "X"
|A_________|
|_X________|

The previous bottom row scrolls up; the new bottom row receives the X after the column is preserved.

LF V-3: With Linefeed Mode (LNM)

printf "\033[20h" # enable LNM
printf "AB"
printf "\n"
printf "X"
printf "\033[20l" # disable LNM
|AB________|
|Xc________|