rom*_*inl 10
这是一个快速且肯定不完美的尝试:
autocmd! FileType qf nnoremap <buffer> <leader><Enter> <C-w><Enter><C-w>L
Run Code Online (Sandbox Code Playgroud)
该<leader><Enter>映射仅在quickfix和位置的窗口是活动的.它在水平窗口(<C-w><Enter>)中打开错误/位置并将其转换为垂直窗口(<C-w>L).
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>
Run Code Online (Sandbox Code Playgroud)