在VIM中检测快速修复缓冲区是否存在

7

简单的问题(我希望如此)。这让我很烦恼。我试图在我的vimrc中创建一个简单的脚本来映射:

<Leader>e

以打开快速修复窗口。如果当前已经打开了快速修复窗口,我还想使用该键组合关闭快速修复窗口。

问题是,bufexists命令似乎会跳过快速修复缓冲区。请问您如何检测是否已经打开了快速修复窗口?

1个回答

8

:cwindow 命令可能是你要找的。以下是帮助信息:

                            *:cw* *:cwindow*
:cw[indow] [height] Open the quickfix window when there are recognized
                    errors.  If the window is already open and there are
                    no recognized errors, close the window.

然而,如果你想关闭快速修复窗口即使仍然存在错误,则可以查看此Vim提示,其中提供了以下片段:

command -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
  if exists("g:qfix_win") && a:forced == 0
    cclose
    unlet g:qfix_win
  else
    copen 10
    let g:qfix_win = bufnr("$")
  endif
endfunction

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接