问题
Is there a way to automatically close the current location list in vim when the user selects an entry from it, i.e. navigates to a listed location?
The scenario is: simular to how to open a file in a list of files in vim? I have an external program that creates a list of files/locations that is then loaded using lgetfile. When the list is opened e.g. using lopen 10 the location list window remains open even after a location is selected.
Extended/alternative - I accept any solution that allows me the following: I have a vim command that calls a vim function with one passed param, based on which an external program is called which writes a list of files and locations. I now want to open this list (either in the current window or as split) and be able to select a file (i.e. up/down navigation, enter to select) so that the list is closed and the selected file is opened (much the same was as the plugin buffer explorer works, just with a custom list of files instead of the list of buffers). Is there even a (popular, maintained) plugin that does that for me (which may have added functionality like "open in new tab", "open in split"?)
回答1:
One can use the following mapping.
:autocmd FileType qf nmap <buffer> <cr> <cr>:lcl<cr>
回答2:
If you are using the quickfix window, and e.g.: lopen 10, you can still do :lopen 10 | lcl.
And I'd recommend to read this article in the Vim Wiki(a).
来源:https://stackoverflow.com/questions/10846598/close-location-list-when-selecting-file