如何评论区域内的所有行

use*_*343 1 emacs

Emacs尝试使用其注释函数变得聪明,以便空白的行不会获得注释前缀.是否有一种简单的内置方式可以确保在我调用类似内容时所有行(空白或不空白)都会被注释comment-region?所以,如果我有这个代码:

Comment comment comment

More comments more comments
Run Code Online (Sandbox Code Playgroud)

假设注释前缀是//,我希望能够选择该区域,并使注释看起来像:

// Comment comment comment
// 
// More comments more comments
Run Code Online (Sandbox Code Playgroud)

是的,我可以编写一个自定义函数来执行此操作,但它看起来像基本的足够的行为,它可能以某种方式内置.

Tob*_*ght 5

comment-empty-lines是一个定义的变量newcomment.el.
它的价值是零

文档:
如果为nil,comment-region则不会注释掉空行.
如果是t,它总是注释掉空行.
如果eol它只注释空行,如果注释被行尾终止(即为comment-end空).

您可以自定义此变量.