Marius Gedminas wrote:

> On Wed, Sep 02, 2020 at 07:14:37PM +0000, russurquhart1 via vim_use wrote:
> > I generally use:
> > 
> > :vim `beta: ` **/*.md | copen
> > 
> > To traverse my Markdown files to find those containing 'beta: '.
> > 
> > I need to do the opposite but can get the pattern right. I tried
> > 
> > :vim -v `beta: ` **/*.md | copen
> > 
> > thinking that might work but no dice.
> > 
> > I looked through teh vimgrep help but couldn't find anything.
> > 
> > Does anyone know how to do this?
> 
> Not with vimgrep, but on the command line to find files that don't
> contain a pattern I generally do
> 
>   grep -c "beta: " **/*.md | grep ':0$' | sed -e 's/:0$//'
> 
> this assumes your shell can do ** and it's probably not the most
> elegant/efficient way of doing it, but it's one that I can remember how
> to spell.
> 
> And then I opened the grep manual page to see if there's an easier way,
> and lo and behold:
> 
>        -L, --files-without-match
>               Suppress normal output; instead print the name of each
>               input file from which no output would normally have  been
>               printed.  The scanning will stop on the first match.
> 
> Just what the doctor ordered!

Not exactly.  This switches from reporting matches to reporting file
names with matches.  The output won't be parsed properly.

> To feed these files to to vim you could play with temporarily setting
> 'grepprg', or use :args `grep -L "beta: " **/*.md`
> 
> If your shell doesn't do **, you may need to use something a bit more
> complicated like
> 
>    find -name '*.md' -exec grep -L "beta: " {} +

The grep program has a long list of options, I don't think we will
want to add them all to :vimgrep.  Especially if it's about listing
files with/without matches, there are several other ways to do that.

-- 
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim             (Eljay Love-Jensen)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/202009031450.083Eolqu060864%40masaka.moolenaar.net.

Reply via email to