I would like to find multiple files and open them all in tabs within the same vim instance.
2 Answers
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
.
find "$PWD" -name '*.txt' -exec vim -p {} +
-
2
-
-
-
This is the better way. The other way is easily broken if filenames have spaces, or special characters in them.– muruApr 24, 2016 at 18:00
-
This approach (using the -exec switch) seems to work also when files contain spaces. Sep 2, 2021 at 9:44
locate
multiple files and open them in vim?find
command and return multiple files