1

如何按照 GNU 样式在 emacs 中自动格式化 C++ 代码?

有这个自动换行符:https://www.gnu.org/software/emacs/manual/html_node/ccmode/Auto_002dnewlines.html,但即使我将样式设置为 GNU 它也不会将返回值放在单独的从函数名开始。

我还想要在参数列表中的参数之间添加空格的东西。在我写完之后我可以在代码上“运行”一些东西(不仅仅是在我输入的时候移动东西)

4

1 回答 1

2

Already been answered here. There's a tool called astyle (Artistic Style) that formats the code in C++.

(defun astyle-this-buffer (pmin pmax)
  (interactive "r")
  (shell-command-on-region pmin pmax
                           "astyle" ;; add options here...
                           (current-buffer) t 
                           (get-buffer-create "*Astyle Errors*") t))
于 2014-05-31T19:57:48.410 回答