When I use a command like vim -s script *.cfg it stops at the end of first file stating that there are x files left to edit and not executing the script in the remaining matching files.

script contains commands to format files and works when passing single file as argument.

What is the correct format to include all files with similar name and edit with same script file?

  • I don't want to open all files simultaneously i want to edit all .cfg files with the script but without entering their names one by one.
    – Magesh
    Commented Jan 24, 2019 at 6:03

1 Answer 1


Your vim script has to handle the looping through the buffer list. Or maybe you can handle it with :bufdo, see :help :bufdo.


for file in *.cfg; do
    vim -s scriptin "$file"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.