Close all locations list or quick fix windows in vim

Is there a way to close all locations lists and quick fix windows with a single command in vim/gvim?


Solution 1:

:windo if &buftype == "quickfix" || &buftype == "locationlist" | lclose | endif

That will execute the :lclose command in all windows not displaying quickfix or location lists. I didn't have a set of location lists to test it with, so I tested with a different buffer type and it worked for that case.

You will probably want to make it a command or shortcut in your .vimrc as well.

Solution 2:

I map this to <F11>:

nmap <F11> :windo lcl\|ccl<CR>

Basically: In each window, run lcl (close location list) and ccl (close quickfix)