Emacs: Hard-Wrap Lines (fill-paragraph)
Reformat Long Line to Multiple Short Lines
- Alt+x
fill-paragraph
【Alt+q】 - Break a long line into multiple lines. (by inserting newline characters.)
- Alt+x
fill-region
- reformat a text selection into multiple short lines.
- Alt+x
auto-fill-mode
-
toggle auto-fill-mode.
When on, automatically insert newline character as you type when line reaches the right margin (fill-column).
put this in your Emacs Init File:
;; auto hard-wrap lines (auto-fill-mode 1)
- fill-column
-
Variable. The number of chars before
fill-paragraph
etc commands kicks in.(setq fill-column 70) ;; default is 70
- Alt+x
set-fill-column
【Ctrl+x f】 - Set the max characters per line used by “fill” commands.
Note: these commands insert newline characters into your file. This type of wrapping is called hard-wrap. Hard-wrap convention of 80 chars came from punched card. You should avoid hard-wrap when possible; add newline char only at logical positions. (Rant: The Harm of hard-wrapping Lines.)
Make sentence ending by single space
When Alt+x fill-paragraph
etc, emacs reformat it so that there are 2 spaces after a period.
;; make sentence ending by single space (setq sentence-end-double-space nil )
Emacs Lines, Column, Cursor Position
Soft-Wrap Lines
Reformat Lines (Hard-Wrap)
- Emacs: Hard-Wrap Lines (fill-paragraph)
- Emacs: Reformat to Long Lines (unfill-paragraph) 🚀
- Emacs: Reformat Lines for Source Code 🚀