- 普通模式下输入:h rename-files
Renaming files *rename-files*
Say I have a directory with the following files in them (directory picked at
random :-):
buffer.c
charset.c
digraph.c
...
and I want to rename *.c *.bla. I'd do it like this:
$ vim
:r !ls *.c
:%s/\(.*\).c/mv & \1.bla
:w !sh
:q!
==============================================================================
- :r !ls *.c 将文件名读入缓冲区
- :%s/(.).c/mv & \1.bla 中(.)明显就是分组啦,\1就是后向引用,$应该是引用前面的整个内容吧,这个之前没有看到过,mv就是重命名啦
- :w !sh 在当前shell中执行当前缓冲区的每行内容