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

Re: Do we support gf for "standard" filename?

Expand Messages
  • Bram Moolenaar
    ... Try this: au BufReadCmd file:///* exe edit . substitute(expand( ), file:/* , , ) Could actually be part of the netrw plugin. Charles? --
    Message 1 of 7 , Apr 5 2:07 AM
    • 0 Attachment
      Xiangjiang Ma wrote:

      > How to make gf work for an internet standard filename, such as:
      >
      > file:///C:/myfile.txt
      >
      > When I did "gf" to above, I got an empty file [New File]
      > with title "myfile.txt (file:///C:) -GVIM1"
      >
      > If it is C:/myfile.txt, I can do gf without any error.

      Try this:

      au BufReadCmd file:///* exe "edit " . substitute(expand("<afile>"), "file:/*", "", "")

      Could actually be part of the netrw plugin. Charles?

      --
      Women are probably the main cause of free software starvation.

      /// 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 at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
    • Steven Tryon
      ... (snip) ... Looks like it needs to be edit / on a Linux box. -- Steven Tryon stryon@rochester.rr.com ICQ 102798975
      Message 2 of 7 , Apr 5 3:03 AM
      • 0 Attachment
        On Mon, 2004-04-05 at 05:07, Bram Moolenaar wrote:
        > Xiangjiang Ma wrote:
        >
        > > How to make gf work for an internet standard filename, such as:
        > >
        > > file:///C:/myfile.txt
        (snip)
        > au BufReadCmd file:///* exe "edit " . substitute(expand("<afile>"), "file:/*", "", "")

        Looks like it needs to be "edit /" on a Linux box.
        --
        Steven Tryon
        stryon@...
        ICQ 102798975
      • Antoine J. Mechelynck
        ... 1) Prefix a slash if the 2nd character of the resulting path is not a colon (or are there other systems where this doesn t work? Mac? Amiga? VMS? Risc-OS?)
        Message 3 of 7 , Apr 5 9:55 AM
        • 0 Attachment
          Steven Tryon <stryon@...> wrote:
          > On Mon, 2004-04-05 at 05:07, Bram Moolenaar wrote:
          > > Xiangjiang Ma wrote:
          > >
          > > > How to make gf work for an internet standard filename, such as:
          > > >
          > > > file:///C:/myfile.txt
          > (snip)
          > > au BufReadCmd file:///* exe "edit " . substitute(expand("<afile>"),
          > > "file:/*", "", "")
          >
          > Looks like it needs to be "edit /" on a Linux box.
          > --
          > Steven Tryon
          > stryon@...
          > ICQ 102798975

          1) Prefix a slash if the 2nd character of the resulting path is not a colon
          (or are there other systems where this doesn't work? Mac? Amiga? VMS?
          Risc-OS?)

          2) What about "file://localhost/" (as used e.g. by Lynx instead of
          "file:///"); and what about percent-escaping, as in
          "file:///C:/Program%20Files/blahblah" ?

          Maybe one should write a function to take care of all that, and invoke it in
          the autocommand?

          Regards,
          Tony.
        • Xiangjiang Ma
          Bram, Your BufReadCmd worked for gf , but my alternative file (C-^) was changed. eg, by doing gf on file:///C:/myfile.txt : 1. I found the correct buffer
          Message 4 of 7 , Apr 5 10:09 AM
          • 0 Attachment
            Bram,

            Your "BufReadCmd" worked for "gf", but my alternative file (C-^) was
            changed.

            eg, by doing gf on "file:///C:/myfile.txt":
            1. I found the correct buffer myfile.txt (C:/)
            2. Typing C-^, I found I was editing a new file: myfile.txt (file:///C:)
            ......

            Also, this may not go to netrw plugin, because it is not remote editing
            related.

            Your solution is very close. Thanks.

            --
            Xiangjiang Ma



            >From: Bram Moolenaar <Bram@...>
            >To: "Xiangjiang Ma" <maxiangjiang@...>
            >CC: charles.e.campbell@..., vim@...
            >Subject: Re: Do we support gf for "standard" filename?
            >Date: Mon, 05 Apr 2004 11:07:11 +0200
            >
            >Xiangjiang Ma wrote:
            >
            > > How to make gf work for an internet standard filename, such as:
            > >
            > > file:///C:/myfile.txt
            > >
            > > When I did "gf" to above, I got an empty file [New File]
            > > with title "myfile.txt (file:///C:) -GVIM1"
            > >
            > > If it is C:/myfile.txt, I can do gf without any error.
            >
            >Try this:
            >
            >au BufReadCmd file:///* exe "edit " . substitute(expand("<afile>"),
            >"file:/*", "", "")
            >
            >Could actually be part of the netrw plugin. Charles?
            >
            >--
            >Women are probably the main cause of free software starvation.
            >
            > /// 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 at Amazon and help AIDS victims -- http://ICCF.nl/click1.html
            >///

            _________________________________________________________________
            Limited-time offer: Fast, reliable MSN 9 Dial-up Internet access FREE for 2
            months!
            http://join.msn.com/?page=dept/dialup&pgmarket=en-us&ST=1/go/onm00200361ave/direct/01/
          • Bram Moolenaar
            ... The reason I mentioned the netrw plugin is because it takes care of the side effects (as well as possible). Using file:// is not networking, but if you
            Message 5 of 7 , Apr 5 11:06 AM
            • 0 Attachment
              Xiangjiang Ma wrote:

              > Your "BufReadCmd" worked for "gf", but my alternative file (C-^) was
              > changed.
              >
              > eg, by doing gf on "file:///C:/myfile.txt":
              > 1. I found the correct buffer myfile.txt (C:/)
              > 2. Typing C-^, I found I was editing a new file: myfile.txt (file:///C:)
              > ......
              >
              > Also, this may not go to netrw plugin, because it is not remote editing
              > related.
              >
              > Your solution is very close. Thanks.

              The reason I mentioned the netrw plugin is because it takes care of the
              side effects (as well as possible). Using "file://" is not networking,
              but if you bend the plugin to "handling URLs" then it could be included
              there. It's up to Charles tough, it's his plugin.

              --
              The software said it requires Windows 95 or better, so I installed Linux.

              /// 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 at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
            • Xiangjiang Ma
              Bram, I found a workaround, by modifying your map: au BufReadCmd file:///* exe bd!|edit .substitute(expand( ), file:/* , , ) Now, it works as I
              Message 6 of 7 , Apr 5 1:49 PM
              • 0 Attachment
                Bram,

                I found a workaround, by modifying your map:

                au BufReadCmd file:///* exe "bd!|edit
                ".substitute(expand("<afile>"),"file:/*","","")

                Now, it works as I expecte, including <C-^>.

                I prefer this "native" way to "netrw plugin".

                Thanks

                --
                Xiangjiang Ma
                maxiangjiang@...





                >From: Bram Moolenaar <Bram@...>
                >To: "Xiangjiang Ma" <maxiangjiang@...>
                >CC: charles.e.campbell@..., vim@...
                >Subject: Re: Do we support gf for "standard" filename?
                >Date: Mon, 05 Apr 2004 20:06:49 +0200
                >
                >Xiangjiang Ma wrote:
                >
                > > Your "BufReadCmd" worked for "gf", but my alternative file (C-^) was
                > > changed.
                > >
                > > eg, by doing gf on "file:///C:/myfile.txt":
                > > 1. I found the correct buffer myfile.txt (C:/)
                > > 2. Typing C-^, I found I was editing a new file: myfile.txt (file:///C:)
                > > ......
                > >
                > > Also, this may not go to netrw plugin, because it is not remote editing
                > > related.
                > >
                > > Your solution is very close. Thanks.
                >
                >The reason I mentioned the netrw plugin is because it takes care of the
                >side effects (as well as possible). Using "file://" is not networking,
                >but if you bend the plugin to "handling URLs" then it could be included
                >there. It's up to Charles tough, it's his plugin.
                >
                >--
                >The software said it requires Windows 95 or better, so I installed Linux.
                >
                > /// 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 at Amazon and help AIDS victims -- http://ICCF.nl/click1.html
                >///

                _________________________________________________________________
                Watch LIVE baseball games on your computer with MLB.TV, included with MSN
                Premium!
                http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/
              Your message has been successfully submitted and would be delivered to recipients shortly.