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)))
Written by Erik Allik
Related protips
2 Responses
Great! Thanks!
over 1 year ago
·
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Emacs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#