Populate arglist with files, exclude directories

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Populate arglist with files, exclude directories

Jason Franklin-2
Greetings,

I'm having trouble finding a clean way to do this...

In a project directory, I will often use the command below to populate the arglist:

  :args **

This works okay, but it includes directories in the arglist which will be opened with netrw.

Is there a concise, clean method to omit directories from the arglist when populating it with
all files below the current project directory?

--
Jason Franklin

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/51896a1c-47b7-4e8b-b803-e351ac90f40b%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Tim Chase
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200105150052.494caa75%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Johannes Degen
: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 <[hidden email]> 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 [hidden email].
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAN%2Bhyd1VrTwUtnedVPMhBup5L88P129GzyTsCcumoAf2B1dLNw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Tim Chase
On 2020-01-05 22:27, Johannes Degen wrote:
> :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(?)

Did you get more than one result?  I only got one file, testing on
FreeBSD & OpenBSD:

  $ mkdir -p ~/tmp/v/{a,b}
  $ for d in ~/tmp/v/{a,b,} ; echo "$d" > "$d/foo.txt" ; done
  $ cd ~/tmp/v
  $ vim
  :args `=filter(expand('**', v:true, v:true), '!isdirectory(v:val)')`

this opens foo.txt but

  :args

shows that it's the only file in the arg-list, missing "a/foo.txt" and
"b/foo.txt"

whereas

  :args `find . -type f`
  :args

shows all the expected files.

-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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200105154123.48137851%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Richard Mitchell
In reply to this post by Jason Franklin-2
What shell are you using?  I'm guessing bash?  Time to update to zsh

  ls *(.)

will list only regular files.  conversely

  ls -d *(/) will list only directories.

zsh is to bash what tcsh was to csh, but a couple magnitudes more.  oh-my-zsh and iterm2 (if OS X) and you'll never look back.


On Sunday, January 5, 2020 at 10:49:52 AM UTC-5, Jason Franklin wrote:
Greetings,

I'm having trouble finding a clean way to do this...

In a project directory, I will often use the command below to populate the arglist:

  :args **

This works okay, but it includes directories in the arglist which will be opened with netrw.

Is there a concise, clean method to omit directories from the arglist when populating it with
all files below the current project directory?

--
Jason Franklin

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Johannes Degen
It might be a shell thing. I use zsh and yes, I got all the results I expected.

On Mon, Jan 6, 2020 at 1:46 AM Richard Mitchell <[hidden email]> wrote:
What shell are you using?  I'm guessing bash?  Time to update to zsh

  ls *(.)

will list only regular files.  conversely

  ls -d *(/) will list only directories.

zsh is to bash what tcsh was to csh, but a couple magnitudes more.  oh-my-zsh and iterm2 (if OS X) and you'll never look back.


On Sunday, January 5, 2020 at 10:49:52 AM UTC-5, Jason Franklin wrote:
Greetings,

I'm having trouble finding a clean way to do this...

In a project directory, I will often use the command below to populate the arglist:

  :args **

This works okay, but it includes directories in the arglist which will be opened with netrw.

Is there a concise, clean method to omit directories from the arglist when populating it with
all files below the current project directory?

--
Jason Franklin

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com.


--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAN%2Bhyd18Cu3SUW8Yef3QFDB2nOLtf6be3SyxJPv7qHtALK9q6w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Jason Franklin-2
I appreciate the responses from everyone.

However, it seems that the answer to my original question is "no".  There does not appear to be a concise way to do this from the command line.

Thanks!

--
Jason Franklin

On Monday, January 6, 2020 at 9:00:50 AM UTC-5, Johannes Degen wrote:
It might be a shell thing. I use zsh and yes, I got all the results I expected.

On Mon, Jan 6, 2020 at 1:46 AM Richard Mitchell <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TEcKK8PxCwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rwmit...@...> wrote:
What shell are you using?  I'm guessing bash?  Time to update to zsh

  ls *(.)

will list only regular files.  conversely

  ls -d *(/) will list only directories.

zsh is to bash what tcsh was to csh, but a couple magnitudes more.  oh-my-zsh and iterm2 (if OS X) and you'll never look back.


On Sunday, January 5, 2020 at 10:49:52 AM UTC-5, Jason Franklin wrote:
Greetings,

I'm having trouble finding a clean way to do this...

In a project directory, I will often use the command below to populate the arglist:

  :args **

This works okay, but it includes directories in the arglist which will be opened with netrw.

Is there a concise, clean method to omit directories from the arglist when populating it with
all files below the current project directory?

--
Jason Franklin

--
--
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 <a href="http://www.vim.org/maillist.php" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.vim.org%2Fmaillist.php\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_i_vTWvOy2_ml2WNZwm9vDnSvaA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.vim.org%2Fmaillist.php\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_i_vTWvOy2_ml2WNZwm9vDnSvaA&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="TEcKK8PxCwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vim...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vim_use/a867e56e-de7e-404d-91a1-f6def04b2c76%40googlegroups.com.


--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/97ab7f20-c9bd-4983-8a32-ee13cbff61c6%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Benjamin Fritz
Do all the files of interest have an extension in their name? If so, maybe ":args ./**/*.*"

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5a859420-5655-4683-aeec-fa8182aa0f49%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Populate arglist with files, exclude directories

Johannes Degen

>On Tue, Jan 7, 2020 at 3:42 PM Ben Fritz <[hidden email]> wrote:
>Do all the files of interest have an extension in their name? If so, maybe ":args ./**/*.*"

Nice and pretty clean solution!

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