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.

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
kenorb
  • 18,433
  • 18
  • 72
  • 134

2 Answers2

24

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.

toro2k
  • 4,882
  • 1
  • 31
  • 35
0

These commands also works:

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

Related:

kenorb
  • 18,433
  • 18
  • 72
  • 134
  • 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