Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save the files opened in all windows and tabs in Vim?

Tags:

vim

I’d like to save the files opened in all vertical/horizontal windows? Is it possible without going to each window and executing the :w! command?

like image 888
vehomzzz Avatar asked Dec 13 '10 13:12

vehomzzz


People also ask

How do I save and quit all tabs in Vim?

:wa - save all tabs / unsaved buffers. :xa / :wqa - save all tabs / unsaved buffers and exit Vim.

How do I save a Vim file to my computer?

The command to save a file in Vim is :w . To save the file without exiting the editor, switch back to normal mode by pressing Esc , type :w and hit Enter . There is also an update command :up , which writes the buffer to the file only if there are unsaved changes.

How do I save a workspace in Vim?

So if you only want to have only one session saved in your current directory, you can use :mksession or :mks from vim to save your current session, and just vim -S to open it back up.


1 Answers

To save only those buffers that opened in the current tab page and not those that are hidden, run the :write command for every open window:

:windo w!

In order to save all open buffers regardless of the corresponding windows’ locations, run the :wall command:

:wa!

There is also a similar command

:bufdo w!

but it does not behave in quite the same fashion. Both commands affect hidden buffers, but :wall does not attempt to write the buffers that do not have a file name set.

like image 179
ib. Avatar answered Oct 14 '22 06:10

ib.