反向M-q,一个不完整的段落功能 [英] Inverse of M-q, an unfill-paragraph-function
问题描述
Mq 是否相反,某种 unfill-paragraph-function
?
如果我有撤消数据,那当然很简单。我要求的是将段落中的行合并为单个长行的能力,就在刚刚从磁盘读取文件之后。这样可以将文本粘贴到一个表单(一个Web表单等)中,这个表单预期每个段落都有一个换行符。
If I have undo data, then it's of course easy. What I am asking for is instead the ability to merge lines in a paragraph into a single long line, right after I have just read the file from disk. This would make it possible to then paste the text into a form (a web form and the like) that is expecting a single linebreak for each paragraph.
在过去我已经关闭了自动填充
,创建了一个宏来删除一个EOL并移动到下一行,并重复应用,但这是越来越累。
In the past I have turned off auto-fill
, created a macro to delete an EOL and move to the next line, and applied it repeatedly, but this is getting tiring.
推荐答案
这是答案。简而言之:
(defun unfill-paragraph ()
"Replace newline chars in current paragraph by single spaces.
This command does the reverse of `fill-paragraph'."
(interactive)
(let ((fill-column 90002000))
(fill-paragraph nil)))
(defun unfill-region (start end)
"Replace newline chars in region by single spaces.
This command does the reverse of `fill-region'."
(interactive "r")
(let ((fill-column 90002000))
(fill-region start end)))
更新:我打包了这个这里,它可以请从果酱门户或 Melpa 安装。
Update: I've packaged this up here and it can be installed from Marmalade or Melpa.
这篇关于反向M-q,一个不完整的段落功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!