On 2014-12-28, Ying Huang wrote:
> Hi,
>     I am using the cscope to search code in vim.
>     The default behaviour, after press ctrl+space+ctrl+space+s is
> split or open a "quickfix"(not sure whether it is) temporarily to
> show the output.
>     What I want is to persist the query result to a file
> /somewhere/<cword>.findresult.
>     I notice some one suggest following way:
>     :redir > filename
>     :cs find f s word
>     :redir end
>     But the shortness for this method is if the result is more than
> one page, I need to manually scroll. Otherwise, only the current page
> would be put into my expected file. Thus it is very inconvenient to
> do this in shell.
>     Any more ideas?
1.  For the problem of scrolling more than one page, you might try
    executing
        :set nomore
    before the :cs command and executing
        :set more
    afterward.  See
        :help 'more'
2.  For the problem of saving a result to a file, are you aware of
    the quickfix stack and the :colder and :cnewer commands?  Vim
    remembers the last ten quickfix error lists and keeps them in a
    stack.  That might work for you if you just want to keep track
    of more than one error list per Vim session.  See
        :help quickfix-error-lists
3.  To really save the results to a file, you could use the
    getqflist() function obtain the results as a list, then save
    that list to a file, perhaps using writefile().  That approach
    will require a bit of programming since the getqflist() list
    format is different from that used by setqflist() and from that
    read by :cfile.  See
        :help getqflist()
        :help writefile()
        :help getqflist()
        :help :cfile
4.  Still another approach to saving the results to a file would be
    to ignore Vim's internal :cscope commands and set 'makeprg' to a
    pipeline or a script that would execute cscope and tee the
    output to a file.  That file could later be read in using
    :cfile.  That approach is probably more than you want to tackle
    unless you are pretty comfortable with 'errorformat' and Vim
    scripting.  It also requires running cscope for each query
    instead of running it as a coprocess as Vim's ":cscope find"
    command does.
Regards,
Gary
-- 
-- 
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 because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment