sent 02:23:45 01 March 2011, Tuesday
by Chris Jones:
> The suggested pipe 'setl bt= | help' does indeed override Vim's miserly
> behavior relative to help windows..
> 
> Why?
Because vim uses 'buftype' to check whether some buffer is a help buffer. If you 
write your own plugin and edit a help file, then you won't have 'buftype' set to 
`help'.
> Another quick question.. in Vimscript, what is the natural idiom to code:
> 
> if count == 0; do proc_0; fi
> if count == 1; do proc_1; fi
> if count >  1; do proc_n; fi
What language is this? On zsh I would have written this as
    if   (( count==0 )) ; then proc_0
    elif (( count==1 )) ; then proc_1
    elif (( count>1  )) ; then proc_n
    fi
. In vim:
    if     count==0 | proc_0
    elseif count==1 | proc_1
    elseif count>1  | proc_n
    endif
(Note that `count' is alias to read-only variable v:count that is keeped for 
backwards compatibility, so you may not use it in your script with other 
meaning.)
Original message:
> On Mon, Feb 28, 2011 at 03:53:27PM EST, ZyX wrote:
> > > How could I figure out the number of help windows in the current tab?
> > > 
> >   let helpcount=len(filter(range(1, winnr('$')),
> >   'getbufvar(winbufnr(v:val), "&ft")==#"help"'))
> 
> Works out of the box.  :-)
> 
> > You may want to change "&ft" (shortcut to "&filetype") to "&bt"
> > (shortcut to "&buftype"), but I would use &ft because vim behavior
> > when you have more then one buffer with 'buftype' set to `help' is
> > undefined (that is why I would have written `setl bt= | vert help
> > subject' instead of suggested `vnew | set bt=help | help subject').
> 
> The suggested pipe 'setl bt= | help' does indeed override Vim's miserly
> behavior relative to help windows..
> 
> Why?
> 
> Another quick question.. in Vimscript, what is the natural idiom to code:
> 
> if count == 0; do proc_0; fi
> if count == 1; do proc_1; fi
> if count >  1; do proc_n; fi
> 
> Otherwise, is there a decent tutorial on how to write functions in Vim..?
> 
> Thanks a bunch,
> 
> cj
No comments:
Post a Comment