簡體   English   中英

quickfix-window中的光標突出顯示:QuickFixCmdPre覆蓋QuickfixCmdPost?

[英]Cursor-highlighting in quickfix-window: QuickFixCmdPre overriding QuickfixCmdPost?

我希望我的quickfix窗口能夠對當前光標行進行一些突出顯示。

經過一些研究后,我發現我可以使用set cursorline配置當前行的一般外觀並highlight CursorLine term=bold cterm=bold guibg=Grey40

現在,當我在quickfix窗口時,我只想要那個。 所以我開始在函數中包含這兩行,並使用自動命令調用該函數:

au QuickFixCmdPre * call EnableSearchHighlighting()

到現在為止還挺好。 因為我在搜索至少一次之后仍然激活突出顯示,我需要再次禁用該效果。 這就是我被困的地方 ......

我寫了另一個函數來set nocursorline並在QuickFixCmdPost -Event上調用它。 但由於某種原因,這打破了一切。 現在我不會再突出顯示了,甚至在quickfix窗口中也沒有。

感覺就像后事件會覆蓋事件前的事件。 我不知道還有什么可以嘗試的。

也許任何人都可以幫助我,甚至還有另一種方法來突出顯示?

這是完整的代碼,因為它現在在我的.vimrc中:

function EnableSearchHighlighting()
  set cursorline
  highlight CursorLine term=bold cterm=bold guibg=Grey40
endfunction

function DisableSearchHighlighting()
  set nocursorline  
endfunction

au QuickFixCmdPre * call EnableSearchHighlighting()
au QuickFixCmdPost * call DisableSearchHighlighting()

謝謝閱讀。 :)

您的方法存在許多問題,但主要問題(以及它不起作用的原因)是在切換到錯誤窗口之前,每個quickfix命令都運行QuickFixCmdPreQuickFixCmdPost

將其添加到文件ftplugin/qf.vim

setlocal cursorline

然后在任何函數或autocmd之外的vimrc添加highlight定義:

highlight CursorLine term=bold cterm=bold guibg=Grey40

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM