change emacs ruby-mode indent to 4 spaces

前端 未结 3 1175
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 20:31

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 in

3条回答
  •  天涯浪人
    2021-01-17 21:16

    The other posters have provided the correct answer, so I'll mention here how to figure out the answer to this kind of question.

    First of all, since you correctly assumed that the indent width would be configurable, the first thing to try is:

    M-x customize-group RET ruby-mode RET
    

    And sure enough, one of the customization options there is "Ruby Indent Level". You can set it and save the changes. Done!

    Alternatively, you can look at ruby-mode itself:

    M-x find-library RET ruby-mode RET
    

    Then search (with C-s) for 'indent'. There you'll find a variable definition:

    (defcustom ruby-indent-level 2 ...)
    

    When you find a variable like that, you can set it in your .emacs (or ~/.emacs.d/init.el) with setq:

    (setq ruby-indent-level 4)
    

    You could also discover that variable using apropos:

    M-x apropos RET indent ruby RET
    

    That's why emacs is described as "self-documenting"!

提交回复
热议问题