I understand how Emacs can remove tabs when using the untabify command (simply place a number of spaces in the place of the tabs) but what I can't understand is how does it place tabs in the place of spaces? When you use tabify how does Emacs knows where to place tabs? At first I thought that if there were 4 spaces (or a particular number) then it would change them with one tab but clearly that is not the case (as I saw using whitespace-mode). Clearly it is logical that this doesn't happen but if that is not the case then how does Emacs decides where should tabs be?

1 Answer 1


From the description of tabify:

A group of spaces is partially replaced by tabs when this can be done without changing the column they end at.

So it seems like it's behaviour depends on tab-width variable.


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.