summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues.hiegel@qosmos.com>2014-12-18 15:52:09 +0100
committerHugues Hiegel <hugues.hiegel@qosmos.com>2014-12-18 15:52:09 +0100
commit882ab357864842f7e61eaeb283611ed4b4470985 (patch)
tree833d0204779bc5e6e15d851c71fde9220da51e0f
parent7b2863b18f9a6c144bb10e3011d6935897f61ff7 (diff)
[focus] Color inactive windows (vim >= 7.3 ..)
-rw-r--r--vimrc29
1 files changed, 29 insertions, 0 deletions
diff --git a/vimrc b/vimrc
index e6e3886..5853196 100644
--- a/vimrc
+++ b/vimrc
@@ -76,6 +76,35 @@ set autowrite
" default error format
"set efm=\"%f\"\\,\ line\ %l:\ error\ %m,\"%f\"\\,\ line\ %l:\ warning\ %m
+" 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 '~')
+if v:version > 703
+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()
+augroup END
+endif
+
" remaps C-j & C-k to C-y and C-e (buffer up/down line-by-line)
noremap <C-k> <C-y>
noremap <C-j> <C-e>