I need some help trying to clean up this tip:
http://vim.wikia.com/wiki/Super_Retab

The tip offers several solutions to the following problem (in the
following, each '.' represents a space, and '|-------' represents a
tab):

Visually select the following:

..for {
....that;
..}

If you enter command ':call SuperRetab(2)' the text changes to:

|-------for {
|-------|-------that;
|-------}

Version 2 of SuperRetab is:

function! SuperRetab(width) range
  let x = 0
  while x < 10
    exe a:firstline . ',' . a:lastline . 's/^\(~[ ]*\)~[ ]\{' .
      \ a:width . '}/\1\t\2/e'
    let x = x + 1
  endwhile
endfunction

If we assume firstline = 11, lastline = 19 and width == 2, the function
executes the following 10 times:

11,19s/^\(~[ ]*\)~[ ]\{2}/\1\t\2/e

Can someone please decode this for me? What is the tilde doing (match
last substitute?)? Is it a mistake?? Why is there a \1 and \2, yet I can
only see one grouping?

I'd also like ideas for what to do with the tip!

John


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to