Monday, April 29, 2013

Re: Still having different pwd for different windows

On 09:12 Mon 29 Apr , Paul Isambert wrote:
> AndyHancock <andymhancock@gmail.com> a écrit:
> > I posted previously about the fact that pwd returns different
> > directories for different windows. I was pointed to autochdir, in
> > particular:
> >
> > verbose set autochdir?
> >
> > which always returns noautochdir.
> >
> > I already have noautochdir in my vimrc, and the above command
> > indicates that netrw was last to set the autochdir option.
> >
> > The problem is sporadic enough that it isn't clear to me that I will
> > ever be able to figure out how/when autochdir is being set (if it is).
>
> The problem might not come from autochdir but from something like:
>
> autocmd BufRead * lcd %:p:h
>
> which sets the window's local directory. Perhaps you have that
> somewhere in your .vimrc file or elsewhere? (It's common enough.)
>
> > As an alternative to tracking this down, is there a way to prevent
> > autochdir from being set at all? I mean even if a plugin or function
> > somehwere issues a command to set autochdir, I want [g]vim to be
> > incapable of complying.
>
> As far as I know, you can't. But you can put a script in your "after"
> directory, which simply contains:
>
> set noautochdir
>
> Scripts in "after" are loaded after plugins.
>
> Best,
> Paul
>

If the above will not solve your problem you can record your local
directory in vimrc:
let g:pwd = getcwd()
and in a '.vim/after/plugin/myscript.vim' use:
set noautochdir
exe 'cd '.fnameescape(g:pwd)

If this was due to lcd used somewhere it should solve it. I assume that
it only happens on startup, if not you might need to use autocommands.
Maybe it only happens with some file type?

Best regards,
Marcin

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment