Is there a way to close all locations lists and quick fix windows with a single command in vim/gvim?
4 Answers
: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.
-
lclose
does not close quickfix lists, so this would not work for those.– trysisCommented Mar 17, 2017 at 14:03
I map this to <F11>:
nmap <F11> :windo lcl\|ccl<CR>
Basically: In each window, run lcl
(close location list) and ccl
(close quickfix)
:windo if &buftype != "quickfix" | 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.
-
Reread the question, he's asking to close all of the quick fix windows, not close everything but them.– deterbCommented Jun 6, 2014 at 14:42
:ccl | lcl
Map it to <Leader>c
:
noremap <Leader>c :ccl <bar> lcl<CR>
-
1This will only close one location list: the one for the active window, if one exists.– chesCommented Feb 6, 2015 at 15:08