我安装了emacs C#模式.
.emacs文件如下
(require 'csharp-mode)
(setq auto-mode-alist
(append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
(defun my-csharp-mode-fn ()
"function that runs when csharp-mode is initialized for a buffer."
(setq default-tab-width 4)
)
(add-hook 'csharp-mode-hook 'my-csharp-mode-fn t)
它工作得很好,但我看到块({..})与我的意图一致.我的意思是,在某些情况下,我有这个.
private static int StringCompare(string x, string y)
{
int result;
if (x == null)
{
}
}
Run Code Online (Sandbox Code Playgroud)
当我期待这个
private static int StringCompare(string x, string y)
{
int result;
if (x == null)
{
}
}
Run Code Online (Sandbox Code Playgroud)
与此同时,我总是有2个代码缩进,但我希望它是4.
我的问题是
我在Mac OS X/mono上使用emacs C#模式.
我发现C#模式也可以使用C模式,所以Mx c-set风格的作品,awk风格适合我.问题是每当我使用c模式时我都必须打开awk模式.有没有办法在c模式下自动运行"Mx c-set-style和awk"模式?
Ada*_*eld 10
将这些行添加到您的my-csharp-mode-fn:
; Set indentation level to 4 spaces (instead of 2)
(setq c-basic-offset 4)
; Set the extra indentation before a substatement (e.g. the opening brace in
; the consequent block of an if statement) to 0 (instead of '+)
(c-set-offset 'substatement-open 0)
Run Code Online (Sandbox Code Playgroud)
或者,您可以将它们添加到公共C模式钩子中,该钩子运行所有与C模式相关的模式:C,C++,Objective-C,Java,C#等:
(defun my-c-mode-common-hook ()
(setq c-basic-offset 4)
(c-set-offset 'substatement-open 0))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Run Code Online (Sandbox Code Playgroud)
有关自定义缩进的详细信息,请参阅CC模式文档.
| 归档时间: |
|
| 查看次数: |
3534 次 |
| 最近记录: |