vim: search replace over all writable buffers

前端 未结 3 1214
一生所求
一生所求 2021-01-12 09:25

so

1GvG:s/..../g

can replace over an entire buffer

However, suppose I have multiple vim buffers loaded, and I want to do a :s over

相关标签:
3条回答
  • 2021-01-12 09:59

    Since I can't leave comments, I'll be repeating what Brian said and adding in my 2 cents.

    I believe the command you're looking for is:

    :bufdo :%s/..../g | :w
    

    Note: This will write each file after the changes are made, so make sure you're ready for this.

    If autowrite is on, you should be able to remove the "| :w" at the end of the command.

    0 讨论(0)
  • 2021-01-12 10:01

    Take a look at bufdo. There's also windo and tabdo. Keep in mind that per default Vim doesn't autowrite so for search/replace commands across buffer you need to turn on autowrite.

    0 讨论(0)
  • 2021-01-12 10:05

    Greplace has a feature that supports this. There's also a pathogen ready version on github.

    0 讨论(0)
提交回复
热议问题