Sunday, January 5, 2020

Re: Populate arglist with files, exclude directories

:args `=filter(expand('**', v:true, v:true), '!isdirectory(v:val)')` works for me (Vim 8.2.74 on OpenBSD 6.6). If you checked on Windows it might mean a Windows related bug(?)

On Sun, Jan 5, 2020 at 10:01 PM Tim Chase <vim@tim.thechases.com> wrote:
On 2020-01-05 06:28, Jason Franklin wrote:
> Is there a concise, clean method to omit directories from the
> arglist when populating it with all files below the current project
> directory?

I was unable to find anything inherent to the "**" token, but at
least on *nix-like platforms you might be able to use

  :args `find . -type f`

as detailed at

  :help backtick-expansion

If you're stuck on Windows without a find(1) command, you *should*
*in theory* be able to do it in pure vim with a bit more typing:

  :args `=filter(expand('**', v:true, v:true), '!isdirectory(v:val)')`

because

  :echo filter(expand('**', v:true, v:true), '!isdirectory(v:val)')

returns the right results.  However I'm not getting this to work.
Can another set of eyes confirm if this is a bug?  I'm basing my
determination on

  :help `=
  """
  You can have the backticks expanded as a Vim expression, instead of
  as an external command, by putting an equal sign right after the
  first backtick
  ...
  When the result is a |List| then each item is used as a name.
  """

So I would expect the ":args `=…`" to work because the filter()
returns a list according to type().

Am I missing something?

-tim





--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200105150052.494caa75%40bigbox.attlocal.net.


--
When in doubt become a philosopher.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAN%2Bhyd1VrTwUtnedVPMhBup5L88P129GzyTsCcumoAf2B1dLNw%40mail.gmail.com.

No comments: