Discussion:
Emacs golang-mode indent setting
Tong Sun
2013-01-20 04:36:03 UTC
Permalink
Hi,

I'm wondering how to set Emacs golang-mode to use 2 as indent level and use
only space (no tab) for indent?
I.e., same as "gofmt -tabs=false -tabwidth=2"?

Thanks

--
Patrick Mylund Nielsen
2013-01-20 05:09:35 UTC
Permalink
Please consider configuring emacs to show tabs as two spaces, i.e. (setq
default-tab-width 2) in your ~/.emacs, then use the default style (go fmt.)
Especially if you are planning to ever share the code.
Post by Tong Sun
Hi,
I'm wondering how to set Emacs golang-mode to use 2 as indent level and
use only space (no tab) for indent?
I.e., same as "gofmt -tabs=false -tabwidth=2"?
Thanks
--
--
magne-nkzjiHSqi6rZJqsBc5GL+
2014-02-13 22:27:57 UTC
Permalink
This seems to work:

(add-hook 'go-mode-hook
(lambda ()
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))
Post by Tong Sun
Hi,
I'm wondering how to set Emacs golang-mode to use 2 as indent level and
use only space (no tab) for indent?
I.e., same as "gofmt -tabs=false -tabwidth=2"?
Thanks
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
gihan karunarathne
2015-02-20 03:55:44 UTC
Permalink
Great. It is formatting with indent size 2, but it uses tabs instead spaces
(on Emacs 24.4). How to avoid it ? (means replace tabs with spaces)
My configuration:
(add-hook 'go-mode-hook
(lambda ()
(add-hook 'before-save-hook 'gofmt-before-save)
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))

Thank you in advance!
Post by magne-nkzjiHSqi6rZJqsBc5GL+
(add-hook 'go-mode-hook
(lambda ()
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tong Sun
2015-02-20 04:10:15 UTC
Permalink
Check out my final solution at

https://github.com/suntong001/emacs.d/

especially,

https://github.com/suntong001/emacs.d/blob/master/lisp/init-code0p.el



On Thu, Feb 19, 2015 at 10:55 PM, gihan karunarathne <
Post by gihan karunarathne
Great. It is formatting with indent size 2, but it uses tabs instead
spaces (on Emacs 24.4). How to avoid it ? (means replace tabs with spaces)
(add-hook 'go-mode-hook
(lambda ()
(add-hook 'before-save-hook 'gofmt-before-save)
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))
Thank you in advance!
Post by magne-nkzjiHSqi6rZJqsBc5GL+
(add-hook 'go-mode-hook
(lambda ()
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))
--
You received this message because you are subscribed to a topic in the
Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/golang-nuts/c176nKcyoDQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...