Emacs has always offered two camps when it comes to long lines: hard wrapping(inserting actual newlines at fill-column with M-q or auto-fill-mode) andsoft wrapping (displaying long lines across multiple visual lines withvisual-line-mode).1Hard wrapping modifies the buffer text, which isn’t always desirable. Softwrapping preserves the text but has always had one glaring problem:continuation lines start at column 0, completely ignoring the indentationcontext. This makes wrapped code and structured text look terrible.Emacs 30 finally solves this with visual-wrap-prefix-mode.What it doesWhen enabled alongside visual-line-mode, visual-wrap-prefix-modeautomatically computes a wrap-prefix for each line based on its surroundingcontext. Continuation lines are displayed with proper indentation — as if thetext had been filled with M-q — but without modifying the buffer at all.The effect is purely visual. Your file stays untouched.Basic setupAs usual, you can enable the mode for a single buffer:(visual-wrap-prefix-mode 1)Or globally:(global-visual-wrap-prefix-mode 1)You’ll likely want to pair it with visual-line-mode:(global-visual-line-mode 1)(global-visual-wrap-prefix-mode 1)Note that with visual-line-mode soft wrapping happens at the window edge. Ifyou’d like to control the extra indentation applied to continuation lines, youcan tweak visual-wrap-extra-indent (default 0):;; Add 2 extra spaces of indentation to wrapped lines(setq visual-wrap-extra-indent 2)Before and afterWithout visual-wrap-prefix-mode (standard visual-line-mode): Some deeply indented text that is quite long andwraps to the next line without any indentation, whichlooks terrible and breaks the visual structure.With visual-wrap-prefix-mode: Some deeply indented text that is quite long and wraps to the next line with proper indentation, preserving the visual structure nicely.A bit of historyIf this sounds familiar, that’s because it’s essentially the adaptive-wrappackage from ELPA — renamed and integrated into core Emacs. If you’ve been usingadaptive-wrap-prefix-mode, you can now switch to the built-in version and dropthe external dependency.Closing ThoughtsAs mentioned earlier, I’m not into soft wrapping myself - I hate longlines and I prefer code to look exactly the same in every editor.Still, sometimes you’ll be dealing with some code you can’t change,and I guess many people don’t feel as strongly about cross-editorconsistency as me. In those cases visual-wrap-prefix-mode willbe quite handy!I have to admit I had forgotten about auto-fill-mode before doing theresearch for this article - now I’m wondering why I’m not using it,as pressing M-q all the time can get annoying.That’s all I have for you today. Keep hacking! I’ve always been in the M-q camp. ↩