Wednesday, August 24, 2011

Autocommand event for new buffers including startup buffer

I normally use `autocmd BufNewFile,BufRead * ‥` to execute a command
in each new buffer as it is opened. However, these events are not
triggered in the "No Name" buffer that is created when Vim is launched
without arguments.

In my .vimrc:

autocmd BufNewFile,BufRead * let b:foo = 1

If I launch Vim with `vim test.txt`, then b:foo is defined in the
resulting buffer. If I launch with just `vim`, however, it is undefined
in the "startup" buffer, but any subsequent buffers I create, say with
`:e`, do have b:foo defined.

Is there an autocommand event that applies to the default startup buffer
as well as all subsequently created buffers? Using something like
`BufNewFile,BufRead,VimEnter` doesn't work for me in this case, because
VimEnter triggers too late to be useful for the result I'm trying to
achieve. I need an event which occurs at the same time (or earlier) in
the buffer creation process as the other two.

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