4

I have a command-line tool that can print search results in a format that works with vimgrep. The example output looks like this:

foo/path/lib/usdviewq/appController.py:3795:22:        index = prim.GetPrimIndex()
foo/bar/lib/testenv/testUsdSpecializes.py:104:28:            refNode = prim.GetPrimIndex().rootNode.children[0]
foo/bar/lib/testenv/testUsdInherits.py:108:28:            refNode = prim.GetPrimIndex().rootNode.children[0]
foo/bar/lib/testenv/testUsdPrims.py:720:14:    def test_GetPrimIndex(self):
foo/bar/lib/testenv/testUsdPrims.py:722:43:            s = Usd.Stage.CreateInMemory('GetPrimIndex.'+fmt)
foo/bar/lib/testenv/testUsdPrims.py:739:34:            self.assertTrue(prim.GetPrimIndex().IsValid())
foo/bar/lib/testenv/testUsdPrims.py:740:34:            self.assertTrue(prim.GetPrimIndex().DumpToString())
foo/bar/lib/testenv/testUsdPrims.py:745:35:            self.assertFalse(prim.GetPrimIndex().IsValid())
foo/bar/lib/testenv/testUsdPrims.py:746:35:            self.assertFalse(prim.GetPrimIndex().DumpToString())
foo/bar/lib/testenv/testUsdInstancing.py:101:18:        s = prim.GetPrimIndex().DumpToString()
foo/bar/lib/testenv/testUsdEditTarget.py:40:26:        primIndex = prim.GetPrimIndex()
foo/bar/lib/testenv/testUsdReferences.py:275:28:            refNode = prim.GetPrimIndex().rootNode.children[0]
foo/bar/lib/testenv/testUsdTimeOffsets.py:288:27:            refNode = foo.GetPrimIndex().rootNode.children[0]
foo/bar/lib/testenv/testUsdTimeOffsets.py:306:31:            payloadNode = foo.GetPrimIndex().rootNode.children[1]

Is there any way to feed that as input into Vim as a quickfix window?

I tried doing

command_that_makes_these_lines | vim -

But that only adds that given text to a Vim buffer.

  • Perhaps vim -c will help you. – Alex Kroll Aug 31 at 7:31
  • 2
    vim -q [filename] Unfortunately, stdin is not supported. – Matt Aug 31 at 11:27
8

Vim has a startup option -q to read a quickfix file. So we have options (depending on your shell):

cmd > results
vim -q results

Or my favorite

vim -q <(cmd)
3

If you'd like to invoke the command from inside Vim and populate the quickfix window with its output, you can use :cexpr together with system() or systemlist().

:cexpr system('command_that_makes_these_lines')

See also :cgetexpr for a version that doesn't jump to the first result (you might want to combine that with |copen to show the quickfix window with the results.)

Also, :lexpr and :lgetexpr can be used, to use the location window instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.