Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs word wrap at a specific column number

Tags:

emacs

I like to run my editor full-screen. The only thing is, though, that when I do this, the word wrap only kicks in when the line hits the right edge of the screen. I would like it to do so, already when the line hits, say, column number 200.

How do I do that?

I would like it to happen in all modes, e.g., Org-mode. I added the line (global-visual-line-mode t) to my .emacs file, in order for the word wrapping also to work in org-mode.

I'm running Emacs 23.


I got it working! Here is what I added to my .emacs file to make it happen:

(add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'text-mode-hook   '(lambda() (set-fill-column 80))) 
like image 960
torbonde Avatar asked Jan 07 '12 19:01

torbonde


People also ask

How do I wrap text in Emacs?

Alternatively, press C-h v word-wrap in Emacs and follow the "customize" link near the end. This is the best answer and without using any modes.

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.

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.


2 Answers

Type M-x auto-fill-mode to activate automatic line-wrapping after a certain column. Then set the actual line width through the variable fill-column as described by user choroba (C-x f).

Note though that this works a bit differently from what other text editors do. M-q will re-format the current paragraph.

like image 104
Thomas Avatar answered Sep 18 '22 12:09

Thomas


You can set the line width with C-xf (set-fill-column).

Afterwards, you might need to hit M-q to reformat the current paragraph (fill-paragraph), or select text to be justified and run fill-region.

like image 37
choroba Avatar answered Sep 17 '22 12:09

choroba