ethereum / emacs-solidity

The official solidity-mode for EMACS
GNU General Public License v3.0
205 stars 66 forks source link

change indent in solidity mode #65

Closed bgits closed 3 years ago

bgits commented 3 years ago

Many solidity projects use 2 indents now and solidity-mode seems to default to 4. How can it be changed to 2?

LefterisJP commented 3 years ago

Since solidity mode is just another emacs language mode you can customize it like any other language mode for things like indentation: https://www.gnu.org/software/emacs/manual/html_node/efaq/Customizing-C-and-C_002b_002b-indentation.html

december1981 commented 2 years ago

Don't know if it helps, but my solidity configuration uses 2 indents, and looks like this

;; NB: Hitting C-c C-s on the line you want to indent will
;; indicate which syntax mode affects indentation (defun-block-intro, statement-block-intro, etc.)
(defun my-solidity-mode-hook ()
  (c-set-offset 'defun-block-intro 2)
  (c-set-offset 'statement-block-intro 2)
)
(add-hook 'solidity-mode-hook 'my-solidity-mode-hook)