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

How do you trap the output of filename completion?

Expand Messages
  • Keith Roberts
    ... ... but * is empty after this. I d like to trap the output generated by the completion so I can :put it into a buffer [so that I can use lid on each of
    Message 1 of 5 , Dec 1, 2003
    • 0 Attachment
      I've tried:
      :redir @*
      :e some_path\abc<tab> [completion]
      :redir end

      ... but "* is empty after this. I'd like to trap the output generated by
      the completion so I can :put it into a buffer [so that I can use 'lid' on
      each of the entries].
    • Gary Johnson
      ... If you re trying to do this in a script, I d suggest you look at ... I think the solution to your particular problem would then be:
      Message 2 of 5 , Dec 1, 2003
      • 0 Attachment
        On 2003-12-01, Keith Roberts <kroberts@...> wrote:
        > I've tried:
        > :redir @*
        > :e some_path\abc<tab> [completion]
        > :redir end
        >
        > ... but "* is empty after this. I'd like to trap the output generated by
        > the completion so I can :put it into a buffer [so that I can use 'lid' on
        > each of the entries].

        If you're trying to do this in a script, I'd suggest you look at

        :help glob()

        I think the solution to your particular problem would then be:

        put=glob('some_path/abc*')

        HTH,
        Gary

        --
        Gary Johnson | Agilent Technologies
        garyjohn@... | Wireless Division
        | Spokane, Washington, USA
      • Benji Fisher
        ... That sounds like a good idea for this particular question, but it would be nice to have a variant of :redir that captured input as well as output. (You
        Message 3 of 5 , Dec 2, 2003
        • 0 Attachment
          On Mon, Dec 01, 2003 at 06:26:47PM -0800, Gary Johnson wrote:
          > On 2003-12-01, Keith Roberts <kroberts@...> wrote:
          > > I've tried:
          > > :redir @*
          > > :e some_path\abc<tab> [completion]
          > > :redir end
          > >
          > > ... but "* is empty after this. I'd like to trap the output generated by
          > > the completion so I can :put it into a buffer [so that I can use 'lid' on
          > > each of the entries].
          >
          > If you're trying to do this in a script, I'd suggest you look at
          >
          > :help glob()
          >
          > I think the solution to your particular problem would then be:
          >
          > put=glob('some_path/abc*')

          That sounds like a good idea for this particular question, but it
          would be nice to have a variant of :redir that captured input as well as
          output. (You can use the command-line window, but that only shows one
          copy of repeated commands.) For example, when reporting problems and
          solutions on this list, it is A Good Thing to be able to record a bit of
          one's session.

          Until such a feature is added to vim, you can use the :Echo command
          in foo.vim :
          http://www.vim.org/script.php?script_id=72

          HTH --Benji Fisher
        • Keith Roberts
          ... This is a step in the right direction. Not *exactly* what I wanted, but I can use it. Filename-completion just returns the filenames without the path,
          Message 4 of 5 , Dec 2, 2003
          • 0 Attachment
            >-----Original Message-----
            >From: Benji Fisher [mailto:benji@...]
            >Sent: Tuesday, December 02, 2003 6:57 AM
            >To: vim@...
            >Subject: Re: How do you trap the output of filename completion?
            >
            >On Mon, Dec 01, 2003 at 06:26:47PM -0800, Gary Johnson wrote:
            >> On 2003-12-01, Keith Roberts <kroberts@...> wrote:
            >> > I've tried:
            >> > :redir @*
            >> > :e some_path\abc<tab> [completion]
            >> > :redir end
            >> >
            >> > ... but "* is empty after this. I'd like to trap the output generated
            >by
            >> > the completion so I can :put it into a buffer [so that I can use 'lid'
            >on
            >> > each of the entries].
            >>
            >> If you're trying to do this in a script, I'd suggest you look at
            >>
            >> :help glob()
            >>
            >> I think the solution to your particular problem would then be:
            >>
            >> put=glob('some_path/abc*')

            This is a step in the right direction. Not *exactly* what I wanted, but I
            can use it. Filename-completion just returns the filenames without the
            path, which is what I was looking for, but it turns out not to make any real
            difference to using 'lid' on <cword>. Plus, it's easy enough to delete the
            paths. Thanks, Gary.

            > That sounds like a good idea for this particular question, but it
            >would be nice to have a variant of :redir that captured input as well as
            >output. (You can use the command-line window, but that only shows one
            >copy of repeated commands.) For example, when reporting problems and
            >solutions on this list, it is A Good Thing to be able to record a bit of
            >one's session.
            >
            > Until such a feature is added to vim, you can use the :Echo command
            >in foo.vim :
            >http://www.vim.org/script.php?script_id=72

            Very interesting, Benji. I like that. I've been meaning to look at some of
            that stuff for quite a while.
          • Keith Roberts
            ... For anyone else out there who is interested, here s an abbrev that will let you play with expansions in the . directory, tossing the matches into a new
            Message 5 of 5 , Dec 2, 2003
            • 0 Attachment
              >-----Original Message-----
              >From: Keith Roberts [mailto:kroberts@...]
              >Sent: Tuesday, December 02, 2003 10:07 AM
              >To: 'Benji Fisher'; 'vim@...'
              >Subject: RE: How do you trap the output of filename completion?
              >
              >>-----Original Message-----
              >>From: Benji Fisher [mailto:benji@...]
              >>Sent: Tuesday, December 02, 2003 6:57 AM
              >>To: vim@...
              >>Subject: Re: How do you trap the output of filename completion?
              >>
              >>On Mon, Dec 01, 2003 at 06:26:47PM -0800, Gary Johnson wrote:
              >>> On 2003-12-01, Keith Roberts <kroberts@...> wrote:
              >>> > [snip]I'd like to trap the output generated by
              >>> > the completion so I can :put it into a buffer [snip]
              >>>[snip]
              >>> I think the solution to your particular problem would then be:
              >>>
              >>> put=glob('some_path/abc*')
              >
              >This is a step in the right direction. Not *exactly* what I wanted, but I
              >can use it. Filename-completion just returns the filenames without the
              >path, which is what I was looking for, but it turns out not to make any
              >real difference to using 'lid' on <cword>. Plus, it's easy enough to
              >delete the paths. Thanks, Gary.

              For anyone else out there who is interested, here's an abbrev that will let
              you play with expansions in the "." directory, tossing the matches into a
              "new" buffer. Note that it lets you edit the command line before executing
              it.
              cnoreab %% <C-R>="new\|put!=glob('".expand('#:p')."')"<CR>

              And for deleting the paths from the above output for readability:
              cmap %f %s+\f*[\\/]++<CR>

              [I couldn't figure out how to do both in one step without losing the ability
              to edit the pathname being globbed.]
            Your message has been successfully submitted and would be delivered to recipients shortly.