On 2006-08-21, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> This is nice, but. This works for :new (I tried BufNew),
> but still does not work
> for that empty buffer #1 that is created when vim is invoked without
> commandline arguments.
>
> I want it to work for the initial empty buffer, too.
I had a similar problem with a plugin I was writing recently.
Without going into details on the plugin, here's what I did to make
sure a particular function was called no matter how I started vim.
--------------------------------------------------------------------
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Call the ConfigureProject() function when Vim is started and when a new
" file is opened.
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let b:event = ''
if argc() == 0
" No files were specified on the command line, so the autocommand
" will not be triggered when vim starts.
call ConfigureProject('')
endif
if argc() > 0 && isdirectory(argv(0))
" The first file specified on the command line is a directory, so the
" autocommand will not be triggered when vim starts.
call ConfigureProject(fnamemodify(argv(0), ":p"))
endif
augroup project
au!
au BufNewFile * let b:event="BufNewFile" | call
ConfigureProject(expand("<afile>:p:h"))
au BufRead * let b:event="BufRead" | call
ConfigureProject(expand("<afile>:p:h"))
augroup END
--------------------------------------------------------------------
HTH,
Gary
--
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
| Spokane, Washington, USA