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

reading contents from a file under directories specified by "path" variable

Expand Messages
  • Aman Jain
    Hi I know vim supports searching for files in those directories which are specified by the path variable. e.g. ... (For this find command, auto complete works
    Message 1 of 4 , Jun 3, 2011
    • 0 Attachment
      Hi

      I know vim supports searching for files in those directories
      which are specified by the path variable.
      e.g.
      :se path=/path/to/dir1,/path/to/dir2
      :find file_inside_dir1.txt
      (For this find command, auto complete works fine.)

      But is there a way for reading in the contents of files present under
      directories,
      specified by path variable e.g.
      :r file_inside_dir<TAB>

      P.S: Right now I have to specify full path to read contents of a file,
      which at some times is not that efficient.
      i.e :r /path/to/dir1/file_inside_dir1

      Thanks

      --
      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
    • Ryan Aviles
      When I do :find It opens the file even if its outside my current working directory. No need for the :r ... -- You received this
      Message 2 of 4 , Jun 3, 2011
      • 0 Attachment
        When I do :find <filename_without_dir>
        It opens the file even if its outside my current working directory. No need for the ":r"

        On Fri, Jun 3, 2011 at 2:38 PM, Aman Jain <amanjain.nitrkl@...> wrote:
        Hi

        I know vim supports searching for files in those directories
        which are specified by the path variable.
        e.g.
        :se path=/path/to/dir1,/path/to/dir2
        :find file_inside_dir1.txt
        (For this find command, auto complete works fine.)

        But is there a way for reading in the contents of files present under
        directories,
        specified by path variable e.g.
        :r file_inside_dir<TAB>

        P.S: Right now I have to specify full path to read contents of a file,
        which at some times is not that efficient.
               i.e :r /path/to/dir1/file_inside_dir1

        Thanks

        --
        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 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
      • Aman Jain
        I know that it works for :find , as already mentioned in my question; I am mainly interested in a way by which I get the same behavior for :r --Thanks ...
        Message 3 of 4 , Jun 3, 2011
        • 0 Attachment
          I know that it works for ":find", as already mentioned in my question;
          I am mainly interested in a way by which I get the same behavior for
          ":r"

          --Thanks

          On Jun 3, 3:54 pm, Ryan Aviles <ryan.avi...@...> wrote:
          > When I do :find <filename_without_dir>
          > It opens the file even if its outside my current working directory. No need
          > for the ":r"
          >
          >
          >
          >
          >
          >
          >
          > On Fri, Jun 3, 2011 at 2:38 PM, Aman Jain <amanjain.nit...@...> wrote:
          > > Hi
          >
          > > I know vim supports searching for files in those directories
          > > which are specified by the path variable.
          > > e.g.
          > > :se path=/path/to/dir1,/path/to/dir2
          > > :find file_inside_dir1.txt
          > > (For this find command, auto complete works fine.)
          >
          > > But is there a way for reading in the contents of files present under
          > > directories,
          > > specified by path variable e.g.
          > > :r file_inside_dir<TAB>
          >
          > > P.S: Right now I have to specify full path to read contents of a file,
          > > which at some times is not that efficient.
          > >        i.e :r /path/to/dir1/file_inside_dir1
          >
          > > Thanks
          >
          > > --
          > > 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, visithttp://www.vim.org/maillist.php

          --
          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
        • Jean-Rene David
          ... As you noticed, :read doesn t consult path . Here s a quick implementation: fun! Read(file) let full_path = findfile(a:file) exe read . full_path
          Message 4 of 4 , Jun 3, 2011
          • 0 Attachment
            * Aman Jain [2011.06.03 14:40]:
            > But is there a way for reading in the contents of files present under
            > directories,
            > specified by path variable e.g.
            > :r file_inside_dir<TAB>

            As you noticed, :read doesn't consult 'path'.

            Here's a quick implementation:

            fun! Read(file)
            let full_path = findfile(a:file)
            exe "read " . full_path
            endfun

            fun! PathComplete(A,L,P)
            return split( globpath(&path, a:A."*"), "\n")
            endfun

            command! -complete=customlist,PathComplete -nargs=1 Read call Read('<args>')

            Use like so:

            :Read foo<tab>

            HTH,

            --
            JR

            --
            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
          Your message has been successfully submitted and would be delivered to recipients shortly.