How to run a series of vim commands from command prompt

后端 未结 5 1505
野的像风
野的像风 2021-01-30 16:17

I have four text files A.txt, B.txt, C.txt and D.txt I have to perform a series of vim editing in all these files. Currently how I am doing is open each files and do the same vi

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 17:04

    JimR and Ingo have provided excellent answers for your use case.

    Just to add one more way to do it, however, you could use my vimrunner plugin to script the interaction in ruby: https://github.com/AndrewRadev/vimrunner.

    Example:

    vim = Vimrunner.start
    
    vim.edit "file.txt"
    vim.insert "Hello"
    vim.write
    
    vim.kill
    

    This can be useful for more complicated interactions, since you get the full power of a programming language.

提交回复
热议问题