从垂直拆分的quickfix窗口打开项目?

时间:2013-05-24 20:26:48

标签: vim

我知道您可以使用ctrl-w + enter在新的水平窗口中打开quickfix项目。

有没有办法在纵向拆分中从quickfix窗口打开一个项目?

3 个答案:

答案 0 :(得分:10)

这是一个快速且肯定不完美的尝试:

autocmd! FileType qf nnoremap <buffer> <leader><Enter> <C-w><Enter><C-w>L

<leader><Enter>映射仅在quickfix和位置窗口中处于活动状态。它会在水平窗口(<C-w><Enter>)中打开错误/位置,并将其转换为垂直窗口(<C-w>L)。

答案 1 :(得分:7)

QFEnter插件看起来对您有所帮助。 它允许在选定的窗口,新的Vert分割窗口,新的分割窗口或新选项卡中打开quickfix项。

答案 2 :(得分:2)

QFEnter插件(https://github.com/yssl/QFEnter)非常聪明且非常棒,它可以提供更多的内容,并且可以进行高度自定义。它的写得也很好。

接受的解决方案导致窗口抖动,因为它首先打开,然后旋转窗口。

QFEnter插件非常优越,因为功能整洁且完全流畅。

如果您需要较少的功能(仅限分割打开的功能)或由于某种原因您无法或不会安装插件,您可以使用以下vimrc代码段。 它使用了我从QFEnter插件中学到的相同技术,虽然是以非常简单的方式,并且仅使用CtrlP(<C-v><C-x>)提供的相同快捷方式提供垂直和水平分割。

" This is only availale in the quickfix window, owing to the filetype
" restriction on the autocmd (see below).
function! <SID>OpenQuickfix(new_split_cmd)
  " 1. the current line is the result idx as we are in the quickfix
  let l:qf_idx = line('.')
  " 2. jump to the previous window
  wincmd p
  " 3. switch to a new split (the new_split_cmd will be 'vnew' or 'split')
  execute a:new_split_cmd
  " 4. open the 'current' item of the quickfix list in the newly created buffer
  "    (the current means, the one focused before switching to the new buffer)
  execute l:qf_idx . 'cc'
endfunction

autocmd FileType qf nnoremap <buffer> <C-v> :call <SID>OpenQuickfix("vnew")<CR>
autocmd FileType qf nnoremap <buffer> <C-x> :call <SID>OpenQuickfix("split")<CR>
相关问题