Loading ...
Sorry, an error occurred while loading the content.

Re: Still having different pwd for different windows

Expand Messages
  • Christian Brabandt
    Hi AndyHancock! ... 2 suggestions to help finding out why/when your working directory changes: 1) :set verbose=5 When the verbose setting is set to at least 5,
    Message 1 of 11 , May 2, 2013
    • 0 Attachment
      Hi AndyHancock!

      On Mi, 01 Mai 2013, AndyHancock wrote:

      > On Apr 29, 5:09 am, Marcin Szamotulski wrote:
      > > 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?
      >
      > Unfortunately, it doesn't just happen at startup. I haven't been able
      > to determine the triggering event.

      2 suggestions to help finding out why/when your working directory
      changes:

      1) :set verbose=5
      When the verbose setting is set to at least 5, Vim will always
      print whenever it changes directories. This might however be
      accompanied with a lot of other verbose messages in which you are
      not interested.

      2) Try if :set cpo+=. helps. This prevents changing directories, if
      your buffer is modified. So this doesn't work in all cases, but
      should at least prevent changing directories, when you are editing
      a file.

      regards,
      Christian
      --
      Kabarett ist ein Breitband-Antiidiotikum.
      -- Volker Pispers

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • AndyHancock
      I recently re-bumped up against this problem enough that I decided to take a wack of time trying to track it down again. Bascially, some buffers cause an
      Message 2 of 11 , Feb 4, 2014
      • 0 Attachment
        I recently re-bumped up against this problem enough that I decided to take a wack of time trying to track it down again. Bascially, some buffers cause an automatic change of the pwd to the parent folder. Even if I do

        :bufdo pwd

        I get the same 20 odd answers for one window, but when I change windows, I get the same 20 odd answers that are different from the first 20 answers. I still haven't figured out what triggers it, but it doesn't happen all the time. Once the problem starts, however, the behaviour sticks and the condition seems to be captured in a mksession file. So if I fire up a new gvim, I can source the session file and the offending behaviour comes along with it. If I simply open a new gvim and revisit all the files I had on my buffer list, I don't see the behaviour come, at least not right away.

        I tried to find an autochdir or a "cd %:p:h" command in the relevant files. Basically, I went to the directory containing _vimrc and vimfiles/ and issued the bash command for searching:

        grep -i -w -r -e autochdir -e acd -e '%:p:h' \
        *vim* ~/tmp/session.vim

        The only lines that came up are commands for setting the Windows titlestring and iconstring:

        _vimrc:set titlestring=v:%t%(\ %M%)%(\ (%{expand(\"%:p:h:s+.*/++\")})%)%(\ %a%)

        _vimrc:set iconstring=v:%t%(\ %M%)%(\ (%{expand(\"%:p:h:s+.*/++\")})%)%(\ %a%)

        These also show up in my session.vim and _viminfo.

        Thanks to anyone who can suggest another way to deal with this.

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Aaron Bohannon
        I only skimmed this thread, but surprisingly, no one seems to have brought up the issue of netrw. Whenever you browse a directory in a window, netrw executes
        Message 3 of 11 , Feb 25, 2014
        • 0 Attachment
          I only skimmed this thread, but surprisingly, no one seems to have brought up the issue of netrw. Whenever you browse a directory in a window, netrw executes an :lcd command in that window, so that it's CWD is different from the rest of the windows. Now that is actually a perfectly sensible thing for netrw to do if g:netrw_keepdir == 0. However, netrw *always* does it, even if g:netrw_keepdir == 1 (the default, meaning "don't change the CWD"). It drives me nuts.

          On Sunday, April 28, 2013 4:36:17 PM UTC-7, AndyHancock wrote:
          > 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).
          >
          >
          >
          > 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.

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Charles E Campbell
          ... Please give me an example. With g:netrw_keepdir= 1, and starting from my home directory: vim somefile ... So, netrw did not change the cwd, in either of
          Message 4 of 11 , Feb 25, 2014
          • 0 Attachment
            Aaron Bohannon wrote:
            > I only skimmed this thread, but surprisingly, no one seems to have brought up the issue of netrw. Whenever you browse a directory in a window, netrw executes an :lcd command in that window, so that it's CWD is different from the rest of the windows. Now that is actually a perfectly sensible thing for netrw to do if g:netrw_keepdir == 0. However, netrw *always* does it, even if g:netrw_keepdir == 1 (the default, meaning "don't change the CWD"). It drives me nuts.
            >
            Please give me an example.

            With g:netrw_keepdir= 1, and starting from my home directory:

            vim somefile
            :echo getcwd() (shows home directory)
            :wincmd s
            :e .vim
            :echo getcwd() (shows home directory)
            :wincmd j
            :echo getcwd() (shows home directory)

            So, netrw did not change the cwd, in either of the two windows used.

            Regards,
            C Campbell

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.