<p>如果您使用的是<a href="http://www.vim.org/" rel="noreferrer">Vim</a>,请参见<a href="http://vimdoc.sourceforge.net/htmldoc/change.html#:retab" rel="noreferrer">^{<cd1>}</a>。</p>
<pre> *:ret* *:retab*
:[range]ret[ab][!] [new_tabstop]
Replace all sequences of white-space containing a
<Tab> with new strings of white-space using the new
tabstop value given. If you do not specify a new
tabstop size or it is zero, Vim uses the current value
of 'tabstop'.
The current value of 'tabstop' is always used to
compute the width of existing tabs.
With !, Vim also replaces strings of only normal
spaces with tabs where appropriate.
With 'expandtab' on, Vim replaces all tabs with the
appropriate number of spaces.
This command sets 'tabstop' to the new value given,
and if performed on the whole file, which is default,
should not make any visible change.
Careful: This command modifies any <Tab> characters
inside of strings in a C program. Use "\t" to avoid
this (that's a good habit anyway).
":retab!" may also change a sequence of spaces by
<Tab> characters, which can mess up a printf().
{not in Vi}
Not available when |+ex_extra| feature was disabled at
compile time.
</pre>
<p>例如,如果您只是键入</p>
<pre>
:ret
</pre>
<p>所有标签页都将展开到空格中。</p>
<p>你可能想</p>
<pre>
:se et " shorthand for :set expandtab
</pre>
<p>以确保任何新行都不会使用文字制表符。</p>
<hr/>
<p>如果你不使用Vim</p>
<pre>
perl -i.bak -pe "s/\t/' 'x(8-pos()%8)/eg" file.py
</pre>
<p>将用空格替换制表符,假设制表符每8个字符停止一次,在<code>file.py</code>中(为了以防万一,原始制表符将转到<code>file.py.bak</code>)。如果您的止动块是每4个空格,则将8s替换为4s。</p>