kpp6ta
Last Updated: February 25, 2016
·
3.7K
· eallik
E49c2e77533477d3c7107f029d9d4b09

Nice Emacs go-mode indenting and autoformat

This will give you nice 4-spaces-wide true tabs in go-mode as well as automatic formatting on file save:

(add-hook 'go-mode-hook
          (lambda ()
            (add-hook 'before-save-hook 'gofmt-before-save)
            (setq tab-width 4)
            (setq indent-tabs-mode 1)))
Say Thanks
Respond

2 Responses
Add your response

18902
1032204 100x100

Great! Thanks!

over 1 year ago ·
19833
Freelancer

I don't like auto-formatting on save when working on shared code, as you then need to exclude (or add patch) hunks from commits that differ just in formatting. I was actually looking for un-hooking before-save in clojure-mode. Your tip gave me a hint on how to accomplish this. Thanks!

over 1 year ago ·