Ste*_*gle 7 python emacs comments
我喜欢任何评论都出现在自己的路线上.我不喜欢在代码所在的同一行上发表评论.在某些语言中,您可以编写注释块,例如:
/**
* I am a comment block. This comment block will be automatically expanded by the
* IDE such that it can contain all of the text in this block.
**/
Run Code Online (Sandbox Code Playgroud)
我喜欢.我喜欢评论块如何在我添加更多文本时不断获得更多行.我喜欢如果我在块中的某个任意点插入文本,后续文本将向下移动,以便没有文本超出某个点到右边.我用Python.Python没有多行块注释.我想你能得到的最接近的是:
# I am a comment block. This comment block will NOT be automatically expanded by
# the IDE, because it does not recognize these two comment lines as being joined.
Run Code Online (Sandbox Code Playgroud)
我也使用emacs.我只是想知道是否有人有一些聪明的解决方案,以便他们可以打开一个评论块,然后开始输入.当注释行的宽度太大时,不必担心必须按返回跳转到下一行.当您希望在注释块中插入时,无需重新整理注释.有任何想法吗?
简介:我正在寻找一种在emacs中进行多行连续注释(对于Python)的方法,而不必手动格式化注释块本身的文本.
谢谢
auto-fill-mode似乎做你想做的事。当行的长度超过该值时,fill-column它会中断该行并插入新的注释行。
但它不是全自动的,如果在两者之间插入文本,您将必须按M-q才能重新填充。
[编辑:这是一种使“空格”命令智能化的方法。每次您按下 SPC您的评论块都会被重新填充:
(defun refill-when-in-comment ()
(interactive)
(let ((curr-face (get-char-property (point) 'face)))
(if (member "comment" (split-string (prin1-to-string curr-face) "-"))
(fill-paragraph t)
)
)
)
(defun smart-space (arg)
(interactive "P")
(refill-when-in-comment)
(self-insert-command (prefix-numeric-value arg))
)
(global-set-key " " 'smart-space)
Run Code Online (Sandbox Code Playgroud)
这对你有用吗?