Save all vim buffers to new directory

421 views Asked by At

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.

1

There are 1 answers

5
Ingo Karkat On BEST ANSWER

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