When emacs displays buffer text to the terminal, along with whatever ANSI (or other termcap/terminfo) sequences it uses, it will occasionally use ordinary ASCII TAB characters to move the cursor. Since this is an output operation, its choice to use a TAB will often have nothing whatsoever with whether there is an actual TAB character in the text being edited, or whether I used the TAB key while editing.

The problem is that if the "terminal" emacs is displaying to is a Terminal window on my Mac (as it always is), and if I use the mouse and Mac clipboard to copy some emacs-displayed text somewhere else, those stray tab characters end up in the Mac clipboard, and they tend to paste as tabs, too, with often deleterious results.

If there's a way to, I would like to tell emacs never to use tabs while displaying text to me in its terminal. If that means emacs has to inefficiently use, say, two or more spaces instead of a single tab, or a move-cursor sequence instead of a tab, I am totally fine with that.

(P.S. I realize this sounds like a strange question. You may be wondering why I'm using the mouse cursor and Mac clipboard, instead of (actually as well as) the emacs kill buffer, to copy text. You may be wondering why I'm using terminal-mode emacs at all, instead of window-mode emacs. But I am, and I am, because that's the way I like it. And I'll like it even more if I can get those stray tabs out of the picture, because they really do get in the way sometimes.)

  • Hmm, maybe this is controlled by the terminfo database? In that case you might be able to create a custom entry. (Unfortunately, how you do that is outside my area of knowledge.) Commented Jan 8, 2022 at 15:22

1 Answer 1


Not as far as I know. Note that there are also conditions where tabs in the buffer will be replaced with spaces.

Your Answer

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

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