Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I get gvim to automatically change the (local) working directory to the current file directory when I change tabs. Or at the very least is there a shortcut command for doing that?

share|improve this question
up vote 1 down vote accepted

Yes, put

set autochdir

in your vimrc.

share|improve this answer
"It's only available if Vim was built with netbeans integration or Sun visual workshop integration."… – innaM Nov 28 '09 at 12:21
Yes. But, if I'm not mistaken that's the default download option from – Rook Nov 28 '09 at 16:00

I htink you looking for autochdir. It should be a builtin command in your vim. To have the current working dir always be what ever buffer you're in, add set autochdir to your vimrc. This is automatic, but may break saving & loading sessions. Check this out for more options. An alternative is to add this to your vimrc:

autocmd BufEnter * lcd %:p:h

This question has also appeared on Stack Overflow

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .