" compute a large pattern, let :match do highlighting command! Bars hi Bars guibg=lightgrey | exe "match Bars ".Bars(0,line("$")) function! Bars(from,to) let r = [] " collect lists of indentations per line let ms = [] " list of matches of the form \%LINEl\%(\%POSc\|..\|\%POSc\) let is = [0] " list of indentations relevant for current line let line = a:from let last = a:to while line < last let line += 1 if getline(line) =~ "^\s*$" | continue | endif " ignore empty lines let i = indent(line) let [j;js] = is while i<=j && !empty(js) let [j;js] = js " drop all indents not bigger than current one endwhile let is = [i,j] + js " add current line's indent let r = add(r,is) " build up a list of patterns for :match command let columns = map(copy(is),'1+v:val') let columnPats = reverse(map(columns,'"\\%" . v:val . "c"')) let linePat = "\\%(\\%" . line . "l\\%(" . join(columnPats,'\|') . "\\)\\)" let ms += [linePat] endwhile return "/\\%(" . join(ms,'\|') . "\\)/" " return r endfunction