I want change fileformat of all the files.
So I open them use vim *
.
Then I want to know if there is any simple way to do this, rather than typing :set fileformat=unix
and :w
for each file one by one.
argdo
is what you want, not bufdo
, since you want to do it on every argument and you don't (necessarily) want to open every file first.
:argdo set ff=unix | update
should do the trick.
Maybe you need bufdo
?
:help bufdo
bufdo[!] {cmd} Execute {cmd} in each buffer in the buffer list.
It works like doing this:
:bfirst
:{cmd}
:bnext
:{cmd}
etc.
Sure, you can do this using vim record and play feature. Follow these steps
1. Open all files using vim *
2. Press "qq" to start recording
3. :set ff=unix
4. :wn
5. Press again "q" to stop recording
6. Execute like "100@q"
Here 100 is the approximate number of files, but don't worry if you gave more number also. It'll stop when it finishes all buffer saying "E165: Cannot go beyond last file". You can get the number of file is by doing "ls | wc -l" before you open.
dos2unix
?dos2unix
. Why do you think you need to do it in vim?