Skip to main content
8 votes

How does one do the reverse of fill-region / fill-paragraph in emacs?

Try M-x unfill-region and M-x unfill-paragraph. Their documentation says that they are the respective inverses of those two commands. Edit: Forgot that this is not built in. You want package unfill ...
Phil Hudson's user avatar
  • 1,798
8 votes
Accepted

fill-paragraph (`M-q`) for s-expressions?

Perhaps you're looking for indent-pp-sexp, which is bound to C-M-q by default in emacs lisp mode. With a prefix argument (e.g. C-u C-M-q) this will "pretty print" the sexp at point.
glucas's user avatar
  • 20.9k
5 votes
Accepted

How to have fill-paragraph/fill-region break the line after a period?

You have sentence-end-double-space set to its default value, which is t. The relevant part of the docstring: Documentation: Non-nil means a single space does not end a sentence. This is ...
Dan's user avatar
  • 33.4k
4 votes
Accepted

pasting from websites results in 1 long line..anyway to keep the paragraph format?

Just run fill-paragraph bound by default to M-q Depending on where you are copying from, remember that the paragraph is one logical object, how it shows depends on the width of the browser on your ...
icarus's user avatar
  • 1,934
4 votes
Accepted

How to prevent LaTeX verbatim environments to be subject to LaTeX-fill-region

Add your self-defined verbatim environment to LaTeX-indent-environment-list. Your modified example would look like this: \documentclass{article} \usepackage{verbatim} \begin{document} This text just ...
Tobias's user avatar
  • 33.7k
4 votes

How does one do the reverse of fill-region / fill-paragraph in emacs?

spacemacs has a nice design regarding this in better defaults layer. from it's manual: Fill or unfill paragraph: Pressing M-q for the first time fills current paragraph and pressing M-q for the ...
nichijou's user avatar
  • 1,218
3 votes
Accepted

How to fill a string programmatically like fill-region in elisp?

You can insert the string into a temporary buffer, fill the region, and read the contents of the buffer as a string: (defun fill-string (s) (with-temp-buffer (emacs-lisp-mode) (insert s) ...
NickD's user avatar
  • 33.6k
3 votes
Accepted

Want to Alt-Q on a long piece of text - but it has no spaces so it doesn't work

Go to the beginning of the line, start a keyboard macro, advance 80 chars (C-U 80 C-F), add a return, finish the macro and then repeat it as many times as needed. See keyboard macros. Cheers, Peter....
Peter Frings's user avatar
3 votes

org-fill-paragraph in a list with checkboxes doesn't take into account the checkboxes

The key is to play with adaptive-fill-function which should return a fill-prefix, a string which prefix newlines of the filled item. It will work because the call chain is org-fill-paragraph > org-...
Firmin Martin's user avatar
3 votes
Accepted

Org-mode paragraph-start not respected

You are trying to use full stops . as bullets. Org mode recognises -, + as unordered list item characters at the beginning of the line. (Try pressing Shift and right arrow with cursor on a list item ...
Heikki's user avatar
  • 3,096
3 votes
Accepted

Prevent fill-paragraph from wrapping past horizontal rules

You can add the following lines to your init-file. Additionally to the default setting, they define lines consisting of at least two equal non-alphanumerical characters as paragraph start and ...
Tobias's user avatar
  • 33.7k
3 votes
Accepted

Is it possible to tune `fill-paragraph` to balance the lines?

avoid typographic widows, i.e. a single word on a line. If you just want to avoid single word lines, then see user option fill-nobreak-predicate and its standard option fill-single-word-nobreak-p ...
phils's user avatar
  • 53.1k
3 votes
Accepted

`fill-paragraph` prevent breaking

I wanted dalanicolai to fix his answer but he didn't do it (see my first and my second comment). So, I give here my own answer. One surpresses filling if one finds the tag starter in a backward search ...
Tobias's user avatar
  • 33.7k
2 votes

How to have fill-paragraph/fill-region break the line after a period?

I'm referring to Emacs Wiki to answer your question. Paragraph Boundaries By default, text-mode assumes that empty lines separate paragraphs. The boundaries of paragraphs are determined by two ...
Prasanna's user avatar
  • 1,590
2 votes
Accepted

fill-paragraph marks file as changed, even if it didn't do anything

Note that this is fixed for newer Emacsen (v.26 upwards).
clemera's user avatar
  • 3,476
2 votes

Format help buffers to specific width

temp-buffer-show-hook should help. That's where help-mode-finish is called, for instance. It is used in with-help-window and with-temp-buffer-window, which are used to display Help windows.
Drew's user avatar
  • 79.1k
2 votes
Accepted

What is this M-q behaviour in Emacs 26.1 message mode

With the default settings M-q effectively calls function message-fill-paragraph in message-mode. message-fill-paragraph acts differently for the header part and the rest of the message. The fill ...
Marco Wahl's user avatar
  • 2,916
2 votes

fill-paragraph does not honor fill-column

Filling is a general facility which can depend on more than just the fill-column variable, however the first thing to test is simply that you're checking the fill-column value for the correct buffer --...
phils's user avatar
  • 53.1k
2 votes

Specify a block of text that should not be filled (leave it "verbatim")?

Polymode Polymode might serve your purpose here. It supports editing documents that combine code in different languages. It does a lot more than just let you tweak autofilling, so it might be worth ...
Tyler's user avatar
  • 22.8k
2 votes

How does one do the reverse of fill-region / fill-paragraph in emacs?

I've been using this from the Emacs wiki: (defun my-unfill-paragraph (&optional region) "Make multi-line paragraph into a single line of text. REGION unfills the region. See URL `https://...
Lorem Ipsum's user avatar
  • 4,577
2 votes
Accepted

How can I avoid fill-paragraph in org-mode?

While the answer by NickD does exactly what is asked, I'd recommend enabling visual-line-mode instead: (add-hook 'org-mode-hook 'visual-line-mode) This also sets (setq truncate-lines nil), but in ...
orgtre's user avatar
  • 1,130
2 votes

`fill-paragraph` prevent breaking

EDIT This answer provides an incorrect solution (see @Tobias his comments and answer), but I leave it here as an example of a faulty solution, and for the explanation why (via Tobias his comments and ...
dalanicolai's user avatar
  • 7,985
1 vote

How to detect if a paragraph has been filled?

Here is an ugly hack that works for me: (defun fill-paragraph-p () (let ((hash (buffer-hash)) result) (save-excursion (fill-paragraph nil t) (setq result (equal hash (buffer-...
Firmin Martin's user avatar
1 vote

How to properly fill a whole Org buffer programmatically?

This seems to give the expected result for me: (defun custom-org-fill () (interactive) (save-excursion (org-with-wide-buffer (cl-loop for el in (reverse (org-element-map (org-...
John Kitchin's user avatar
  • 12.1k
1 vote
Accepted

org-fill-paragraph doesn't comply with org-list-allow-alphabetical

As @NickD pointed out and per the documentation: This variable needs to be set before org.el is loaded. If you need to make a change while Emacs is running, use the customize interface or run the ...
Firmin Martin's user avatar
1 vote
Accepted

From one-line list to one element per line in python-mode

You can always write a function to do what you want and bind it to a key sequence. The following will deal with the vast majority of cases, but it will fail if a list element contains the string "...
NickD's user avatar
  • 33.6k
1 vote
Accepted

(Sudden) Weird behavior of M-q in auctex

Entries in LaTeX-indent-environment-list control the filling behavior in environments. If you want the standard filling AUCTeX applies to environments, remove entries for your appendices from it and ...
Arash Esbati's user avatar
  • 2,100
1 vote

How to prevent LaTeX verbatim environments to be subject to LaTeX-fill-region

In case you're using fancyvrb.sty to define your custom environment, you only need to hit C-c C-n and let AUCTeX parse your document. AUCTeX has a sophisticated style file for fancyvrb.sty which ...
Arash Esbati's user avatar
  • 2,100
1 vote

is there a fill paragraph with bullets combo command for emacs

Wrapping the paragraphs is simple: C-x h M-q (mark the whole buffer, fill paragraphs). Adding the bullets is not a built-in capability in text-mode, but can be accomplished a few ways. You could ...
glucas's user avatar
  • 20.9k
1 vote

Unfill `mu4e` message before sending

This works approximately: (defun unfill-email-body () (let ((fill-column most-positive-fixnum) (top )) (mu4e-compose-goto-top) (setq top (point)) (mu4e-compose-goto-bottom) ;; ...
John Kitchin's user avatar
  • 12.1k

Only top scored, non community-wiki answers of a minimum length are eligible