对于Markdown, org, latex, 同不建议写超长行。
有传说中的爷爷一样老的auto-fill mode可以用,设个舒服的fill-column的值(每行最多字数),比如80,到了超出你点空白字符键时就会自动加回车换行。当你进行插入或者删除等修改操作后,变得各行不齐时,在当前段落任何位置,按下M-q就又重新排齐啦。
我是被老板安利的,主要这玩意儿太老了,除非看书,根本不会注意到。我之前衣纠结过很久,知道用了它。我写长邮件草稿都用Emacs了,为了换行和对齐方便。
另附上把自动换行对齐为多个行在段落重新转成一个超长行:
;; unfill paragraph: the opposite of fill-paragraph
(defun y:unfill-paragraph-or-region (&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)))
(define-key global-map "\M-Q" 'y:unfill-paragraph-or-region)