On Thu, Apr 27, 2006 at 09:44:04AM -0700, Eric Crahen wrote:
> I've tried all variation of BufEnter and autchdir commands to get the
> cwd switched to that of the file that is open. None of them ever work
> when I specify a file on the command line. The buffer for the file I
> specify is open, but the cwd is right where I started vim. I have to
> :bn|:bp to get the buffer switched.
> 
> Its only this first file. Anyone know why?
> " Change directory
> if exists('+autochdir')
>  set autochdir
> else
>  autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
> endif

     Without checking, I guess that the BufEnter autocommand is not
triggered when vim first starts up.  This should work:

autocmd VimEnter,BufEnter * silent! lcd %:p:h

HTH                                     --Benji Fisher

Reply via email to