Open all files matching a pattern in vim

Nov 10, 2017 using tags vim

It is sometimes desirable to open all files of a specific type in vim. Say I wanted to manually edit all the .md files from this repository in vim, I could try and manually open each one but vim has a better way of doing this.

Inside a vim buffer, :args *.md will open all the markdown files in the current directory. The file argument accepts globs so :args **/*.md will recursively open all markdown files starting from the current directory.

Few tips to navigate a large set of buffers in vim:

  • :ls list all open buffers
  • :bn to move to the next buffer
  • :bd to delete the current buffer
  • :qa to close all the buffers and exit vim
  • :qa! to close all the buffers and exit vim, forsaking any changes you made