Post

How to use bufdo in Neovim

How to use Neovim bufdo command to perform bulk edits across multiple YAML files matching a glob pattern.

  • Find all YAML files that satisfy a pattern, open them in Vim and delete each line that contains a specific string.

The :bufdo command runs an Ex command across all open buffers. Combined with :g/pattern/d, it deletes every matching line in every file. The | update part saves each buffer after the deletion. This is a fast way to bulk-remove lines from many files at once without leaving Vim.

1
2
v organization/*/*/*/*/XZY*.yaml
:bufdo exe "g/bigtable.googleapis.com/d" | update
This post is licensed under CC BY 4.0 by the author.