2014-01-23 74 views
1

我得到了极好的bookmarks.vim插件给我的vim。我特别喜欢命名的书签并使用QuickFix窗口列出它们。如何在选择QuickFix窗口中的项目后关闭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 
+0

听起来好像它可能有帮助:一种切换quickfix窗口的手段(如果它打开,关闭它,如果不是,打开它)在http://vim.wikia.com/wiki/Toggle_to_open_or_close_the_quickfix_window给出。 –

+0

@ebenezer我会保留这一个在现在的后门。我有''和''映射为在上下窗口和'F3'映射之间移动以退出,所以' F3'与给定的解决方案一样少/许多按键。 –

回答

2

覆盖了在quickfix窗口用来选择一个条目<CR>映射:

:autocmd FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR> 

注:如果你不希望这个应用到位置清单做,你需要调整映射一下。