This should do the trick:
find . -name "*.txt" -exec vim {} +
Use Vim, it's better for your health. :-)
The oft-overlooked +
option to -exec
makes all filenames (up to line length limits) appear in one line, i.e. you still get all the files opened in one vim
session (navigated with :n
for next and :N
for previous file).
With vim -p
you get a file tab for each file. Check :help tab-page-commands
for more details.
With vim -o
you will get horizontally split windows for each file, vim -O
vertically split windows. Check :help window-move-cursor
for more details.
Note that the previous version of this answer, vim $(find . -name "*.txt")
, does not work with spaces in filenames, and has security implications.
Piping into xargs vi
gives a Warning: Input is not from a terminal
, plus a terminal with completely bogus behaviour afterwards. User grawity explained why in a comment below, and with a bit more explanation in this question.
Related: Terminal borked after invoking Vim with xargs.
– kenorb – 2017-11-16T11:49:47.703Piping to
xargs
destroyed my shell terminal. The proper solution is the one below by @DevSolar – typelogic – 2018-09-13T14:36:02.4301You can pipe it into vi: find . "*.txt" | xargs vi – MaQleod – 2011-09-15T15:55:12.177
1@MaQleod: Technically it would be piping to xargs. – user1686 – 2011-09-15T16:18:47.947