将所有vim缓冲区保存到新目录(Save all vim buffers to new directory)

系统教程 行业动态 更新时间:2024-06-14 16:57:17
将所有vim缓冲区保存到新目录(Save all vim buffers to new directory)

我想做一个: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/%:t

All 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

更多推荐

本文发布于:2023-04-12 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/5bf326246d6154b802425cba84fb2c2f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   到新   目录   vim   buffers

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!