2010-12-07 08:35:02 -05:00
# Indent Guides
2010-12-29 18:23:44 -05:00
Indent Guides is a plugin for visually displaying indent levels in Vim.
2010-12-07 08:35:02 -05:00
2015-05-10 17:23:15 -04:00
< img src = "http://i.imgur.com/ONgoj.png" width = "448" height = "448" alt = "" / >
2010-12-11 09:14:56 -05:00
## Features:
* Can detect both tab and space indent styles.
2010-12-29 18:23:44 -05:00
* Automatically inspects your colorscheme and picks appropriate colors (gVim only).
2010-12-11 09:14:56 -05:00
* Will highlight indent levels with alternating colors.
2010-12-30 05:35:22 -05:00
* Full support for gVim and basic support for Terminal Vim.
2010-12-29 18:23:44 -05:00
* Seems to work on Windows gVim 7.3 (haven't done any extensive tests though).
2011-03-13 07:00:59 -04:00
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
2017-07-01 13:51:17 -04:00
* Highlight support for files with a mixture of tab and space indent styles.
2010-12-07 08:47:48 -05:00
2010-12-12 04:33:16 -05:00
## Requirements
2010-12-29 18:23:44 -05:00
* Vim 7.2+
2010-12-12 04:33:16 -05:00
2010-12-07 08:45:07 -05:00
## Installation
2017-07-01 13:51:17 -04:00
To install the plugin copy `autoload` , `plugin` , `doc` directories into your `.vim` directory.
2010-12-07 08:35:02 -05:00
2017-07-01 13:51:17 -04:00
### Pathogen
If you have [Pathogen ](http://www.vim.org/scripts/script.php?script_id=2332 ) installed, clone this repo into a subdirectory of your `.vim/bundle` directory like so:
2010-12-11 09:14:56 -05:00
2018-05-14 07:27:26 -04:00
```bash
2018-05-13 16:19:27 -04:00
cd ~/.vim/bundle
git clone git://github.com/nathanaelkane/vim-indent-guides.git
```
2010-12-07 08:45:07 -05:00
2017-07-01 13:51:17 -04:00
### Vundle
If you have [Vundle ](https://github.com/VundleVim/Vundle.vim ) installed, add the following line to your `~/.vimrc` in the appropriate spot (see the Vundle.vim README for help):
2018-05-13 16:19:27 -04:00
```vim
Plugin 'nathanaelkane/vim-indent-guides'
```
2017-07-01 13:51:17 -04:00
and then run the following command from inside Vim:
2018-05-13 16:19:27 -04:00
```vim
:PluginInstall
```
2018-05-14 07:25:22 -04:00
2010-12-07 08:45:07 -05:00
## Usage
2017-07-01 13:51:17 -04:00
The default mapping to toggle the plugin is `<Leader>ig` .
You can also use the following commands inside Vim:
2018-05-13 16:19:27 -04:00
```vim
:IndentGuidesEnable
:IndentGuidesDisable
:IndentGuidesToggle
```
2017-07-01 13:51:17 -04:00
If you would like to have indent guides enabled by default, you can add the following to your `~/.vimrc` :
2018-05-13 16:19:27 -04:00
```vim
let g:indent_guides_enable_on_vim_startup = 1
```
2018-05-14 07:25:22 -04:00
2010-12-29 18:23:44 -05:00
### gVim
**This plugin should work with gVim out of the box, no configuration needed.** It will automatically inspect your colorscheme and pick appropriate colors.
2010-12-29 06:23:35 -05:00
### Setting custom indent colors
2010-12-29 07:15:42 -05:00
Here's an example of how to define custom colors instead of using the ones the plugin automatically generates for you. Add this to your `.vimrc` file:
2010-12-29 06:23:35 -05:00
2018-05-13 16:19:27 -04:00
```vim
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
```
2018-05-14 07:25:22 -04:00
2011-03-13 07:00:59 -04:00
Alternatively you can add the following lines to your colorscheme file.
2018-05-13 16:19:27 -04:00
```vim
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
```
2018-05-14 07:25:22 -04:00
2010-12-29 06:15:52 -05:00
### Terminal Vim
2010-12-29 06:29:13 -05:00
At the moment Terminal Vim only has basic support. This means is that colors won't be automatically calculated based on your colorscheme. Instead, some preset colors are used depending on whether `background` is set to `dark` or `light` .
2010-12-29 06:15:52 -05:00
When `set background=dark` is used, the following highlight colors will be defined:
2018-05-13 16:19:27 -04:00
```vim
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
```
2010-12-29 06:15:52 -05:00
2010-12-29 06:29:13 -05:00
Alternatively, when `set background=light` is used, the following highlight colors will be defined:
2010-12-29 06:15:52 -05:00
2018-05-13 16:19:27 -04:00
```vim
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
```
2010-12-29 06:15:52 -05:00
2010-12-29 06:29:13 -05:00
If for some reason it's incorrectly defining light highlight colors instead of dark ones or vice versa, the first thing you should check is that the `background` value is being set correctly for your colorscheme. Sometimes it's best to manually set the `background` value in your `.vimrc` , for example:
2010-12-29 06:15:52 -05:00
2018-05-13 16:19:27 -04:00
```vim
colorscheme desert256
set background=dark
```
2010-12-29 06:15:52 -05:00
Alternatively you can manually setup the highlight colors yourself, see `:help indent_guides_auto_colors` for an example.
2010-12-07 08:45:07 -05:00
## Help
`:help indent-guides`
2010-12-11 09:14:56 -05:00
## Screenshots
2011-01-10 06:38:06 -05:00
< img src = "http://i.imgur.com/7tMBl.png" width = "448" height = "448" alt = "" / >
< img src = "http://i.imgur.com/EvrqK.png" width = "448" height = "448" alt = "" / >
< img src = "http://i.imgur.com/hHqp2.png" width = "448" height = "448" alt = "" / >