tôi đã đưa ra các giải pháp sau đây (sử dụng 'colorcolumn' và unset '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
Xem nó ở tôi dotfiles (hiện tại): https://github.com/blueyed/dotfiles/blob/master/vimrc#L351
Cập nhật tôi đã tạo một plugin trong số đó: https://github.com/blueyed/vim-diminactive
tuyệt vời! rất đẹp. –
Điều này có thể được thực hiện hiệu quả hơn cho bất kỳ máy móc nào đang gặp khó khăn. Chúng tôi không thực sự cần phải chạy cho tất cả các cửa sổ mỗi lần chúng tôi chuyển đổi cửa sổ. Chúng ta chỉ cần thực hiện 'setwinvar' trên bất kỳ cửa sổ nào chúng ta WinLeave, và' setlocal nocolorcolumn' trên WinEnter. (Đó là giả định phiên của chúng tôi bắt đầu chỉ với một cửa sổ, và chúng tôi không bao giờ tạo nhiều cửa sổ mà không cần nhập từng cửa sổ.) – joeytwiddle
Xóa phân vùng au WinEnter * để cài đặt con trỏ ban đầu của người dùng được tôn trọng –