On 4/21/06, Gerald Lai <[EMAIL PROTECTED]> wrote:
> There's a general dislike for tabs because it is editor-dependent. I
> only seem to find use for them in Makefiles.

Only the tabstop should be editor dependant. I follow the philosophy
of here:  http://derkarl.org/why_to_tabs.html - using tabs to indent
code but using spaces for formatting. This is also useful if code must
every be printed as the whole lot can be compressed by e.g. set
tabstop=1 or 2

> > b) is there a way of making the substitution automatically re-run
> > itself until no more possibilities exist?
>
> Yes, a repeated search & replace follows the format:
>
>    :g/<search>/wh getline(".")=~@/|s//<replace>/|endw
>
> Here's a suggestion to what you may want:
>
>    :g/^\t*\zs[ ]\{1,4}/wh getline(".")=~@/|s//\t/|endw
>
> where 4 is what you set 'tabstop' to. See ":help 'tabstop'".

> the following commands replace leading spaces by tabs according to the
> current value of the 'tabstop' option
>
>  :%s/^ \+/\=substitute(submatch(0), repeat(' ', &tabstop), "\t", 'g')
>
>  :%s/^ \+/\=substitute(submatch(0), ' \{' . &tabstop . '\}', "\t", 'g')
>
> The first command only works in VIM 7.0 due to the use of the new
> repeat() function, but the second one should work in all versions.
>
> Regards,
> Jürgen

Thanks to both.

Reply via email to