10

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
    Nov 27 '19 at 16:47
3
: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
    Mar 17 '17 at 14:03
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)

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
    Jun 6 '14 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
    Feb 6 '15 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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