On Thu, 27 Apr 2006, Eric Crahen wrote:
On 4/27/06, Gerald Lai <[EMAIL PROTECTED]> wrote:
On 4/27/06, Eric Crahen <[EMAIL PROTECTED]> wrote:
On 4/27/06, Gerald Lai <[EMAIL PROTECTED]> wrote:
On Thu, 27 Apr 2006, 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
Hi Eric,
I don't use 'autochdir', but here's what I have that works for me:
"set local directory
autocmd BufWinEnter,BufWritePost *
\ if expand("%") !~ "^\\%(\\a\\+://\\|$\\)" |
\ lcd %:p:h |
\ endif |
HTH :)
I tried adding that and there was no effect
Try running from the prompt:
$ vim -u NONE
Then do:
:set nocp laststatus=2
:autocmd BufWinEnter * lcd %:p:h
Split open 2 files in different directories and switch between both the
windows. Do you see the paths change?
[modified for bottom posting]
When I open files from within vim its not a problem. Its the files
that are opened from the command line, a method I use every day.
The autocmds VimEnter, BufEnter, WinEnter, and BufWinEnter all activate
when a file is opened from the command line. You can use any of these.
The example "set local directory" I gave you will only set the directory
for windows in Vim. When you quit Vim, you will still be where you
executed Vim.
Consider using
:cd
instead of
:lcd
See ":help :cd" & ":help :lcd".
I'm sorry I misunderstood what you wanted in the first place.
HTH :)
--
Gerald