微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vim – 昏暗的非活动分割窗格

如果您熟悉iTerm2应用程序,您将知道您可以拆分类似于vim的视图,而不活动的视图会变暗.

我通常使用vim进行三个垂直分割视图,例如通过将背景颜色设置为较暗的色调来调暗不活动的图像.

有没有办法做到这一点?

我想出了以下解决方案(使用’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

查看我的(当前)dotfiles:https://github.com/blueyed/dotfiles/blob/master/vimrc#L351

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

原文地址:https://www.jb51.cc/vim/386745.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐