gpt4 book ai didi

vim - 使不活动的拆分 Pane 变暗

转载 作者:行者123 更新时间:2023-12-03 11:55:32 28 4
gpt4 key购买 nike

如果您熟悉 iTerm2 应用程序,您就会知道您可以像 vim 一样 Split View,并且不活动的 View 会“变暗”。

我通常在 vim 中使用三个垂直 Split View,例如,通过将背景颜色设置为较暗的色调来使不活动的 View 变暗会很好。

有没有办法做到这一点?

最佳答案

我想出了以下解决方案(使用'colorcolumn'并取消设置'cursorline'):

" Dim inactive windows using 'colorcolumn' setting
" This tends to slow down redrawing, but is very useful.
" Based on https://groups.google.com/d/msg/vim_use/IJU-Vk-QLJE/xz4hjPjCRBUJ
" XXX: this will only work with lines containing text (i.e. not '~')
function! s:DimInactiveWindows()
for i in range(1, tabpagewinnr(tabpagenr(), '$'))
let l:range = ""
if i != winnr()
if &wrap
" HACK: when wrapping lines is enabled, we use the maximum number
" of columns getting highlighted. This might get calculated by
" looking for the longest visible line and using a multiple of
" winwidth().
let l:width=256 " max
else
let l:width=winwidth(i)
endif
let l:range = join(range(1, l:width), ',')
endif
call setwinvar(i, '&colorcolumn', l:range)
endfor
endfunction
augroup DimInactiveWindows
au!
au WinEnter * call s:DimInactiveWindows()
au WinEnter * set cursorline
au WinLeave * set nocursorline
augroup END

在我的(当前)点文件中查看它: https://github.com/blueyed/dotfiles/blob/master/vimrc#L351

更新
我用它创建了一个插件: https://github.com/blueyed/vim-diminactive

关于vim - 使不活动的拆分 Pane 变暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8415828/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com