问题
I want to execute a substitution in vim on around 20 *.C and *.H files, and I want to open them all at once. All files are distributed in multiple nested directories, and the command is executed in the top parent directory. Can I do this using only vim, or do I need the "find" command and the "-p" option as shown on this answer?
回答1:
Start Vim at the root of your project:
$ vim /path/to/project
Add the relevant files to the arglist, recursively:
:argadd **/*.C **/*.H
See
:h starstar
and:h :argadd
.Perform your substitution on every file in the arglist:
:argdo s/foo/bar/gc
See
:h argdo
and:h s_flags
.
来源:https://stackoverflow.com/questions/13877898/is-there-a-way-for-vim-to-open-all-c-and-h-files-in-a-directory-and-all-its-su