In go-mode, inside a rune hitting the tab key doesn't add the tab character.


var foobar = `
If I place the point at the start of this line and press tab it wouldn't add the tab character :(
var barfoo = 1 // I expect the tab character not to be added if I do the same  here

How can I get this behavior?

Trying what's proposed here doesn't do it.

  • 1
    As last resort you can always insert a tab character by typing C-q TAB.
    – Tobias
    May 27, 2016 at 13:43
  • What does M-: (nth 3 (syntax-ppss (point))) say when point is where you want to insert the tab character?
    – Tobias
    May 27, 2016 at 13:47
  • It is likely that you did something wrong when installing emacs.stackexchange.com/a/19807/8223. Put the defun and the add-hook into your initialization file, maybe re-compile the file, then restart emacs and try again. (Note, the restart is actually not required. But I added it here to make sure that you restart everything. (E.g., restart go-mode for the go-file after you installed the hook.)
    – Tobias
    May 27, 2016 at 13:58
  • Result of the command: 96 (#o140, #x60, ?`)Restarting Emacs I do as last resort and I my least preferred. (E)Lisp is powerful enough to provide a solution. @Tobias. +1 to C-q TAB but inconvenient. May 27, 2016 at 15:23
  • 1
    If you do this with the go file already loaded you need to do M-x normal-mode afterwards to run the hook functions.
    – Tobias
    Jun 9, 2016 at 18:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.