Thursday, October 25, 2012

Help with vim scripting

I already posted this once but I don't see it on the list yet so I am posting it again.

Hello!
I have written a shell script that uses vim to read in a file, edit it, and write it out again. If I manually enter the vim commands it works correctly but if I put the commands into a script and read that, the edit commands do not produce the same result. I am attempting to read in a directory listing and replace each space in a file pathname with a \space. HELP!
Thanks!
Michael

#!/bin/sh

# Generate a recursive list of full pathnames for all filenames that do not # begin with a "."
find "$1" -type f -and \! -name ".*" > filelist1

# Generate the input script for the vim editor
# Go through the "find" listing and replace every " " with "\ "
cat << EOF > vimscript
:%s/ /\\ /g
:wq! md5shell
EOF

# Execute vim with the generated input script
vim -s vimscript filelist1

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: