This plugin is used for displaying thin vertical lines at each indentation level for code indented with spaces. For code indented with tabs I think there is no need to support it, because you can use :set list lcs=tab:\|\ (here is a space)
.
This plugin takes advantage of the newly provided conceal
feature in Vim 7.3, so this plugin will not work with lower versions of Vim.
To install the plugin just put the plugin files in your ~/.vim
(Linux) or ~/vimfiles
(Windows).
If you use a plugin manager you can put the whole directory into your ~/.vim/bundle/
directory (Pathogen) or add the line Plugin 'Yggdroot/indentLine'
to your .vimrc
(Vundle).
To apply customization, apply the variable definitions to your .vimrc
file.
Change Character Color
" Vim
let g:indentLine_color_term = 239
"GVim
let g:indentLine_color_gui = '#A4E57E'
" none X terminal
let g:indentLine_color_tty_light = 7 " (default: 4)
let g:indentLine_color_dark = 1 " (default: 2)
Change Indent Char
Vim and GVim
let g:indentLine_char = 'c'
where 'c'
can be any ASCII character. You can also use one of ¦
, ┆
, or │
to display more beautiful lines. However, these characters will only work with files whose encoding is UTF-8.
Change Conceal Behaviour
Vim 7.3 has a new feature conceal
Documentation to automatically hide a stretch of text based on syntax highlighting.
let g:indentLine_concealcursor = 'vc' (default 'inc')
let g:indentLine_conceallevel = 0 (default 2)
Disable by default
let g:indentLine_enabled = 0
:IndentLinesToggle
toggles lines on and off.
If you find all the standard unicode and ASCII characters too obtrusive, you might consider patching your font with the indentLine-dotted-guide.eps glyph provided. FontForge makes the process amazingly simple:
- Download and install FontForge.
- Locate and open your terminal/gVim font.
- Open the font in FontForge, choose Goto from the View menu and select Private Use Area from the drop down box.
- In the private use area, locate a blank spot for the glyph. Make a note of the code, e.g.
U+E0A3
. - Double-click the selected code point to open the font drawing tool.
- From the File menu, select Import... and locate the indentLine-dotted-guide.eps file.
- Once imported, choose File -> Generate Fonts and choose a location and file type for the new font.
Once completed, your new font will contain the more subtle dotted guide and all you have to do is set that glyph to g:indentLine_char
in your .vimrc
file.
If you think this script is helpful, follow the GitHub repository, and don't forget to vote for it on Vim.org! (vimscript #4354).