On Jan 16, 2008 1:15 PM, Ben Schmidt <[EMAIL PROTECTED]> wrote:

>
> >>> - add flexible tab stops, can be used for tables
> >> Bram, do you mean Matthew Winn's patch? It would be super! I hope that
> as it
> >> works, the amount of work to push it to production state will be small
> and this
> >> feature will be be included in vim even without any extra votes ;-)
> >
> > It's slightly buggy at the moment, in that it doesn't correctly update
> > the global values. I need to bring my Linux machine up and have a look
> > at it.
> >
> > Also, it uses the same tabstops over an entire file. An extended idea
> > is to find some way of specifying different tab widths at different
> > parts of the same file, but that means a heap of empty cans and worms
> > all over the place.
>
> I think this is a much bigger problem than tabstops, and not worth
> addressing
> until a true and general solution can be found. The problem is basically
> that of
> having 'context-local' option settings, i.e. options that aren't global,
> nor local
> to a buffer or window, but local to a part of a file. Vim has no way of
> doing this
> though there are a number of occasions where it would be useful, and as
> you say
> there are many cans of worms if this is pursued.
>
> And, to be honest, the need for this is small. If a file uses different
> width tab
> stops for different parts of the file it would either be (1) Vim-specific
> and
> reliant on the Vim variable tabs feature or (2) some mish mash of files
> that
> should be in separate files anyway (i.e. somebody probably catted two
> different
> datafiles together) or (3) use spaces not tabs anyway.
>
> In those rare cases, it's no big deal to change the tabstop settings to
> work on
> the part of the file you're interested in, IMHO, especially if the
> AutoTabs
> command (I forget who provided this) is updated to accept a range (I have
> been
> meaning to do this as it does annoy me that it doesn't at present; often I
> have a
> small amount of paragraph text/comments with no tabs at all followed by a
> table
> and at present the comments push the first tab to the right side of the
> screen all
> the time, and so I delete the comments, run AutoTabs and replace them;
> would be
> much better to select the table and run AutoTabs on just that part).
>
> Ben.
>


I did update it - I don't remember if I posted the updated version or not.


if has("vartabs")
function! AutoVariableTabstop(line1,line2,...)
  let extra = 0
  if a:0 > 0
      let extra = a:1
  endif
  let i = a:line1
  let tabs = []
  while i <= a:line2
    let fields = split(getline(i),"\t",1)
    let i = i + 1
    let f = 0
    while f < len(fields)
      let l = strlen(fields[f])+1+extra
      if (len(tabs) <= f)
          call add(tabs,l)
      else
          if (l > tabs[f])
              let tabs[f] = l
          endif
      endif
      let f = f + 1
    endwhile
  endwhile
  execute "set vts=" . join(tabs,",")
endfunction
command! -nargs=? -range=% AutoTabs call
AutoVariableTabstop(<line1>,<line2>,<args>)
endif

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

Raspunde prin e-mail lui