How to set fileformat = unix for all opend files in vim?

I want to change the fileformat of all files.

Therefore, I open them using vim * .

Then I want to know if there is any easy way to do this, and not print :set fileformat=unix and :w for each file one at a time.

+4
source share
3 answers

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. 
+2
source

argdo is what you want, not bufdo , since you want to do this on every argument, and you don't (necessarily) want to open each file first.

 :argdo set ff=unix | update 

gotta do the trick.

+10
source

Of course, you can do this using the vim recording and playback 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 specify another number. It will stop when it finishes the entire buffer, saying "E165: cannot go beyond the last file." You can get the number of files by running "ls | wc -l" before opening.

+4
source

All Articles