函数delete-indentation通常绑定到(M- ^),将当前行连接到下一行并删除任何缩进。
如何将此功能应用于整个区域以连接区域中的多个线? 或者还有另一种方法可以达到预期的效果吗?
由于
答案 0 :(得分:4)
尝试unfill-paragraph
,取自Emacs wiki。
;;; An unfill-paragraph that works in lisp modes
(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))
(emacs-lisp-docstring-fill-column t))
(fill-paragraph nil region)))
如果您愿意放弃标准 M - ^ 的前缀参数,您可以将以下函数绑定到该键盘快捷键,如下所示:
(defun join-line-or-unfill-paragraph (&optional unfill)
(interactive "P")
(if unfill (unfill-paragraph) (delete-indentation)))
(global-set-key (kbd "M-^") 'join-line-or-unfill-paragraph)
这样,无论何时在 M - ^ 之前输入 C-u ,都会加入完整的段落。