Monday, February 28, 2011

Re: using the help system in split screen mode

>> 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

How do you figure that? You can easily get multiple buffers with
buftype=help perfectly naturally by splitting help windows and moving to
new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
behaves perfectly normally and as expected.

>> (that is why I would have written `setl bt= | vert help
>> subject' instead of suggested `vnew | set bt=help | help subject').

Well, my set should definitely have been setl, but apart from that, I
think it's still arguably a better approach.

> The suggested pipe 'setl bt= | help' does indeed override Vim's miserly
> behavior relative to help windows..
>
> Why?

Because Vim identifies help windows by the buftype, so if you clear it,
Vim no longer thinks it is a help window, so doesn't reuse it.

I would advise against this, as it has other side effects, e.g. using
:help in the existing window will not reuse it as desired, but open a
new window. A few other help-window-specific behaviours will also not
work on the old help window if you do this.

> 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..?

I'm not sure Vimscript has any natural idioms! You will probably get a
whole bunch of opinions on how best to do anything. Quite possibly the
best idiom is what seems most natural to you.

But what you wrote above seems fine, though of course in Vimscript, the
syntax is different:

if count == 0 | call proc_0() | endif
if count == 1 | call proc_1() | endif
if count> 1 | call proc_n() | endif

Ben.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment