20

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.

2 Answers 2

23

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:

3
  • Are there effective differences between using this or :qa? Feb 20, 2015 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, 2015 at 12:00
  • Okay :-) Just curious if this would somehow behave subtly different or something... Feb 20, 2015 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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