When invoking vim through find | xargs, like this:
find . -name "*.txt" | xargs vim
you get a warning about
Input is not from a terminal
and a terminal with pretty much broken behaviour afterwards. Why is that?
|
When you invoke a program via $ true | xargs filan -s 0 chrdev /dev/null 1 tty /dev/pts/1 2 tty /dev/pts/1 $ true | xargs ls -l /dev/fd/ Vim expects its stdin to be the same as its controlling terminal, and performs various terminal-related ioctl's on stdin directly. When done on
You could consider this a bug in Vim, since it can open |
||||
|
|
|
Following on from grawity's answer, From OSX/BSD
-o Reopen stdin as /dev/tty in the child process
before executing the command. This is useful
if you want xargs to run an interactive application.
Thus the following line of code should work for you: find . -name "*.txt" | xargs -o vim For GNU find . -name "*.txt" | xargs bash -c '</dev/tty vim "$@"' |
|||||
|
|
|
Use GNU Parallel instead:
Or if you want to open all the files in one go:
It even deals correctly with filenames like:
Watch the intro video to learn more: http://www.youtube.com/watch?v=OpaiGYxkSuQ |
|||||||||||||||
|
|
It should work just fine if you use the -exec option on find rather than piping into xargs. E.g
|
|||
|
findorxargsat all. Open vim with no arguments, then run:args **/*.txt<CR>to set vim's arguments from inside the editor. – Trevor Powell Mar 21 at 13:26