12

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

1
  • Are we talking windows or buffers? Cause I'm looking for something similar but for buffers.
    – Adrien
    Commented Nov 27, 2019 at 16:47

4 Answers 4

4
: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.

1
  • lclose does not close quickfix lists, so this would not work for those.
    – trysis
    Commented Mar 17, 2017 at 14:03
4

I map this to <F11>:

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

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

0
: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.

1
  • Reread the question, he's asking to close all of the quick fix windows, not close everything but them.
    – deterb
    Commented Jun 6, 2014 at 14:42
0

:ccl | lcl

Map it to <Leader>c:

noremap <Leader>c :ccl <bar> lcl<CR>

1
  • 1
    This will only close one location list: the one for the active window, if one exists.
    – ches
    Commented Feb 6, 2015 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .