Nic*_*out 18
您可以使用以下代码:
(setq fill-column 72)
(setq comment-auto-fill-only-comments t)
(auto-fill-mode t)
Run Code Online (Sandbox Code Playgroud)
这将自动包装文本,仅用于注释,并且每次执行换行时都会插入注释字符.
我只为编程模式设置如下:
(defun my-prog-mode-hook
(setq fill-column 72)
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(auto-fill-mode t))
(add-hook 'prog-mode-hook 'my-prog-mode-hook)
Run Code Online (Sandbox Code Playgroud)
这确保了如果我在非编程模式(如AUCTeX)中打开自动填充模式,所有文本都会被包装,而不仅仅是注释.