Книга: Learning GNU Emacs, 3rd Edition

7.1.6 Changing Tabs to Spaces (and Vice Versa)

7.1.6 Changing Tabs to Spaces (and Vice Versa)

We've just talked about a way to make sure that Emacs inserts spaces instead of tabs. But what if you inherit a file and it has tabs that you want to change to spaces?

Emacs provides a command to banish tabs from your files. You can use tabs for editing and then convert all of the tabs to the appropriate number of spaces so that the appearance of your file doesn't change. Unlike tabs, a space is almost always well defined. The command for eliminating tabs is M-x untabify. There's a corresponding command to convert spaces into tabs: tabify. However, we trust that you'll take our advice and forget about it.

The untabify command works on a region. Therefore, to use it, you must put the mark somewhere in the buffer (preferably at the beginning), move to some other place in the buffer (preferably the end), and type M-x untabify Enter. The command C-x h (for mark-whole-buffer) automatically puts the cursor at the beginning of the buffer and the mark at the end. It makes untabification a bit easier because you can do it all at once with the simple sequence C-x h M-x untabify Enter.

Table 7-1 shows the tab commands we've covered in this section.

Table 7-1. Tab commands

Keystrokes Command name Action
(none) edit-tab-stops Open a buffer called *Tab Stops* where you can change the tab settings.
(none) untabify Change all tabs into the equivalent number of spaces.
(none) tabify Change groups of three or more spaces to tabs where possible without affecting the text placement.

Оглавление книги


Генерация: 1.214. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз