相比于VIM,emacs在默认配置下写C代码还真是不好用。
好多东西都要调整,其中最麻烦的就是缩进。调啊调,调了好久。
勉强形成一个配置如下:

(add-hook 'c-mode-hook
	  (lambda ()
	    (fci-mode)
	    (display-line-numbers-mode)
	    (line-number-mode)
	    (column-number-mode)
	    (whitespace-mode)
	    (setq c-default-style
		  '((java-mode . "java")
		    (awk-mode . "awk")
		    (other . "linux")))
	    (setq c-basic-offset 4)
	    (setq tab-width 4)
	    (setq backward-delete-char-untabify-method nil)))

其中需要注意的是,那两个4都要相等才能生效。
见文档:https://dougie.io/emacs/indentation/

最后,来个效果图:
[emacs] emacs调整C代码的缩进格式等

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
猜你喜欢
  • 2021-05-29
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案