Another Vim plugin - IndentGuides
#99 Henry, Thursday, 14 April 2011 10:59 AM (Category: UNIX Tools)
(Tags: vim indentguides)

I was reading Reddit and came across another Vim plugin that might be useful - IndentGuides. I decided to try it.

I downloaded and installed it (didn't need much work, just copy the directories in the .tar.gz to the .vim directory), read the examples on the download page and then added this to my .vimrc file:

let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd  guibg=red   ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4

When I started Vim next time and type ig to toggle Indent-Guides on, I got an error:

E411: highlight group not found: Normal

I eventually discovered that I was not setting a colorscheme in my .vimrc, so a bunch of color settings that Indent-Guides needed were not there. I looked in /usr/share/vim/vim73/colors/, and got the list of color schemes supplied with Vim, and I tried them one by one. I think a lot of them work best with gvim, and not so good with plain Vim. In the end, I liked the default colorscheme, so I added this to my .vimrc:

colorscheme default

and when I started Vim again, and typed ig to toggle IndentGuides on, it worked. The color scheme was pretty atrocious so I played with it a bit and settled on light gray and white for the indent colours. I finally changed my .vimrc to have these settings and they look okay for checking the indents. At first I set it to enable Indent-Guides when I start editing a file, but I found it too distracting. So I don't start with it on, I toggle it on if needed with ig. It's an interesting guide, definitely useful with Python. I don't need it often, but will keep it around.

" IndentGuide stuff
let g:indent_guides_enable_on_vim_startup = 0
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd  guibg=red ctermbg=lightgrey
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=white

Vim plugin - Indent-Guides

0 comments