← Back to Archives

The opposite of fill-paragraph in Emacs...

hacks

So, like many emacs users, I occasionally need to do the opposite of a specific command. Case in point, the M-q command which does the function fill-paragraph will take a line that is too long and justify it to 72 columns per row of text (as well as doing a bunch of other things like keeping lists justified properly and such).

How does one do the opposite? Well theres no unjustify-region command or unfill-paragraph command. However, Stefan Monnier has provided a quick unfill-paragraph command that you can place in your .emacs file:

;;; Stefan Monnier . It is the opposite of ;;; fill-paragraph. Takes a multi-line paragraph and makes ;;; it into a single line of text. (defun unfill-paragraph () (interactive) (let ((fill-column (point-max))) (fill-paragraph nil)))