2

I would like to find multiple files and open them all in tabs within the same vim instance.

2
6
vim -p `find . -name '*.txt'` 

Putting the find command between backticks executes find before running the full command and the results replace what's between the backticks. So before running the full command it will have this form vim -p result1 result2 ... resultN .

1
  • This seems to fail if the filenames contain spaces. Sep 2 at 9:40
5
find "$PWD" -name '*.txt' -exec vim -p {} +
5
  • 2
    vim -p `find . -name '*.txt'` Oct 8 '15 at 14:41
  • I like that more. If you post it as an answer I'll accept it.
    – andorov
    Oct 8 '15 at 14:59
  • Ok, will do that. Oct 8 '15 at 15:10
  • This is the better way. The other way is easily broken if filenames have spaces, or special characters in them.
    – muru
    Apr 24 '16 at 18:00
  • This approach (using the -exec switch) seems to work also when files contain spaces. Sep 2 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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