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

Problem with 'autochdir' in Vim 7

Expand Messages
  • Halim, Salman
    Hello again, Dunno if this was something that s come up before (like my previous comment about the Folded higlight), but I m noticing the following behaviour
    Message 1 of 3 , Mar 23, 2005
    • 0 Attachment
      Hello again,

      Dunno if this was something that's come up before (like my previous
      comment about the Folded higlight), but I'm noticing the following
      behaviour with GVim 7.066 that I'm not with GVim 6.3 when I execute the
      following command-line:

      gvim -o tiles/incidentComparisonTopMenu.jsp
      tiles/layout/incidentComparisonLayout.jsp

      Obviously, both filenames are relative to the current directory. I have
      :set autochdir in my _vimrc; this causes no problems with 6.3 and things
      open up just fine. However, in Vim 7, I get:

      E211: File tiles/incidentComparisonTopMenu.jsp no longer exists.

      Vim has set the current directory to the 'tiles' subdirectory (I did a
      :pwd to ensure this) but shows the current file as being
      tiles/incidentComparisonTopMenu.jsp, basically reducing the file to
      tiles/tiles/incidentComparisonTopMenu.jsp. Note further that the second
      buffer shows up as tiles/layout/incidentComparisonLayout.jsp (being
      reduced to tiles/tiles/layout/incidentComparisonLayout.jsp because of
      the current directory already being tiles) and is empty as it couldn't
      be read from that location. At this point, neither buffer is valid (I
      don't have a tiles/tiles path; re-edits on the original file set it to
      empty, also, which is correct in light of the paths being used).

      I commented out the :set autochdir from my _vimrc and things worked just
      fine; however, I *like* the autochdir and wasn't having any problems
      with it in Vim 6.3. I noticed that :help 'autochdir' says:

      This option is provided for backward compatibility with the Vim
      released with Sun ONE Studio 4 Enterprise Edition.

      Does this mean that this isn't something I should be using or relying
      upon to be consistent in behaviour? (Since it was provided solely for
      backward compatibility, does this mean it will go away?)

      Before this option came about, I was using the following mechanism:

      " Automatically cd to the directory of the current buffer upon entry
      function! ToggleAutoCD()
      if(exists('g:autocd'))
      silent! au! AutoCD
      unlet g:autocd
      else
      augroup AutoCD
      au! BufEnter * cd %:p:h
      augroup END
      cd %:p:h
      let g:autocd=1
      endif
      endfunction
      com! -bar Toggleautocd call ToggleAutoCD()

      function! SetAutoCD()
      if ( !exists( 'g:autocd' ) )
      Toggleautocd
      endif
      endfunction
      com! -bar Setautocd call SetAutoCD()

      (And was calling SetAutoCD in the beginning.) Interestingly enough,
      THIS doesn't work in Vim 7 with basically the same series of errors
      ("Can't find directory tiles/tiles") but DOES work in Vim 6.3.

      Long-winded, I know, but I hope I've given enough information here to
      help solve the problem, in case it hasn't come up before.

      Thanks :)

      Salman.
    • Bram Moolenaar
      ... I can t reproduce this. Try this: gvim -u NONE -U NONE --cmd set autochdir -o tiles/incidentComparisonTopMenu.jsp
      Message 2 of 3 , Mar 23, 2005
      • 0 Attachment
        Salman Halim wrote:

        > Dunno if this was something that's come up before (like my previous
        > comment about the Folded higlight), but I'm noticing the following
        > behaviour with GVim 7.066 that I'm not with GVim 6.3 when I execute the
        > following command-line:
        >
        > gvim -o tiles/incidentComparisonTopMenu.jsp
        > tiles/layout/incidentComparisonLayout.jsp
        >
        > Obviously, both filenames are relative to the current directory. I have
        > :set autochdir in my _vimrc; this causes no problems with 6.3 and things
        > open up just fine. However, in Vim 7, I get:
        >
        > E211: File tiles/incidentComparisonTopMenu.jsp no longer exists.
        >
        > Vim has set the current directory to the 'tiles' subdirectory (I did a
        > :pwd to ensure this) but shows the current file as being
        > tiles/incidentComparisonTopMenu.jsp, basically reducing the file to
        > tiles/tiles/incidentComparisonTopMenu.jsp. Note further that the second
        > buffer shows up as tiles/layout/incidentComparisonLayout.jsp (being
        > reduced to tiles/tiles/layout/incidentComparisonLayout.jsp because of
        > the current directory already being tiles) and is empty as it couldn't
        > be read from that location. At this point, neither buffer is valid (I
        > don't have a tiles/tiles path; re-edits on the original file set it to
        > empty, also, which is correct in light of the paths being used).

        I can't reproduce this. Try this:

        gvim -u NONE -U NONE --cmd "set autochdir" -o tiles/incidentComparisonTopMenu.jsp
        tiles/layout/incidentComparisonLayout.jsp

        This rules out the rest of your ~/.vimrc. Does it still happen then?

        Is this on Unix or Win32?

        --
        If you had to identify, in one word, the reason why the
        human race has not achieved, and never will achieve, its
        full potential, that word would be "meetings."

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Halim, Salman
        My apologies; you are correct -- with the files completely turned off and acd turned on, it does work. However, I m confused as to why I wasn t having this
        Message 3 of 3 , Mar 23, 2005
        • 0 Attachment
          My apologies; you are correct -- with the files completely turned off
          and acd turned on, it does work. However, I'm confused as to why I
          wasn't having this problem in 6.3 at all. I'll hunt through and see
          what's happening: interestingly enough, simply removing my plugin
          directory didn't do it, so it's something else, possibly my _vimrc or
          something in an ftplugin.

          Thanks; and sorry for the second false alarm.

          Salman.

          > -----Original Message-----
          > From: Bram@... [mailto:Bram@...]
          > Sent: Wednesday, March 23, 2005 4:57 PM
          > To: Halim, Salman
          > Cc: vim-dev@...
          > Subject: Re: Problem with 'autochdir' in Vim 7
          >
          >
          > Salman Halim wrote:
          >
          > > Dunno if this was something that's come up before (like my previous
          > > comment about the Folded higlight), but I'm noticing the following
          > > behaviour with GVim 7.066 that I'm not with GVim 6.3 when I execute
          > > the following command-line:
          > >
          > > gvim -o tiles/incidentComparisonTopMenu.jsp
          > > tiles/layout/incidentComparisonLayout.jsp
          > >
          > > Obviously, both filenames are relative to the current directory. I
          > > have :set autochdir in my _vimrc; this causes no problems
          > with 6.3 and
          > > things open up just fine. However, in Vim 7, I get:
          > >
          > > E211: File tiles/incidentComparisonTopMenu.jsp no longer exists.
          > >
          > > Vim has set the current directory to the 'tiles'
          > subdirectory (I did a
          > > :pwd to ensure this) but shows the current file as being
          > > tiles/incidentComparisonTopMenu.jsp, basically reducing the file to
          > > tiles/tiles/incidentComparisonTopMenu.jsp. Note further that the
          > > second buffer shows up as tiles/layout/incidentComparisonLayout.jsp
          > > (being reduced to tiles/tiles/layout/incidentComparisonLayout.jsp
          > > because of the current directory already being tiles) and
          > is empty as
          > > it couldn't be read from that location. At this point,
          > neither buffer
          > > is valid (I don't have a tiles/tiles path; re-edits on the original
          > > file set it to empty, also, which is correct in light of
          > the paths being used).
          >
          > I can't reproduce this. Try this:
          >
          > gvim -u NONE -U NONE --cmd "set autochdir" -o
          > tiles/incidentComparisonTopMenu.jsp
          > tiles/layout/incidentComparisonLayout.jsp
          >
          > This rules out the rest of your ~/.vimrc. Does it still happen then?
          >
          > Is this on Unix or Win32?
          >
          > --
          > If you had to identify, in one word, the reason why the human
          > race has not achieved, and never will achieve, its full
          > potential, that word would be "meetings."
          >
          > /// Bram Moolenaar -- Bram@... --
          > http://www.Moolenaar.net \\\
          > /// Sponsor Vim, vote for features --
          > http://www.Vim.org/sponsor/ \\\
          > \\\ Project leader for A-A-P --
          > http://www.A-A-P.org ///
          > \\\ Buy LOTR 3 and help AIDS victims --
          > http://ICCF.nl/lotr.html ///
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.