I find myself performing a small shell loop (involving
vim) to transform files into the correct line endings for my system. It looks as follows:
for i in *; do vim -c 'set ff=dos' -c 'wq' $i; done
It works. The problem is that the terminal flashes during the loop as vim opens and closes repeatedly. There should be a more elegant way to perform this.
Attempt 1 (-e -s)
for i in *; do vim -e -s -c 'set ff=dos' -c 'wq' $i; done
but it is not doing what I believed it would do.
set ff= is an
ex command alright, and the command above works if I do not include
-s. But if I leave
-s out it opens and closes vim just like the original command.
Attempt 2 (:argdo)
I'm afraid of
argdo because I never understood how it can perform changes to several buffers without writing them back to disk. And I just run into this exact issue in this attempt. I open all files with
vim * and try:
:argdo set ff=unix
But after changing the current file I get:
E37: No write since last change (add ! to override)
I'm probably missing something simple in both attempts. I'm very keen on finding a good solution for attempt 1, since it is easier to automate.
What is the elegant way of performing such a multi-file conversion in vim?