我将出色的bookmarks.vim插件添加到了vim。我特别喜欢命名的书签,并使用QuickFix窗口列出它们。
在显示书签列表的代码中,我想添加一些使QuickFix窗口在我选择一个选项后关闭的功能。我怎么做?
" 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
覆盖<CR>
在quickfix窗口中用于选择条目的映射:
:autocmd FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR>
注意:如果您不希望将其应用于位置列表,则需要对映射进行一些调整。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句