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

相关文章

解决方案:解决linux下vim乱码的情况:(修改vimrc的内容)全...
Linuxvi/vim所有的UnixLike系统都会内建vi文书编辑器,其他的...
      vim正则匹配:空行:/^$/  /^[\t]*$/注释...
$select-editorSelectaneditor.Tochangelater,run'sele...
上次手贱忘了保存,这次就简单做个备忘吧,把踩过的坑记一下...
Linux之文本编译器小结vim的优势所有的UNIX-LIKE习通都会内置...