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

How to filter input in a buffer in a script?

Expand Messages
  • Martin Lundberg
    Hi, Plugins like fuzzyfinder and command-t makes it possible to get a list of files and then filter that list by typing in a pattern. The pattern you type is
    Message 1 of 6 , Oct 10, 2010
    • 0 Attachment
      Hi,

      Plugins like fuzzyfinder and command-t makes it possible to get a list
      of files and then filter that list by typing in a pattern. The pattern
      you type is showed to the user at the same time as the list in the
      buffer is removing filenames (lines).

      I'm want to do the same with buffers in vim script. I've come as far
      as creating a buffer (botright) and setting some local options with
      setlocal. Now, how can I let the user enter a pattern, act on that
      pattern and also show it to the user at the same time?

      Thanks in advance!

      -Martin

      --
      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
    • Michael Henry
      ... You may find that LustyExplorer suits your needs: http://www.vim.org/scripts/script.php?script_id=1890 From the above page: It includes a filesystem
      Message 2 of 6 , Oct 10, 2010
      • 0 Attachment
        On 10/10/2010 05:55 AM, Martin Lundberg wrote:
        > Hi,
        >
        > Plugins like fuzzyfinder and command-t makes it possible to get a list
        > of files and then filter that list by typing in a pattern. The pattern
        > you type is showed to the user at the same time as the list in the
        > buffer is removing filenames (lines).
        >
        > I'm want to do the same with buffers in vim script.

        You may find that LustyExplorer suits your needs:
        http://www.vim.org/scripts/script.php?script_id=1890

        From the above page:
        """
        It includes a filesystem explorer, a buffer switcher, and a
        buffer grep for searching through and switching between files
        and buffers quickly, all through a mostly common interface.
        """

        It works similarly to command-t (which I also use and like).

        While searching for LustyExplorer's link on vim.org, I
        encountered the following additional plugins. I've not tried
        them yet, but they seem to provide similar functionality:

        QuickBuf:
        http://www.vim.org/scripts/script.php?script_id=1910

        QuickName:
        http://www.vim.org/scripts/script.php?script_id=2317

        qnamebuf (a merging of QuickName and QuickBuf):
        http://www.vim.org/scripts/script.php?script_id=3217

        Michael Henry

        --
        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
      • Tom Link
        ... tlib s[1] tlib#input#List() function does the same in vim script. In conjunction with tselectfiles[2] it provides a similar features as command-t -- from
        Message 3 of 6 , Oct 10, 2010
        • 0 Attachment
          > I'm want to do the same with buffers in vim script.

          tlib's[1] tlib#input#List() function does the same in vim script. In
          conjunction with tselectfiles[2] it provides a similar features as
          command-t -- from what I can tell.

          IMHO the main question is whether you want to call the function
          synchronously (in this case your will probably have to read the
          characters with getchar() in a loop) or asynchronously (in this case
          you could also use buffer local maps and map all unwanted keys to
          something that doesn't do anything at all).

          Regards,
          Tom


          [1]
          http://www.vim.org/scripts/script.php?script_id=1863
          http://github.com/tomtom/tlib_vim

          [2]
          http://www.vim.org/scripts/script.php?script_id=1865
          http://github.com/tomtom/tselectfiles_vim

          --
          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
        • Martin Lundberg
          Thanks both of you! I will take a look at the scripts you listed. Just want to make clear I m not looking so much for a plugin which can do this for me as I am
          Message 4 of 6 , Oct 10, 2010
          • 0 Attachment
            Thanks both of you! I will take a look at the scripts you listed. Just
            want to make clear I'm not looking so much for a plugin which can do
            this for me as I am to learn how to do it myself in vim script so no
            python/ruby plugins :)

            On 10 Okt, 13:07, Tom Link <micat...@...> wrote:
            > > I'm want to do the same with buffers in vim script.
            >
            > tlib's[1] tlib#input#List() function does the same in vim script. In
            > conjunction with tselectfiles[2] it provides a similar features as
            > command-t -- from what I can tell.
            >
            > IMHO the main question is whether you want to call the function
            > synchronously (in this case your will probably have to read the
            > characters with getchar() in a loop) or asynchronously (in this case
            > you could also use buffer local maps and map all unwanted keys to
            > something that doesn't do anything at all).
            >
            > Regards,
            > Tom
            >
            > [1]http://www.vim.org/scripts/script.php?script_id=1863http://github.com/tomtom/tlib_vim
            >
            > [2]http://www.vim.org/scripts/script.php?script_id=1865http://github.com/tomtom/tselectfiles_vim

            --
            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
          • Martin Lundberg
            I m confused and don t really know where to start. Most of the examples are too complex. Would really appreciate if someone could write some simple basic code
            Message 5 of 6 , Oct 10, 2010
            • 0 Attachment
              I'm confused and don't really know where to start. Most of the
              examples are too complex.

              Would really appreciate if someone could write some simple basic code
              that does the basics of fetching the pattern, showing it to the user
              and calling a method giving it the pattern. From there I can evolve.
              But maybe it's just that it is complex and it's not possible to make a
              simple example. I'll keep looking into the scripts trying to
              understand it.

              On 10 Okt, 13:45, Martin Lundberg <martin.lundb...@...> wrote:
              > Thanks both of you! I will take a look at the scripts you listed. Just
              > want to make clear I'm not looking so much for a plugin which can do
              > this for me as I am to learn how to do it myself in vim script so no
              > python/ruby plugins :)
              >
              > On 10 Okt, 13:07, Tom Link <micat...@...> wrote:
              >
              >
              >
              >
              >
              >
              >
              > > > I'm want to do the same with buffers in vim script.
              >
              > > tlib's[1] tlib#input#List() function does the same in vim script. In
              > > conjunction with tselectfiles[2] it provides a similar features as
              > > command-t -- from what I can tell.
              >
              > > IMHO the main question is whether you want to call the function
              > > synchronously (in this case your will probably have to read the
              > > characters with getchar() in a loop) or asynchronously (in this case
              > > you could also use buffer local maps and map all unwanted keys to
              > > something that doesn't do anything at all).
              >
              > > Regards,
              > > Tom
              >
              > > [1]http://www.vim.org/scripts/script.php?script_id=1863http://github.com...
              >
              > > [2]http://www.vim.org/scripts/script.php?script_id=1865http://github.com...

              --
              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
            • Tony Mechelynck
              ... I m not sure what you actually want to do. OTOH, Vim works best if you don t come to it with preconceived ideas about how to do what you want done. This
              Message 6 of 6 , Oct 10, 2010
              • 0 Attachment
                On 10/10/10 23:12, Martin Lundberg wrote:
                > I'm confused and don't really know where to start. Most of the
                > examples are too complex.
                >
                > Would really appreciate if someone could write some simple basic code
                > that does the basics of fetching the pattern, showing it to the user
                > and calling a method giving it the pattern. From there I can evolve.
                > But maybe it's just that it is complex and it's not possible to make a
                > simple example. I'll keep looking into the scripts trying to
                > understand it.

                I'm not sure what you actually want to do. OTOH, Vim works best if you
                don't come to it with preconceived ideas about how to do what you want done.

                This said, would

                :g/pattern/p

                be something you could use?

                see
                :help :g
                :help pattern.txt
                " and in particular
                :help pattern-overview " (the whole section)
                :help :p


                Nest regards,
                Tony.
                --
                LARGE MAN: Who's that then?
                CART DRIVER: (Grudgingly) I dunno, Must be a king.
                LARGE MAN: Why?
                CART DRIVER: He hasn't got shit all over him.
                "Monty Python and the Holy Grail" PYTHON (MONTY)
                PICTURES LTD

                --
                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.