> I have this in my _vimrc file: > > function! CHANGE_CURR_DIR() > let _dir = expand("%:p:h") > let _filename = expand("%") //I added this line > exec "cd " . _dir > unlet _dir > endfunction > autocmd BufEnter * call CHANGE_CURR_DIR()
You may also want to investigate the 'autochdir' option :help 'autochdir' which exploits Vim's builtin ability to do what you're describing above. -tim