I like to have leading spaces as tabs, but all spaces after any
non-whitespace character has occurred to be regular spaces.

Unfortunately :retab! performs the spaces->tab substitution throughout the file.

In the past I have got around this by using the following replace
instead (where ^I = tab)

:%s/^\([^I]*\)    /\1^I/g

This replaces sequences of 4 spaces immediately at the start of the
line, or immediately after a number of tabs at the start of the line.
Due to its nature I have to run this several times to achieve the
desired result.

Therefore I have two questions:

a) could we have a variant of :retab that performs this function - I
believe it is a fairly common way of having source code

b) is there a way of making the substitution automatically re-run
itself until no more possibilities exist?

Reply via email to