John Beckett wrote:
> Tim Chase wrote:
>>> http://vim.wikia.com/wiki/Super_Retab
>> ...
>> My vote is to scrap it and use my above commands :)
>
> Thanks Tim. After pondering, I can understand your code! It does seem
> that someone contributed the "solution" I posted, but it is actually
> broken.
Hopefully it's not too painful...the basic steps are:
1) find all the whitespace-of-interest at the beginning of the line
2) replace each tab/N-spaces in that leading whitespace with
the corresponding number of spaces or a tab
The exec() is used to hack in the tabstop setting. I think it's
only the Space2Tab that needs the exec, as the Tab2Space may be
writable as
command! -range=% -nargs=0 Tab2Space
<line1>,<line2>s/^\t\+/\=substitute(submatch(0), '\t',
repeat(' ', &ts), 'g')
This substitute command makes it pretty clear what it's doing.
> What do you think of the first solution in the tip (one line):
>
> command! -range=% -nargs=1 Space2Tab
> <line1>,<line2>s/\v%(^ *)@<= {<args>}/\t/g
It seems to work, though it's a bit mystical (or should I say
it's "very magical") to the uninitiated. I also prefer to have
the command sniff the &tabstop setting over manually specifying
the number of spaces to use.
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---