当我使用ctrl_w ctrl_w
或类似的东西来切换窗口时,我无法停用光标线:
au BufLeave * setlocal nocursorline
手册上说:
BufLeave Before leaving to another buffer. Also when
leaving or closing the current window and the
new current window is not for the same buffer.
Not used for ":qa" or ":q" when exiting Vim.
那么,使用 ctrl_w ctrl_w
时,BufLeave 事件不是会触发吗?
提前非常感谢您!
最佳答案
您的autocmd
对我来说工作得很好,但请注意,它仅在离开缓冲区时触发。如果两个窗口都指向同一个缓冲区,则您没有离开缓冲区,而只是切换到缓冲区上的不同 View 。
我们可以使用以下方法验证这一点:
au BufLeave * echoerr 'BufLeave triggered!'
然后检查:messages
以确定。
在这种情况下,您可能想要使用 WinLeave
自动命令:
au WinLeave * setlocal nocursorline
关于vim - vim ctrl_w 触发的事件是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36195201/