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/$/\"/"))
This seems clunky, especially since it seems that the eval $(echo $())
indirection should not be necessary Perhaps there is a better way that does
not rely on those shell commands?
Tip 1212 <http://www.vim.org/tips/tip.php?tip_id=1212> seemed like it might
apply (using isfname), but initial attempts to use vim --cmd did not seem to
work. Variations like the following all seemed to fail, and may indicate
that isfname is not used to process command line arguments that are file
names, but it also could mean I just don't know what I am doing ;-)
$ vi --cmd ":set isfname+=32" $(find . -name Entries | sed -e "s/ /\\\ /")
$ vi --cmd "set isfname+=32" $(find . -name readme.txt | sed -e "s/^/\"/"
-e "s/$/\"/")
It might be helpful to see what, exactly, you want to do with the
files. However, to answer the direct question (that of opening files
with spaces in them), you could do something like this from within VIM
itself:
:for file in split(globpath('.', '**/*.txt'), "\n")|argadd `=file`|endfor|rewind
That command will search for all *.txt files under the current
directory (and all its subdirectories) and add them to the arg list,
regardless of spaces in the path names.
Hope that helps,
Bob