How to control indentation after an open parenthesis in Emacs

前端 未结 3 2014
孤城傲影
孤城傲影 2020-12-25 13:36

When I use emacs python-mode, if the last character of a line is an open parenthesis it indents the next line just one step in from the indentation of the previous line.

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-25 14:14

    Since ecmascript-mode is based on cc-mode, you can use c-set-offset which allows you to customize any syntactic symbol's offset with the preferred value.

    In your case, go to the point which is indented in the wrong level, hit C-c C-o (or type M-x c-set-offset), accept the suggested symbol (arglist-intro), and set it a new value (e.g. +, the default offset).

    You can also do it programmatically in your dotemacs, for instance, with:

    (add-hook 'ecmascript-mode-hook
              (lambda ()
                (c-set-offset 'arglist-intro '+)
                (c-set-offset 'arglist-close 0)))
    

提交回复
热议问题