> On Sat, Jul 3, 2010 at 00:20, Ben Fritz<fritzophrenic@gmail.com> wrote:
>> On Jun 3, 1:54 am, Tinou<tinou...@gmail.com> wrote:
>>> Now this seems to work:
>>>
>>> autocmd! BufNew * if empty(expand("<afile>")) | call
>>> setbufvar(bufnr("$"), "&buftype", "nofile") | endif
>>>
>>> I'm not very happy with the bufnr("$"), but bufnr("<afile>") returns
>>> -1. Can I rely, in this case for the<afile> to always be the last
>>> buffer ? Or is there a better way to get the number of the<afile>
>>> buffer ?
>>
>> Maybe try bufnr(expand("<afile>"))
>
> No, that doesn't work.
>
> Doing this:
> - start vim
> - :e somefile
> - :tabe
>
> "somefile" gets the nofile buftype.
>
> I've been using it with "$" since then and it hasn't ever done anything
> not expected yet. So I guess a new buffer is always the last.
>
> Tinou
>
Maybe not if you reuse a filename (and absolute path) which is already
in the bufferlist (saved from the previous session in the viminfo) but
hasn't been loaded yet during the present session.
Best regards,
Tony.
--
Although we modern persons tend to take our electric lights, radios,
mixers, etc., for granted, hundreds of years ago people did not have
any of these things, which is just as well because there was no place
to plug them in. Then along came the first Electrical Pioneer,
Benjamin Franklin, who flew a kite in a lighting storm and received a
serious electrical shock. This proved that lighting was powered by the
same force as carpets, but it also damaged Franklin's brain so severely
that he started speaking only in incomprehensible maxims, such as "A
penny saved is a penny earned." Eventually he had to be given a job
running the post office.
-- Dave Barry, "What is Electricity?"
--
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