我想做一个:wa ,但是在新路径下保存所有缓冲区。 我可以让每个缓冲区分别将它们写入新路径,但我希望为所有打开的缓冲区执行此操作。 我实际上并不关心是否所有子路径或绝对路径都被剥离,而且一切都只是在一个目录中。
我打算在vim打开时从shell中删除目录后保存所有打开的vim文件。
I'd like to do a :wa, but save all buffers under a new path. I could to each buffer write them individually to a new path, but I'm looking to do this for all open buffers. I actually wouldn't care if all sub-paths or absolute paths were stripped, and everything was just flatly in one directory.
I'm trying to save all open vim files after deleting the directory from the shell while vim was open.
最满意答案
所有缓冲区都需要:bufdo 。 使用%:t ,您将获得当前缓冲区的文件名(不带路径)。 阅读:help filename-modifiers所有这些的:help filename-modifiers ; 你也可以包括子路径。 Ergo(在/tmp/backup制作副本):
:bufdo write /tmp/backups/%:tAll buffers calls for :bufdo. With %:t, you get the current buffer's filename (without path). Read :help filename-modifiers for all of them; you can include subpaths, too. Ergo (to make copies in /tmp/backup):
:bufdo write /tmp/backups/%:t更多推荐
发布评论