将emacs ruby​​-mode缩进更改为4个空格 [英] change emacs ruby-mode indent to 4 spaces

查看:157
本文介绍了将emacs ruby​​-mode缩进更改为4个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从上一篇文章我得到了Ruby模式在emacs中工作。这是非常好的



设置用于mac ruby​​开发的.emacs文件



我们公司使用4个空格缩进,而不是默认值2.我无法使此工作。



这是我的.emacs文件


(add-to-list'



(require'ruby-mode)



(setq indent-tabs-mode nil);总是用空格替换标签



(setq-default tab-width 4);将所有缓冲区的标签宽度设置为4


有没有人看到我做错了什么?



谢谢!

解决方案

tab-width 仅控制制表符的宽度,即在缓冲区中显示时,Tab字符等于多少空格。它不影响用于缩进代码的空格(或制表符)数量。



对于Ruby代码,缩进由 ruby​​控制-intent-level 变量:

 (setq ruby​​-indent-level 4)


From a previous post I got Ruby mode working in emacs. This is working great.

Setting up .emacs file for mac ruby development

Our company uses 4 spaces for indents though instead of the default 2. I am having difficulty getting this to work.

Here is my .emacs file

(add-to-list 'load-path "~/rdoc-mode.el")

(require 'ruby-mode)

(setq indent-tabs-mode nil) ; always replace tabs with spaces

(setq-default tab-width 4) ; set tab width to 4 for all buffers

Does anyone see what I am doing wrong?

Thanks!

解决方案

The tab-width setting only controls the width of a tab character, i.e. how many spaces a tab character is equivalent to when displayed in your buffer. It does not affect the number of spaces (or tabs) used for indenting your code.

For Ruby code, the indentation is controlled by the ruby-indent-level variable:

(setq ruby-indent-level 4)

这篇关于将emacs ruby​​-mode缩进更改为4个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆