puk
puk

Reputation: 16752

How to pass the result of find to vim's argadd command

I previously found out, and posted, about how to load multiple buffers using :argadd instead of :badd. However, I would further like to add all files of all subdirectories matching a certain pattern. My current attempt looks like so:

:argadd !find . -name *.js -type f

But that adds

 51      "!find"                        line 1
 52      "~/Documents/neuro-sim/website/3.0" line 1
 53      "-name"                        line 1
 54      "*.js"                         line 1
 55      "-type"                        line 1
 56      "f"                            line 1

to the buffer. What modification do I have to make to make this work?

Upvotes: 7

Views: 1627

Answers (2)

rupert160
rupert160

Reputation: 1531

You need backticks "`" to evaluate the find and plug them into args. I agree it does seem strange to not use "!" but I think that is for handling stream buffers not args...

:arga `find . -name '*glob_pattern*'`

Upvotes: 0

Zsolt Botykai
Zsolt Botykai

Reputation: 51593

But why don't you do it with

:args **/*.js 

(Yeah, I know you can't filter for files this way...)

HTH

Upvotes: 6

Related Questions