preservim / vim-indent-guides Goto Github PK
View Code? Open in Web Editor NEWA Vim plugin for visually displaying indent levels in code
License: MIT License
A Vim plugin for visually displaying indent levels in code
License: MIT License
When using indent guides with cursorline enabled (:set cursorline
), the indent guides show in front of the cursorline background.
It'd be great to have an option to show the cursorline background color in front of indent guides.
Vim noob here - wondering if there's a way to have this plugin automatically active instead of having to hit the key combo to toggle it every time?
When I activate the plugin for a yaml file (syntax highlighting is enabled) I receive the following error message:
Error detected while processing function <SNR>19_IndentGuidesEnable..indent_guides#enable..indent_guides#init_script_vars..indent_guides#
capture_highlight:
line 2:
E411: highlight group not found: Normal
Fedora 17
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 15 2012 09:58:06)
Included patches: 1-415, 417-682
Need an option to disable indent guides on the NERDTree window/buffer.
It’d be nice if vim-indent-guides could be configured to still hilight indentation after commentary markers, if there is no non-commentary-marker code between the beginning of the line and the commentary markers themselves.
Hello,
setting shiftwidth=0
(it's supposed to use the tabstop value then) breaks the plugin. The foreground of the very first column is then in a different color which looks kind of strange and is unreadable (for me) because it is almost the same color as the background.
I've replaced set sw=0
with let &shiftwidth=&tabstop
in my .vimrc
and now it works again. However, I'm wondering why it won't work the sw=0
option as the help page (for sw) says.
some wishes :-)
I wish in these case:
| if foo then <--- show here
| ? blah blah blah <---don't show here on '?'
| end <---show here
| a =
| here
but not:
| a =
| | | | | | here
Instead of (or along with) just hilighting the space, it’d be nice to be able to show (a) character(s) there.
Hi,
first off, great plugin! I just have one minor annoyance, I found it almost impossible to set custom indent colors when using vim in the console. The autocmd
lines worked until I changed buffers, after which the colors were back to default.
So i basically overwrote indent_guides#basic_highlight_colors()
in my .vimrc
, adding a default color option:
" set two dark grey colors for indent guides
let g:indent_guides_default_ctermbg_colors = [234, 235]
" function that registers / overrides "indent_guides#basic_highlight_colors"
function! OverrideIndentGuidesFunction ()
function! indent_guides#basic_highlight_colors()
if exists('g:indent_guides_default_ctermbg_colors')
let l:cterm_colors = g:indent_guides_default_ctermbg_colors
else
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
endif
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[0]
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[1]
endfunction
endfunction
" and a hook to overwrite the plugin's function with ours after the plugin has loaded:
autocmd VimEnter * :call OverrideIndentGuidesFunction()
This hack works, but I would appreciate it if some such option would be provided, such that the "fallback" to darkgrey etc. can be overriden by the user.
With debugging enabled I get this, but nothing changes visually.
s:indent_size = 4
s:guide_size = 4
s:hi_normal = Normal xxx ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#282828
s:indent_levels = 30
s:auto_colors = 0
s:change_percent = 0.1
s:color_hex_pat = #[0-9A-Fa-f]{6}
s:color_hex_bg_pat = guibg=\zs#[0-9A-Fa-f]{6}\ze
s:color_name_bg_pat = guibg='?\zs[0-9A-Za-z ]+\ze'?
s:start_level = 1
I've tried this with various color schemes but still no luck :(
I like the guide-size=1 look with spaces, but unfortunately this does not work when using tabs.
I have list
set so my tabs do show up (So I can tell that some whitespace is made of tabs or not), I just would like to have some way of telling the indent-guides plugin to color tab based indentation differently from space-based indentation. For instance since only one character out of 4 will be highlighted with space-indentation the color can stand to be more prominent. However with tabs they are always fully colored so I'd like to configure a less prominent color for when they are tabs.
After I run :IndentGuidesEnable
, there is no effect. But for the default
colorscheme, everything works fine.
I had sent you an email when Indent-guides was just born. At that time, you give me the following 3 lines. I added them to vimrc
, then everything would work, but for the current version it won't work.
let g:indent_guides_auto_colors = 0
hi IndentGuidesOdd guibg=#212121
hi IndentGuidesEven guibg=#404040
I am using gvim on Linux. I'm using vim 7.3.
Thanks!
This is a feature request. (Not sure if it's even possible.)
Hello,
I'm in the (slow) process of teaching myself vim, so my apologies if this question is a bit silly. However, is there a way to automatically enable the plugin via my .vimrc? The obvious "<Leader>ig" doesn't work, and a significant amount of googling and reading docs didn't seem to shed any light on it.
Thanks,
Jack
Hi,
I have set this in my vimrc:
let g:indent_guides_start_level = 0
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
But, when I open a file or enter in a buffer, I have this error:
Error detected while processing function <SNR>37_IndentGuidesEnable..indent_guides#enable:
line 17:
E71: Invalid character after \%
Press ENTER or type command to continue
Error detected while processing function <SNR>37_IndentGuidesEnable..indent_guides#enable:
line 17:
E475: Invalid argument: ^\s*\%-3v\zs\s*\%-2v\ze
Press ENTER or type command to continue
Error detected while processing function <SNR>37_IndentGuidesEnable..indent_guides#enable:
line 19:
E71: Invalid character after \%
Press ENTER or type command to continue
Error detected while processing function <SNR>37_IndentGuidesEnable..indent_guides#enable:
line 19:
E475: Invalid argument: ^\t*\%-3v\zs\t*\%1v\ze
Press ENTER or type command to continue
I use Vim 7.3.682 on Fedora 17.
Is their a way to fix it?
Thanks by advance.
I haven't narrowed it down to a small problem file, but "+yy
(and any other operation that interacts with the X CLIPBOARD) and Bisectly blaims this plugin for messing with the clipboard.
The behavior I'm seeing is that if I try to paste from the X CLIPBOARD into some other GUI application, the contents of the "+
register is only available the first time. On subsequent pastes, it is empty. Disabling this plugin fixes the issue.
Hi,
I installed using the zip file. I've confirmed that all the files are installed correctly in their intended sub directories under my ~/.vim folder. When loading MacVim none of the commands work and indentation guides do not appear in my files. I tried setting my ~/.gvimrc file to auto load the plugin on startup but that does not work as well.
Here's my config file (~/.gvimrc):
set nowrap
set number
set completeopt=longest,menu
set ruler
set go-=T
set guifont=Menlo\ Regular:h18
set hlsearch
set tabstop=2 shiftwidth=2 softtabstop=2 expandtab
filetype indent on
filetype plugin on
au BufNewFile,BufRead *.ejs set filetype=html
let g:indent_guides_enable_on_vim_startup = 1
Any advice or suggestions would be greatly appreciated. Admittedly, I'm a VIM newbie and I'd really like to get this plugin to work. Thanks in advance.
Sincerely,
Jeff
I've added
let g:indent_guides_auto_colors = 0
let g:indent_guides_enable_on_vim_startup = 1
to my .vimrc
and
hi IndentGuidesOdd guibg=#121212
hi IndentGuidesEven guibg=#262626
to my colorscheme, but the highlight rules are cleared.
By the way, nice plugin. I wrote something similar myself (github.com/graywh/vim-colorindent) that's unpolished b/c I didn't like the existing alternatives that used syntax rules instead of matches.
I got my MacVim tweaked just the way I wanted on the Intel/Snow Leopard desktop. Decided to do the same thing to the PPC/Leopard laptop. So I copy .gvimrc and install my only plugin, indent guides. The end result: spaces are ignored until repeated 8 times, at which point it is color-coded like a tab (though navigation in vim still treats the whole "block" like a space and not a tab). Up until that point, there is no color coding.
Unfortunately, I can't say much about the CLI interface. :IndentGuidesToggle
yields:
Error detected while processing function3_IndentGuidesToggle..indent_guides#enable..indent_guides#init_script_vars..indent_guides#capture_highlight:
line 2:
E411: highlight group not found: Normal
Appropriate :let
s--
indent_guides_color_name_guibg_pattern guibg='\?\zs[0-9A-Za-z ]\+\ze'\?
loaded_indent_guides #1
indent_guides_color_hex_guibg_pattern guibg=\zs#[0-9A-Fa-f]\{6\}\ze
indent_guides_auto_colors #0
indent_guides_start_level #1
indent_guides_color_hex_pattern #[0-9A-Fa-f]\{6\}
indent_guides_enable_on_vim_startup #0
indent_guides_color_change_percent #10
indent_guides_indent_levels #30
indent_guides_autocmds_enabled #0
indent_guides_debug #0
indent_guides_guide_size #0
w:indent_guides_matches []
here's some relevant bits from :highlight
including the supposedly missing group:
Normal xxx guifg=Grey50 guibg=black
IndentGuidesOdd xxx guibg=darkblue
IndentGuidesEven xxx guibg=darkgreen
all of which suggests to me that everything's in order. Harumph?
This seems like a useful plugin to have when editing Python code, but I can't get myself to use it much because I have to constantly turn it on and off since it acts globally. It'd be nice to be able to say "turn it on for this buffer". IOW, some sort of buffer-local variable to enable/disable it for that buffer.
I'd like to have this plugin automatically enabled for any of my source-code files. However, I don't want it enabled for files that are not indentation-based. Currently, it is impossible.
I've tried adding this to my ~/.vimrc
:
au FileType python IndentGuidesEnable
I open a Python file and this plugin is automatically enabled, as it should! Great! Then I type :help indent_guides
, and the help file gets indent-highlighted. No, it's not good. So I've added this:
au FileType * IndentGuidesDisable
And now opening a help file disables the highlighting, but after going back to the Python source, it gets disabled there as well. Damn, this state is global, while it should be local to each buffer!
Once this issue is fixed, issue #20 will be fixed as well.
When I set indent_guides_guide_size = 1 on a document that has space indentation it works great, but when I set indent_guides_guide_size = 1 on a document that has tab indentation it doesn't work at all.
Perhaps you can make an option to be able to do this:
http://i.imgur.com/KVi0T.jpg
Found here:
http://www.vim.org/scripts/script.php?script_id=4354
How can I change the style to be Sublime Text 2 , so it will be very small dots like sublime ?
Hi,
I using your plugin with vim 7.3.102 (Gentoo version, but that is not really relevant)
In some version of vim-7.2, there was a bug with floating points (see http://vim.1045645.n5.nabble.com/patch-fixed-bug-floating-point-numbers-cannot-be-used-as-arguments-in-GVIM-lang-td1203961.html) which seems to have surfaced again in my version.
As a workaround, you could use ' / str2float("100.0")' instead of ' / 100.0'.
This works for me, and I suppose it works for the 7.2 versions that have this bug, too.
All my indent guides are 'broken lines' because i use a lot of lines with nothing on them (just a carriage return). The vim indent line stops and stars on the next line under the carriage return... can i have it ALWAYS be there whether the line has anything on it or not?
Is there any way to highlight empty lines so they show the same indent level as their previous line? I realize this might be hard, but I don't want to go around and put spaces all over my files, and I don't want discontinuity throughout my highlights either
Hi. It would be great to have a new mode where the guide highlights go full width. So it would not stop at the first non-whitespace character but rather continue covering the text too. What do you think?
Please check out the mockup https://gist.github.com/3852009
Hi
Thanks for this great plugin.
I use this plugin with default setting, but the wired thing is it takes no effect at all when run IndentGuidesEnable
or IndentGuidesToggle
.
But when I change the colorscheme(without quiting gvim),the guide lines can be seen.
By the way ,if I use the customized color for this plugin(in .vimrc), it works well. So I think it should be the color-auto-detect issue.
gvim
is 7.4 with 027 patch.
While the automatic coloring of indent guides looks great in gvim, it looks really ugly running vim on a 256-color terminal. Compare and contrast, for example, these two screenshots:
The color scheme in both screenshots is zenburn, and the code snippet is from indent_guides.vim. The rest of the colors match quite well, which makes the indent guides stand out like a sore thumb.
When I check :hi IndentGuidesOdd
and :hi IndentGuidesEven
in gvim, I see that they've been calculated as grey85 and grey70 respectively. After a little playing around (the Xterm 256 color chart was a big help), I found that `:hi IndentGuidesOdd ctermbg=236and
:hi IndentGuidesEven ctermbg=240`` were decent matches for the guibg colors -- and indeed, when I set those values, my terminal VIm looks much better.
It would be nice if vim-indent-guides could detect a 256-color (or 88-color) terminal and calculate its grey values accordingly. The Python script at http://excess.org/article/2007/10/xterm-256-colour-chart-20/ might help: it shows that the greys in the Xterm 256 color chart are spread between 0xe8 (ctermbg=232) and 0xff (ctermbg=255), which means each increasing ctermbg number adds about 4% brightness overall. That should make the math reasonably simple for a 256-color terminal. (Afraid I can't help with the 88-color terminal math, as I don't have one of those handy to test with.)
Some possible color modes:
Alternatively you could have an option to control how many colors the guides should alternate between, with the default being 2.
Windows 7 Pro x64.
echo &shiftwidth
displays : 8
.
This is in my _vimrc
:
" Indentation Guides let g:indent_guides_guide_size = 1 let g:indent_guides_indent_levels = 50 nnoremap <silent> <F8> :IndentGuidesToggle<CR> autocmd VimEnter * :IndentGuidesEnable
The issue :
My debug :let g:indent_guides_debug = 1
+ :IndentGuideToggle
output :
When using the vim folding system, there is a setting to use the syntax highlighter to find the best folding areas.
I think if you could do the same for the indent guides, this would be very awesome. Currently the ident guides are implemented in a non intelligent way. They even occour if the indent is not used for grouping code, but for making the code better readable. The indent guides will distract me in that case .
Instead of just changing the bg, it would be nice to be able to display a character intead, like the pipe |. Just a thought.
Would it be possible to use the unicode characters for drawing a line (aka skinning guides) instead of a whole character row? It'd be much more pleasing to the eye and the coloring would be easier to deal with...
I'm thinking of Unicode character U+2502 "│"
Ciao!
I use @altercation's solarized (dark) for my theme, and I can't get the highlights to be dark when background is set before colorscheme.
set background=dark
colorscheme solarized
yields
where
colorscheme solarized
set background=dark
yields
I've tried setting
hi IndentGuidesEven ctermbg=black
hi IndentGuidesOdd ctermbg=darkgrey
but that doesn't work at all. You can see the relevant lines to my .vimrc here
This error appears when I enable indent-guides
by <leader>ig
Error detected while processing function <SNR>22_IndentGuidesToggle..indent_guides#toggle..indent_guides#enable..indent_guides
#init_script_vars..indent_guides#capture_highlight:
line 2:
E411: highlight group not found: Normal
Press ENTER or type command to continue
The file content on which I'm enabling indent-guide
#!/usr/bin/env python
def helloworld():
print "Hello World!"
pass
helloworld
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 6 2012 15:24:46)
Included patches: 1-393
Modified by Gentoo-7.3.393
Compiled by root@localhost
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile -python
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup +X11 +xfontset -xim
+xsmp_interact +xterm_clipboard -xterm_save
system vimrc file: "/etc/vim/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: x86_64-pc-linux-gnu-gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -pipe -march=native -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -lnsl -lcurses -lacl -lattr -ldl
Hello, I have
match Todo /\s\+$/
in my vimrc, so that whitespace stands out like crazy (because whitespace is evil). When indent guides are turned on, or if
let g:indent_guides_enable_on_vim_startup = 1
I no longer see the whitespace (Todo) match.
If I turn on indent guides then do a
:match Todo /\s\+$/
then I have working indent guides as well as the Todo match. I thought this might be an order of operations issue, so I put the match statement as the last line of my .vimrc, but that doesn't work.
Do you have any suggestions?
Thanks.
-Shawn
Make it highlight the indentation guide when the cursor is on a bracket, so that the guide can easily be followed visually to the next bracket, similar to how Notepad++ does it.
Add also the ability to just highlight the indent guides based on which code block the current resides in, similar to Sublime's functionality.
What I'm seeing is an exact copy of closed issue #43 ...
This is on Windows. I have Vim 7.3.46, I have the latest copy of indent-guides from github. When I try to manually load it using :IndentGuideToggle, I get an error of :
E492: Not an editor command: IndentGuideToggle
All scripts show up when I run :scriptnames. I did what was suggested in the other issue and copied color_helper to the plugins directory.
All to no-avail... Any ideas what might be wrong?
Thank you!
Error detected while processing function indent_guides#process_autocmds..indent_guides#enable..indent_guides#clear_matches:
line 5:
E803: ID not found: 904
E803: ID not found: 905
E803: ID not found: 906
E803: ID not found: 907
E803: ID not found: 908
E803: ID not found: 909
E803: ID not found: 910
E803: ID not found: 911
E803: ID not found: 912
E803: ID not found: 913
E803: ID not found: 914
E803: ID not found: 915
E803: ID not found: 916
E803: ID not found: 917
E803: ID not found: 918
E803: ID not found: 919
E803: ID not found: 920
E803: ID not found: 921
E803: ID not found: 922
E803: ID not found: 923
When having indented code, but include blank lines between statements, which contains no spaces at all, the guide is cutoff.
I understand this could be assumed as logical as the indentation is pretty much removed, but generally you do not want to include lines containing only white space.
I copy the folders to my ~/.vim folder and nothing seems to happen when I restart vim. :help indent-guides also doesn't work even though the correct files are in the docs folder.
Any insight into how I can get this plugin running?
If the option set cursorline
is set in the vimrc, the current line is highlighted in vim. The highlight color of this can also be modified by issuing a hi CursorLine ctermbg=<desired color>
in your vimrc. The issue is that on lines with indentation highlighted by indent-guides, the highlighting of the current line is overwritten by indent-guides highlighting at the beginning of the line where the indentation is.
This is not an issue for set cursorcolumn
, as the highlighted column displays fine across all lines, including the portions highlighted by indent-guides.
I'm not sure, but this may be related to another reported issue ( #66 ). Not sure if it's possible to reduce the priority of highlighting of indent-guides to resolve issues like this or not.
If nothing else it would be cool if it could detect which line is currently selected, and change the tint of the indents on that line.
This line causes an error in Vim 7.1:
let s:change_percent = g:indent_guides_color_change_percent / str2float("100.0")
Changing it to this doesn't seem to be a problem:
let s:change_percent = g:indent_guides_color_change_percent / 100.0
Like the title says, I can set it to on, even set the g:indent_guides_enable_on_vim_startup
option to on, but whenever I source my .vimrc file (I use 'sv') it disables itself again.
Update:
I've figured out that this only happens visually, if I do ,ig
twice it appears again, which leads me to believe that it's always on, just not visible after sourcing the .vimrc
file.
I, like @jc00ke (see #24) am trying to use @altercation’s Solarized with vim-indent-guides
. My approach is slightly different, as I desire to set specific colours for the indent guides (and I intend to tweak some other distasteful Solarized defaults at the same time). I’ve copied the configuration from your README into a function, and setup an auto command to call this function (as I intend to add other Solarized modifications to it than those I’m making for your plugin), as thus:
let g:indent_guides_auto_colors = 0
" . . .
function! s:RebuildSolarization()
" . . . <setting up Solarized colour values here>
exe "hi! IndentGuidesOdd" .s:fmt_none .s:fg_none .s:bg_base02
exe "hi! IndentGuidesEven".s:fmt_none .s:fg_none .s:bg_base01
" . . . <other Solarized customization>
endfunction
autocmd! VimEnter,ColorScheme * if g:colors_name == "solarized" | call s:RebuildSolarization() | endif
Unfortunately, it doesn’t work: while the commands are run (I’ve checked them with echoerr
at the time of the function being run), by the time anything is rendered, the hilights are set back to bog-standard neon-green and neon-red. (Very disgusting defaults, by the way; couldn’t you at least default to two quiet shades of grey? :x)
I’m not very familiar with VimScript, what am I doing wrong here?
**Postscript_: The full code at the time of this writing is available in the commit linked below._
The problem:
Themes that don't specify a guibg
color for hi Normal
don't work with the plugin. That is, they don't work when the auto colors option is set, ie. when let g:indent_guides_auto_colors = 1
.
For example:
When using colorscheme default
, hi Normal
is Normal xxx cleared
, which doesn't specify a guibg
.
Possible solution:
Because we can't get a valid guibg
we'll have to base the colors off the background
variable. Ie. set background=dark
will produce dark grey guides, and set background=light
will produce light grey guides.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.