15

How to efficiently exit vim when editing multiple files in the split mode at one go?

It seems when I'm having e.g. 10 split windows, I've to repeat 10 times :q! command for each window which is a bit time consuming.

Are there any better methods of quitting the editor?

As for dirty workaround, it can be quit by pressing Control+Z and typing kill %1 to kill it.

19

Use the command :qall!, :qa! for short, or its safer alternative :qall that prevent to discard modified buffers. To save all buffers before quitting use the command :wqall. See :help window-exit for the full set of commands to quit multiple windows at once.

0

These commands also works:

  • :windo :q - executes :q in each window
  • :bufdo :q - executes :q in each buffer

Related:

  • Are there effective differences between using this or :qa? – Martin Tournoij Feb 20 '15 at 11:51
  • @Carpetsmoker No difference other that someone can learn something new. One of advantages is that it allows to execute additional custom commands for each window before closing them, but I can't think of practical example yet. – kenorb Feb 20 '15 at 12:00
  • Okay :-) Just curious if this would somehow behave subtly different or something... – Martin Tournoij Feb 20 '15 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.