Search code examples
vimindentationhighlight

How to draw a vertical bar on every 4th space in Vim?


I'd like (g)Vim to draw a pipe symbol | on each 4th space of indentation to show something like vertical indentation line.

I found this plugin: http://vim.sourceforge.net/scripts/script.php?script_id=628, but it works only with tab characters, and I'm using spaces for indentation.

My .vimrc contains:

set ts=4
set sw=4
set expandtab 
set softtabstop=4 

Thanks for help


Solution

  • One could simply highlight every fourth space. Although it might look a bit hackish, is is simpler and quite effective. Please take a look at my answer to the question “Is it possible to display indentation guides in Vim?” where I lay out the technique in full detail.