1

This is more or less a question of putting the answer from Make web-mode always indent with spaces into the use-package declaration.

I want to set tab indent to 2 spaces, and use the spaces throughout the lines, even when reaching 8 spaces etc.

This is my effort so far, I've tried both setq and setq-default, and I've tried to put the init code in either :config or :init, but it's not working. When I "describe variable", tab-width is always 8 in the .go file that I'm opening.

(use-package go-mode
  :mode "\\.go\\'"
  :config
  (progn
    (setq-default tab-width 2)
    (setq-default indent-tabs-mode nil)
    ;; tab-width & indent-tabs-mode are both buffer-local so need setq-default
    )

  :init
  (progn
    (setq-default tab-width 2)
    (setq-default indent-tabs-mode nil)
    )

  )
2

The most go specific way to do it is using a go-mode-hook.

In your :config add something like (add-hook 'go-mode-hook (lambda () (setq tab-width 2))) That way you set it for every go buffer you open.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.