2

Currently pressing TAB in evil insert mode, runs indent-for-tab-command

I'm not sure of the exact details, but from what I can tell this is performing some kind of re-indentation, which does nothing if emacs consideres the text already indented.

I would like this to behave (like vim) where.

  • When tabs are enabled a \t is inserted *.
  • When tabs are disabled, insert n spaces, aligning to the tab-width.

Is this possible?


* by tabs enabled I mean (setq indent-tabs-mode t).

  • 2
    Why not embrace Emacs and its smart indentation? Each mode is free to set it to something smarter than indent-relative and this makes for less tab key usage if it's configured properly. You can do the same by overriding the indentation function for modes that don't behave. – wasamasa Oct 17 '16 at 6:26
  • ^ this. Also, you might want to check this article out by Xah Lee – Chakravarthy Raghunandan Oct 17 '16 at 6:33
  • @wasamasa: Vim/Evil have the = operator for that. – Erik Jan 10 '17 at 4:33
4

To have tab work as it does in VIM, use tab-to-tab-stop.

(define-key evil-insert-state-map (kbd "TAB") 'tab-to-tab-stop)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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