Replacing tabs with spaces in Emacs

How to replace tabs with spaces in Emacs?

asked May 13, 2014 by anonymous

1 Answer

Best answer

You can first select the regions of text for converting/replacing, then run

M-x untabify

to replace all tabs with appropriate number of spaces.

There is also a M-x tabify for replacing sequences of spaces to tabs.

There are also commands to convert tabs to spaces or vice versa, always preserving the columns of all non-whitespace text. M-x tabify scans the region for sequences of spaces, and converts sequences of at least two spaces to tabs if that can be done without changing indentation. M-x untabify changes all tabs in the region to appropriate numbers of spaces.

Reference: GNU Emacs Manual.

answered May 13, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost