Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable line wrap on word boundaries only in Emacs?

Tags:

emacs

How do I configure Emacs so that line wrapping does not break in the middle of a word?

like image 920
Yufei Avatar asked Jul 19 '10 13:07

Yufei


People also ask

How do I turn off word wrap in Emacs?

I think what you probably want is "M-x toggle-truncate-lines". That toggles between wrapping or requiring you to scroll right and left to see the entire line. This is actually a way better answer than the accepted one.

How do I enable line mode in Emacs?

By default, Emacs displays the current line number of the point in the mode line. You can toggle this feature off or on with the command M-x line-number-mode , or by setting the variable line-number-mode .

What is line wrap mode?

Modes such as Long Lines wrap lines on word boundaries as you type, by inserting temporary line-ending characters. These are removed when you save the buffer to a file or copy its text for yanking elsewhere, so they are only for display purposes.


2 Answers

If you want to emulate the behavior of an editor like Notepad, you might want to turn on visual line mode. While setting word-wrap will cause line wrapping at word boundaries, any action you take on a line (e.g., moving up/down or killing) will still respect the newline character. Visual line mode will treat each display line as though it had a newline at the end.

(visual-line-mode t) 

Line to add in .emacs file:

(global-visual-line-mode t) 
like image 163
Kirk Kelsey Avatar answered Sep 23 '22 17:09

Kirk Kelsey


M-x toggle-truncate-lines disable allows you to disable visually line breaking.

M-x auto-fill-mode + M-q allows you to word wrap for real a pre-existing paragraph.

like image 25
Doomsday Avatar answered Sep 21 '22 17:09

Doomsday