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

Re: Still having different pwd for different windows

Expand Messages
  • John Little
    If you haven t already, have a look at the output of ... Might give a clue about what s happening. Regards, John Little -- -- You received this message from
    Message 1 of 11 , May 2, 2013
    • 0 Attachment
      If you haven't already, have a look at the output of
      :scriptnames

      Might give a clue about what's happening.


      Regards, John Little

      --
      --
      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.
    • Marcin Szamotulski
      ... The scripts in the after directory will be executed after other scripts. For example if you have ~/.vim/plugin/p1.vim and ~/.vim/after/plugin/p2.vim the
      Message 2 of 11 , May 2, 2013
      • 0 Attachment
        On 22:42 Wed 01 May , 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.
        >
        > I'm still unclear about how the after directory works. When do which
        > files get invoked? I was confused by the help for "after".
        >
        > --
        > --
        > 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.
        >

        The scripts in the after directory will be executed after other scripts.
        For example if you have
        ~/.vim/plugin/p1.vim

        and
        ~/.vim/after/plugin/p2.vim

        the second one will be executed after the first one (i.e. the scripts
        under 'after/plugin/' are executed after all the scripts under
        'plugin/'). The same applies to any other directories (ftplugin vs
        after/ftplugin, syntax vs after/syntax, etc). I often use the after
        directory to add some features to syntax files with, for example in

        ~/.vim/after/syntax/vim.vim

        You can add additional syntax rules to the standard syntax/vim.vim
        file. If you'd place it without the '/after' directory it would
        execute and the one under $VIMRUNTIME/syntax/vim.vim would not.

        The next level are autocommands, for example the FileType autocommand
        group is executed after the ~/.vim/ftplugin/... script and even after
        ~/.vim/after/ftplugin/... (where the ... correspond to the specific file
        type).

        I hope it explains the after directory a bit. You can experimant with
        them by putting a simple script which just echoes a message:

        Pu this in '~/.vim/plugin/test.vim':
        echom 'plugin/test.vim'

        and this in '~/.vim/after/plugin/test.vim':
        echom 'after/plugin/test.vim'

        there is VimEnter autocommand group which is fired as the last step of
        the vim start-up (actually almost the last, since it is before running
        the --cmd vim command line argument :).


        As for your problem: have you checked where autochdir get set, this
        command might help you:
        :verbose set acd?
        otherwise you can bisect your plugins (turn some of them off
        and check if it happens) or grep which one is useing :lcd or :cd command
        without reverting the change.

        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • 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 3 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 4 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 5 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 6 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.