摆弄
comment-dwim
可能握错了棍子的一端。为了我,
M-;
自动插入两个空格,“#”字符和一个空格,然后放置点。如果它没有为您这样做,那么您可能在其他地方重新配置了它,可能是偶然的。
我建议另一种选择是启用“保存时格式化”选项,这将为您做到这一点,而不会在您的
.emacs
或使用自定义。
(use-package python-black :after python
:hook (python-mode . python-black-on-save-mode)
:bind ("C-c p C-f" . 'python-black-buffer))
我使用
black
,但任何替代格式化程序都应该执行相同的操作。我从不担心文件的格式,因为
黑色
自动为我修复它。
来自的文档
黑色
:
Black does not format comment contents, but it enforces two spaces
between code and a comment on the same line, and a space before the
comment text begins.