按';键时,Emacs返回缩进代码行;返回';钥匙
我使用的是emacs 22.2.1和Ubuntu 9.04 我已经在.emacs文件中这样做了。每次我按“;”时缩进并创建新行或{}按';键时,Emacs返回缩进代码行;返回';钥匙,emacs,Emacs,我使用的是emacs 22.2.1和Ubuntu 9.04 我已经在.emacs文件中这样做了。每次我按“;”时缩进并创建新行或{} if(success == 0) { printf("Success\n"); <---- if I press return key here it will go <-- to here, and I have to tab to go to the code line. 映射返回到换行+缩进。或者,如果您愿意,您可以养成键入C-
if(success == 0)
{
printf("Success\n");
<---- if I press return key here it will go
<-- to here, and I have to tab to go to the code line.
映射返回到换行+缩进。或者,如果您愿意,您可以养成键入C-j而不是return的习惯,因为C-j已经映射到此函数。找到它的方法是
- 知道C-j做你想做的事
- 使用C-h k C-j找出C-j映射到
换行和缩进
- 在EMACS信息中查找重新映射键
prog mode hook
“发现的方法是[…]知道[某件事]。”如果ad homeem是老狗反驳的方式,我希望我永远是一只小狗。
(require 'cc-mode)
;; Auto indent on insertion of a curly brace
(add-hook 'c-mode-hook '(lambda()
(c-toggle-auto-state t)))
;; Set coding style to indent 4 spaces
(setq c-default-style "bsd"
c-basic-offset 4)
(add-hook 'c-mode-hook
'(lambda ()
(define-key c-mode-map "\C-m" 'newline-and-indent)))