I got the wonderful bookmarks.vim plugin to my vim. I especially like the named bookmarks and using the QuickFix window to list them.
In the code to show the bookmark list I'd like to add something that causes the QuickFix window to close after I select a choice. How do I do that?
" Open all bookmarks in the quickfix window
command! CopenBookmarks call s:CopenBookmarks()
function! s:CopenBookmarks()
let choices = []
for [name, place] in items(g:BOOKMARKS)
let [filename, cursor] = place
call add(choices, {
\ 'text': name,
\ 'filename': filename,
\ 'lnum': cursor[1],
\ 'col': cursor[2]
\ })
endfor
call setqflist(choices)
copen
endfunction
Override the <CR>
mapping that is used in the quickfix window to select an entry:
:autocmd FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR>
Note: If you don't want this applied to location lists, you need to tweak the mapping a bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With