Emacs: toggle margin 📜

By Xah Lee. Date: . Last updated: .

emacs toggle margin

Here's a command that just toggles the margin.

emacs Alt+x xah-toggle-margin-right

(defun xah-toggle-margin-right ()
  "Toggle the right margin between `fill-column' or window width.
This command is convenient when reading novel, documentation.

URL `http://xahlee.info/emacs/emacs/emacs_toggle_margin.html'
Created: 2020-04-10 or before
Version: 2026-06-15"
  (interactive)
  (if (cdr (window-margins))
      (set-window-margins nil 0 0)
    (set-window-margins nil 0 (- (window-body-width) fill-column))))
emacs toggle margin right 2020-04-10 5h24m
emacs toggle margin right 2020-04-10 5h24m

Emacs Lines, Column, Cursor Position

Soft-Wrap Lines

Reformat Lines

Show Line Number, Column Number

Highlight Current Line, Screen Line