On 8/24/06, Bulgrien, Kevin <[EMAIL PROTECTED]> wrote:
At various times it is useful to launch vim with a file list that has been
generated by a command so that buffers and macros written on the fly are
able to be used on a number of files. A trivial, though questionably useful,
example that normally works might be:
$ vim $(find . -iname "readme.txt")
The above command fails when spaces occur in path and file names, and the
following variation has been found to work in the BASH shell.
$ eval $(echo vi $(find . -iname "readme.txt" | sed -e "s/^/\"/" -e
"s/$/\"/"))
1. Try this:
find -name "* *" | vim+
Where vim+ is a script which reads names of the files
from stdin, 1 filename per line. Text of vim+ script is below.
2. Essentially this is not vim question but shell question.
Same problem exists for any unix utility not just vim (grep, wc etc).
3. You write:
$ vim $(find . -iname "readme.txt")
The above command fails when spaces occur in path and file names,
I have great doubts that command 'find -iname "readme.txt"' could
ever match filenames with spaces.
Yakov
-------------- vim+ ------------------------------
#!/bin/sh
# vim+ -- script that collects file names from stdin,
# one filename per line,
# then invokes vim with given filenames.
# Handles spaces in filenames properly.
# collect filenames from stdin, properly quoted
FILES=`sed -e "s/^/\"/" -e "s/$/\"/"`
eval exec vim <&1 "$@" $FILES
-------------------------------------------------------