Thread: Re: Hard tabsize vs. soft tabsize problem
Cream is a free, easy-to-use configuration of the Vim text editor
Brought to you by:
digitect
From: Steve H. <dig...@mi...> - 2004-10-27 22:26:59
|
From: BG - Ben Armstrong, Oct 27, 2004 4:59 PM > > It seems that in addition to "tab size" and shiftwidth, Cream lacks > the concept of "soft tab" altogether. Indeed. This is slated for a near term release, and shows up on the first page of the TODO as: o Add a Soft Tab option. (Walter Mundt) Note I say "near term". I've been thinking about trying to go to a staggered release cycle of stable and unstable versions. It seems lately my strategy has been to put the big new features in odd releases and then only bug fixes in even ones. Of course this all seems a bit silly to me given the nano-size and importance of Cream, but at least it has been (mostly) keeping me from doing overhauls or big fixes without taking care of some minor or hard-to-fix bugs. :) Thoughts? -- Steve Hall [ dig...@mi... ] |
From: Steve H. <dig...@mi...> - 2004-10-28 20:34:10
|
From: BG - Ben Armstrong, Oct 28, 2004 2:46 PM > On Wed, 2004-10-27 at 18:26 -0400, Steve Hall wrote: > > > > o Add a Soft Tab option. (Walter Mundt) > > How would a cream Soft Tab option play with my ftplugin soft tab > adjustments? I haven't written it yet, but here are my thoughts on Soft Tabstop at the moment: o Will be the coupling of &softtabstop and &shiftwidth. o Won't affect &tabstop or &smarttab. o No default setting. If not set, Cream will assume the same as Tabstop. o Configured in the same basic manner as Tabstop. (Initialization, autocmd per buffer, saved across sessions.) o Optioned in the Settings menu. > Actually, it would still be generally useful even if it were a > global setting that would still need to be overridden in a handful > of filetypes, as the rule is still soft tabs are 3 characters for > most files. Anything you have in cream-user.vim will overwrite Cream settings. Have you ever explored modelines? (:help modeline) These allow a file to have it's own setting, overriding any Vim (or Cream) setting. They are terrific for ensuring all Vim editors use the same formatting, encoding, foldmethods, etc. -- Steve Hall [ digitect mindspring com ] Cream... something good to put in your Vim! http://cream.sourceforge.net |
From: Thomas de G. de L. <deg...@ea...> - 2004-10-28 20:51:12
|
On Thu, 28 Oct 2004 16:34:00 -0400 (EDT) Steve Hall <dig...@mi...> wrote: > o Will be the coupling of &softtabstop and &shiftwidth. > o Won't affect &tabstop or &smarttab. > o No default setting. If not set, Cream will assume the same as > Tabstop. > o Configured in the same basic manner as Tabstop. > (Initialization, autocmd per buffer, saved across sessions.) > o Optioned in the Settings menu. Sounds good. Also, I think there should be a "Use Tabstop value" button in the option dialog. Its effect would not be to simply grab the tabstop value, but to really unset the setting (ie, go back to the default state where only Tabstop is used). -- TGL. |
From: Elias P. <el...@us...> - 2004-10-28 21:58:37
|
Have you ever explored modelines? (:help modeline) These allow a file > to have it's own setting, overriding any Vim (or Cream) setting. They > are terrific for ensuring all Vim editors use the same formatting, > encoding, foldmethods, etc. > Modelines are great, but of not much use if you have to edit code from projects which don't allow polluting files with them. I'm wondering, didn't anybody write a vim script to autodetect the tabstop settings of a file, and use it? It should be quite simple.. just scan through the file, and look for a certain <tab> and <space> pattern in leading whitespace. E.g. if it's always a multiple of 2, 3 or 4 spaces and no tabs, you set the sw and sts to it, and disable tabs. If it's always just tabs, you set sw=sts=ts to the same value (no way to autodetect the value). If it is a mixture of tabs and spaces, it again should be easy to auto-detect both the sw/sts and ts values - e.g. with sw=4 and ts=8, leading whitespace will be "ssss" or "t" or "tssss" or "tt" and so on, with sw=3 and ts=8 it will be "sss", "ssssss", "ts", "tssss", .... And probably it would have to be enabled depending on file types, e.g. i see this working with any programming language, but not with e.g. a makefile. Maybe just have a list of extension for which the script gets activated. Any idea if something like this is available? Else maybe I might try writing something like this - I feel I spend too much time adjusting the tabstop settings with Ctrl-l in cream each time I open up source code files. Oh, and I can only agree to the plan of using the gvim dialog instead of the cream one.. it was the first thing I had put in my cream-user.vim :) -- Elias Pschernig |
From: Steve H. <dig...@mi...> - 2004-10-29 01:51:32
|
On Thu, 2004-10-28 at 17:59, Elias Pschernig wrote: > > Have you ever explored modelines? (:help modeline) These allow a > > file to have it's own setting, overriding any Vim (or Cream) > > setting. They are terrific for ensuring all Vim editors use the > > same formatting, encoding, foldmethods, etc. > > Modelines are great, but of not much use if you have to edit code > from projects which don't allow polluting files with them. True. > I'm wondering, didn't anybody write a vim script to autodetect the > tabstop settings of a file, and use it? It should be quite simple.. > just scan through the file, and look for a certain <tab> and <space> > pattern in leading whitespace. E.g. if it's always a multiple of 2, > 3 or 4 spaces and no tabs, you set the sw and sts to it, and disable > tabs. If it's always just tabs, you set sw=sts=ts to the same value > (no way to autodetect the value). If it is a mixture of tabs and > spaces, it again should be easy to auto-detect both the sw/sts and > ts values - e.g. with sw=4 and ts=8, leading whitespace will be > "ssss" or "t" or "tssss" or "tt" and so on, with sw=3 and ts=8 it > will be "sss", "ssssss", "ts", "tssss", .... And probably it would > have to be enabled depending on file types, e.g. i see this working > with any programming language, but not with e.g. a makefile. Maybe > just have a list of extension for which the script gets activated. > > Any idea if something like this is available? Else maybe I might try > writing something like this - I feel I spend too much time adjusting > the tabstop settings with Ctrl-l in cream each time I open up source > code files. I've not ever seen anything like this, but it would be quite useful. If you wanted to work it up as a Cream add-on, then users could run it over a file with a single mapping rather than have it autocmd each BufEnter. I'd almost want to see it pop up a dialog confirming what it discovered for me to accept or reject, too. Or at least echo to the command line. > Oh, and I can only agree to the plan of using the gvim dialog > instead of the cream one.. it was the first thing I had put in my > cream-user.vim :) It does seem to be a popular topic this week. :) -- Steve Hall [ digitect mindspring com ] Cream... the Vim text editor in sheep's clothing! http://cream.sourceforge.net |
From: BG - B. A. <BAr...@dy...> - 2004-10-29 12:58:28
|
On Thu, 2004-10-28 at 16:34 -0400, Steve Hall wrote: > I haven't written it yet, but here are my thoughts on Soft Tabstop at > the moment: > > o Will be the coupling of &softtabstop and &shiftwidth. > o Won't affect &tabstop or &smarttab. > o No default setting. If not set, Cream will assume the same as > Tabstop. > o Configured in the same basic manner as Tabstop. (Initialization, > autocmd per buffer, saved across sessions.) > o Optioned in the Settings menu. Sounds good. > Anything you have in cream-user.vim will overwrite Cream settings. Fine for establishing the initial default, but doesn't solve the problem of undoing individual autocmd commands. I'm afraid I'll have to live with merging in my cream-autocmd.vim mods in each new release. Is cream-autocmd.vim re-runnable? e.g. if I just drop my version into the vimfiles dir, will it start by clearing old autocmds defined by cream? I took a look through it and didn't see anything that indicated it did, but maybe I'm missing something. If not, then should it? > Have you ever explored modelines? (:help modeline) These allow a file > to have it's own setting, overriding any Vim (or Cream) setting. They > are terrific for ensuring all Vim editors use the same formatting, > encoding, foldmethods, etc. At this time, injecting modelines into the source code is not an option, since the majority of users still don't use cream/vim. Ben |
From: Steve H. <dig...@mi...> - 2004-10-28 21:08:53
|
From: Thomas de Grenier de Latour, Oct 28, 2004 4:50 PM > On Thu, 28 Oct 2004 16:34:00 -0400 (EDT), Steve Hall wrote: > > > > o Will be the coupling of &softtabstop and &shiftwidth. > > o Won't affect &tabstop or &smarttab. > > o No default setting. If not set, Cream will assume the same as > > Tabstop. > > o Configured in the same basic manner as Tabstop. > > (Initialization, autocmd per buffer, saved across sessions.) > > o Optioned in the Settings menu. > > Sounds good. Also, I think there should be a "Use Tabstop value" > button in the option dialog. Its effect would not be to simply > grab the tabstop value, but to really unset the setting (ie, go > back to the default state where only Tabstop is used). Right, I was planning to explain that a 0 or empty value will reset Soft Tabstop to use the Tabstop values, in effect, turning it off. -- Steve Hall [ digitect mindspring com ] Cream... something good to put in your Vim! http://cream.sourceforge.net |
From: Steve H. <dig...@mi...> - 2004-10-29 18:26:47
|
From: BG - Ben Armstrong, Oct 29, 2004 8:58 AM > On Thu, 2004-10-28 at 16:34 -0400, Steve Hall wrote: > > > > Anything you have in cream-user.vim will overwrite Cream settings. > > Fine for establishing the initial default, but doesn't solve the > problem of undoing individual autocmd commands. I'm afraid I'll have > to live with merging in my cream-autocmd.vim mods in each new > release. Is cream-autocmd.vim re-runnable? e.g. if I just drop my > version into the vimfiles dir, will it start by clearing old > autocmds defined by cream? I took a look through it and didn't see > anything that indicated it did, but maybe I'm missing something. If > not, then should it? Theoretically, autocmds added later are run later. Vim creates a list per event when one is added and then each event runs them in order. You can see the list with :autocmd [event]. To overwrite Cream settings you just want to do the same thing Cream does to Vim...load a later autocmd. This is why cream-user.vim loads last (cream-conf.vim loads first). First, create a function that handles your softab settings: function! MySoftab() if &ft == "vim" let stops = 4 elseif &ft == "c" let stops = 8 elseif &ft == "lisp" let stops = 2 else let stops = g:CREAM_TABSTOP endif let &softtabstop = stops let &shiftwidth = stops endfunction Then add the autocmd: autocmd BufEnter,BufNewFile * call MySoftab() and you should be set. Note I have not tested this. :) -- Steve Hall [ digitect mindspring com ] Cream... something good to put in your Vim! http://cream.sourceforge.net |
From: BG - B. A. <BAr...@dy...> - 2004-10-29 18:49:21
|
On Fri, 2004-10-29 at 14:26 -0400, Steve Hall wrote: > First, create a function that handles your softab settings: In cream-user.vim I assume? > function! MySoftab() > > if &ft == "vim" > let stops = 4 > elseif &ft == "c" > let stops = 8 > elseif &ft == "lisp" > let stops = 2 > else > let stops = g:CREAM_TABSTOP > endif > > let &softtabstop = stops > let &shiftwidth = stops > > endfunction > > Then add the autocmd: > > autocmd BufEnter,BufNewFile * call MySoftab() Did that ... > and you should be set. Note I have not tested this. :) Well, it doesn't work for me. I tinkered with it a bit, but couldn't figure out what was wrong. Ben |
From: BG - B. A. <BAr...@dy...> - 2004-10-29 19:16:56
|
On Fri, 2004-10-29 at 15:49 -0300, BG - Ben Armstrong wrote: > > Then add the autocmd: > > > > autocmd BufEnter,BufNewFile * call MySoftab() > > Did that ... > > > and you should be set. Note I have not tested this. :) > > Well, it doesn't work for me. I tinkered with it a bit, but couldn't > figure out what was wrong. I think the issue is that I'm passing a filename to cream from the command line. When I do a cream File -> Open, then the autocmd is invoked. But as I explained earlier, all of our files are edited by passing a file to cream through an external wrapper. If I do this instead, it works: autocmd VimEnter,BufEnter,BufNewFile * call MySoftab() Ben |
From: Steve H. <dig...@mi...> - 2004-10-29 21:51:31
|
From: BG - Ben Armstrong, Oct 29, 2004 3:16 PM > On Fri, 2004-10-29 at 15:49 -0300, BG - Ben Armstrong wrote: > > > > > > Then add the autocmd: > > > > > > autocmd BufEnter,BufNewFile * call MySoftab() [...] > > I think the issue is that I'm passing a filename to cream from the > command line. When I do a cream File -> Open, then the autocmd is > invoked. But as I explained earlier, all of our files are edited by > passing a file to cream through an external wrapper. If I do this > instead, it works: > > autocmd VimEnter,BufEnter,BufNewFile * call MySoftab() Ah, glad you solved that. This is the typical set of events for Cream autocmds, I should have considered they'd be the same. -- Steve Hall [ digitect mindspring com ] Cream... something good to put in your Vim! http://cream.sourceforge.net |
From: BG - B. A. <BAr...@dy...> - 2004-10-28 18:46:54
|
On Wed, 2004-10-27 at 18:26 -0400, Steve Hall wrote: > o Add a Soft Tab option. (Walter Mundt) > > Note I say "near term". I've been thinking about trying to go to a > staggered release cycle of stable and unstable versions. It seems > lately my strategy has been to put the big new features in odd > releases and then only bug fixes in even ones. Of course this all > seems a bit silly to me given the nano-size and importance of Cream, > but at least it has been (mostly) keeping me from doing overhauls or > big fixes without taking care of some minor or hard-to-fix bugs. :) Staggering releases seems like a reasonable approach. How would a cream Soft Tab option play with my ftplugin soft tab adjustments? Actually, it would still be generally useful even if it were a global setting that would still need to be overridden in a handful of filetypes, as the rule is still soft tabs are 3 characters for most files. Ben |