是否存在 M-q 的倒数,某种unfill-paragraph-function
?
如果我有撤消数据,那么它当然很容易。我要求的是在我刚从磁盘读取文件后立即将段落中的行合并为单个长行的能力。这样就可以将文本粘贴到一个表格(网页表格等)中,期望每个段落都有一个换行符。
过去我关闭了auto-fill
,创建了一个宏来删除EOL并移动到下一行,并重复应用它,但这很累人。
答案 0 :(得分:23)
Here's the answer。简而言之:
(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)))
答案 1 :(得分:8)
另见M- ^(删除缩进)。
它将当前行连接到上一行,因此如果从段落的最后一行开始,可以按M- ^直到所有行都连接起来。
答案 2 :(得分:1)
我第一次使用@ sanityinc的解决方案一段时间,直到我遇到Stefan Monnier's Unfill Paragraph in EmacsWiki。看起来更健壮了
;;; Stefan Monnier <foo at acm.org>. It is the opposite of fill-paragraph
(defun unfill-paragraph (&optional region)
"Takes a multi-line paragraph and makes it into a single line of text."
(interactive (progn (barf-if-buffer-read-only) '(t)))
(let ((fill-column (point-max))
;; This would override `fill-column' if it's an integer.
(emacs-lisp-docstring-fill-column t))
(fill-paragraph nil region)))
;; Handy key definition
(define-key global-map "\M-Q" 'unfill-paragraph)
M-Q
键绑定使命令变得更加容易。
答案 3 :(得分:0)