For a time I have one vim configuration on my laptop and another on my desktop, so when I edited filed on my Dropbox between the two I would end up with format issues.
Specifically, I had ffs=mac,unix,dos
on one and ffs=unix,dos
on the other.
Now thankfully that setup is fixed! Yet stragglers remain (those files which haven't been opened, and converted and saved with the new setup).
Now sometimes when I open a file from where it was saved with an ff of "mac", I get a bunch of ^M
.
So I do:
e ++ff=mac
setlocal ff=unix
w
To correct the issue.
What works to do this 3 line procedure automatically everytime I open a file?
Or even better how could it work to do it automatically everytime I open a file which has an ff that is not unix?
I've Googled [vim task on every buffer open] and [vim macro on every file open] and haven't seen anything that works.
(I'm sure vim in its seemingly infinite wisdom has something just for this, as it seems to have something just for anything [how did they imagine and make all these features?!].)
grep -rlIP '[\x0d]' *
to find the affected files and runningdos2unix
on them.