Vim question

Alec Shaw shaw.alec at gmail.com
Tue Jan 13 20:41:19 MST 2009


Every so often I have files with spaces in their names and I want to 
rename them with underscores for the spaces.
The way I have normally done the the renaming is by putting the output 
of an ls into a file and editing the file in vim
to make it into a script.
I usually do ":g/.*/s//mv & &/ " and then hand editing the paces to 
underscores in the third column.
There has to be a better way.
Is it possible to have vim do the substitution on the third column 
without affecting the first column?
Actually as I think about it maybe a bash or ksh (after years of use ksh 
is still my preferred shell) script
would be better.  Maybe a "for f in *; do mv $f $g; done" but how do I 
get $g from $f with spaces substituted?

Thanks for any suggestions.
Alec Shaw



More information about the PLUG mailing list