How to undo fill-paragraph in emacs?

后端 未结 2 552
时光说笑
时光说笑 2021-02-13 09:08

I have a text file that is pretty long. Any easy way to \"undo\" a M-q (fill-paragraph) on a file that was written and saved a while ago?

For example, I wan

相关标签:
2条回答
  • 2021-02-13 09:55

    Use the following from my .emacs:

    (defun unfill-paragraph ()
      (interactive)
      (let ((fill-column (point-max)))
        (fill-paragraph nil)))
    
    (defun unfill-region ()
      (interactive)
      (let ((fill-column (point-max)))
        (fill-region (region-beginning) (region-end) nil)))
    

    I can't take credit, I googled this years ago.

    0 讨论(0)
  • 2021-02-13 10:10

    You can set fill-columnn to a really large number, and fill.

    C-u 10000 C-x f M-x fill-individual-paragraphs
    

    Or you can use a little custom function:

    (defun refill-paragraphs-to-be-one-line ()
      "fill individual paragraphs with large fill column"
      (interactive)
      (let ((fill-column 100000))
        (fill-individual-paragraphs (point-min) (point-max))))
    
    0 讨论(0)
提交回复
热议问题