I used textmate to work with ruby code for over one year. Recently I switched to using mvim. When I open some of the files in mvim I get empty blocks. Look at this picture to get a feel for it.
Any idea on how to get rid of them?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Others have explained that this could either be a search highlighting spaces or tabs or (more likely) it could be highlight designed to show up mixed indentation (particularly useful in python for what it’s worth). I find this very useful personally.
Anyway, there are a number of options to sort out your highlighting depending on the cause:
To clean end of line spaces (as mentioned by chaos), use something like:
Probably the most useful one: tidy up the tabbing:
If you’re using spaces for indentation:
If you’re using tabs:
If you’re using tabs for indentation and spaces elsewhere:
I have the last line mapped to a command called
:RetabIndents. All of those assume that yourtabstopsetting is correct (it should be set withset ts=2based on your picture). Personally, I’d also recommend keepingshiftwidthequal totabstop, soset ts=2 sw=2.You may also be able to get away with a simple
gg=G(auto-indent the whole file). However, this won’t work in some languages (in particular python as there’s no way for any editor to know which lines should be indented to which level).To switch off search-based highlighting temporarily:
Or permanently (put this in .vimrc):
Or a quick shortcut for when you’ve used it and don’t want it anymore:
To switch off indent highlighting, you’ll have to identify which highlighting group is used, which is a little complicated and is probably easiest to just read your .vimrc, but if you really want to search for it, move the cursor to one of the highlighted characters and enter (taken from here):
You can then clear the highlighting group by searching for the name that is reported on the command line in your .vim/.vimrc/_vimrc/vimfiles configuration and commenting out anything relevant.
For more information