Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So far I've been using vim */** which seems to open all files in subdirectories but not those in the current directory, and vim * which opens all files in the current directory. But how do I open all files in the current directory and all subdirectories?

share|improve this question
up vote 5 down vote accepted

With zsh:

vim ./**/*(.)

Other shells:

find . \( -name '.?*' -prune \) -o -type f -exec vim {} +

To open only the (non-hidden) regular files (not directories, symlinks, pipes, devices, doors, sockets...).

vim ./**/*(D-.)

Other shells, GNU find:

find . -xtype f -exec vim {} +

To also open hidden files (and traversing hidden directories) and symlinks to regular files.


vim ./***/*(D-.)

other shells:

find -L . -type f -exec vim {} +

to also traverse symlinks when looking into subdirectories.

If you only want one level of subdirectories:

vim ./* ./*/*

Note that it's a good habit to prefix your globs with ./ in case some of the file names start with - or +.

(of course the find ones also work in zsh. Note that they may run several instances of vim if the list of files is big).

share|improve this answer

In bash with shopt -s extglob:

for file in **/**; do [[ -f "$file" ]] && vim "$file"; done

Note that, as per Stéphane's comment, prior to Bash 4.3 this would follow any symlinks in the directories covered.

share|improve this answer
That runs one vim per file though. Note that bash before 4.3 used to traverse symlinks with **. It's been fixed in 4.3. – Stéphane Chazelas Aug 9 '14 at 7:17
@StéphaneChazelas Is one vim per file bad per se (assuming we are talking about several files, rather than several hundred)? Thanks for the note about the symlinks: I'll edit that in. – jasonwryan Aug 9 '14 at 7:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.