Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter cscope output within Vim

Tags:

vim

cscope

I am looking for a way to grep the output of cscope queries from Vim.

The following didn't work for me:

:cs f s symbol !grep pattern

It gave:

E259: no matches found for cscope query s symbol !grep pattern ...

P.S:
I know the redir method, I am looking for a simpler way to filter
output of ex command(s) through Unix commands.

like image 669
Aman Jain Avatar asked Sep 08 '11 21:09

Aman Jain


1 Answers

You can use :redir to send message output to a register or file.

redir @c
cs f s symbol
redir END

Now you can put the c register into a file and filter it.

I don't get much output from cscope (it's all in the quickfix), but that will do what you're describing.


In general, you can filter shell commands (see :help :!cmd) with | (bar):

:!echo 0updateView | cscope -dl | grep global

But ex commands interpret bar as a command separator (so you can put multiple commands on one line):

:if &ft != 'help' | silent! cd %:p:h | endif

I don't think you can filter the output of ex commands aside from using redir. However, you could use Benoit's answer to filter the quickfix.

like image 61
idbrii Avatar answered Nov 19 '22 08:11

idbrii