3

I want to highlight tabs and spaces. In sublime text I activated an "draw_white_space": "all" option. After that all tabs and spaces is highlighting.

enter image description here

I want to activate the same option in vim, but all what I used didn't work.

I tried set follow options:

set listchars=tab:--
set list

How is it possible to activate it, and how to make highlighting tabs and spaces the same sympols like in picture above?

Mike_Device
  • 634
  • 2
  • 8
  • 25
  • 1
    Your tab highlight should (mostly) work as you like, now. Is something wrong with it? If it's just not as pretty as you want, you can use mdash characters or some Unicode drawing character in place of dashes. For the spaces, unfortunately, Vim does not have a built-in option (yet) but I think there is a patch available. – Ben Mar 15 '15 at 18:12

2 Answers2

5

As icwnd says use

set list
set listchars=tab:▸·

However you may find that you still cannot see the characters because they are the same color as the background. Adding the following will change the color of those characters

highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59

As Ben mentions, this does not work for spaces.


Edit

You can now do the same for spaces, see https://stackoverflow.com/a/29787362/1427295.

Community
  • 1
  • 1
Brett Y
  • 7,171
  • 1
  • 28
  • 42
4

There is a vim plugin called spacehi which does that with tabs.

Download the spacehi.vim file, copy that into your ~/.vim/plugin/ folder, restart vim and activate/deactivate with F3.

If you don't want to use the plugin you could use this:

set list
set listchars=tab:--,trail:.,eol:¬,extends:>,precedes:<

For even nicer indentation also take a look at the vim-indent-guides.

rbento
  • 9,919
  • 3
  • 61
  • 61