Even if Vim did this, you would still have to figure out what settings were used to create the file, in order to set tabstop the
first time. A better approach might be to write a VimL function to be called from an autoevent, whose job is to guess at the
settings. It could look for lines containing sequences of more than 1 space. The assumption would be that sequences of spaces are
used to achieve tabstop alignment. The function could have an array or map of possible tabstop values, say from 1-8, and could
continue doing tab alignment computations on the aforementioned lines until (hopefully) all of the tabstop values but one have been
ruled out (i.e., the corresponding flag in the array or map has been set or cleared). Multiple lines would need to be checked in the
general case, with each remaining tabstop value tested for each, since a tabstop value of 2 or 4 or 8 might work for some lines, but
hopefully not for all. A tabstop value of 3 would most likely be found more quickly... Anyways, I haven't tried this, but I'm
guessing the algorithm wouldn't be very complicated, and would probably be able to guess fairly reliably. A more robust algorithm
could be devised, which would allow for some lines that are not aligned correctly. In this approach, binary flags would not be
sufficient, since a single line for which a tabstop value doesn't work would not be sufficient to rule that tabstop value out.
Rather, there would be a sort of weighting for each possible tabstop value, and the "best-fit" would be used...
Brett Stahlman
----- Original Message -----
From: "Yakov Lerner" <[EMAIL PROTECTED]>
To: "Eric Arnold" <[EMAIL PROTECTED]>
Cc: "Vim mailing list" <[email protected]>
Sent: Sunday, April 09, 2006 6:05 AM
Subject: Re: persistent tabstop per-file ? (viminfo)
On 4/9/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
--- Yakov Lerner <[EMAIL PROTECTED]> wrote:
> Some of the files I use are 8-tabbed, some are 4-tabbed.
> These files are readonly, so modelines are not an option.
> (I am talking about \t tabs, not about vim7 tabpages).
>
> Viminfo remembers last position in the file. When I
> reopen file, vim remembers last position.
>
> Is there any way to tell vim to remember the last tabstop-related
> options per file in the viminfo ?
If you use the
" vim6:fdm=marker:foldenable:ts=4:sw=4
This thing is called "modeline". I can't modify those files so I
can't use modelines for then (when I can use modelines, I use them).
For some files I cannot use modelines. Then I manually set
tab-related options (via shortcut mappings). I just thought
why would vim not remember tabbing-related options in the
viminfo ?
Yakov
mappings