← Back to Upcase

Vim and Whitespace Characters


(Kevin Leugers) #1

Hello,

Is there a certain Vim plugin or configuration in your .vimrc that any of you use to show whitespace chars?

I ask because I recently started using Vim and was happily coding along until viewing something I submitted to Github. All of a sudden my formatting was a mess. I had been using something like this:autocmd Filetype ruby setlocal ts=2 sts=2 sw=2 in my .vimrc to format tabs to 2 spaces. However, I apparently was missing the set expandtab as well to convert the tabs to spaces. So even though it looked to me like they were spaces in my editor, after submitting to Github I saw they were actually tab chars so everything was expanded and looked off.

Is there a way to show your whitespace chars so I will know if I have this problem or a way to catch trailing whitespace? Or maybe I shouldn’t worry since I have corrected my .vimrc now and I shouldn’t have any problems?

I think I just like being able to visually see those there so I know I’m safe. Sublime Text has an option to show whitespace like this.


(Kevin Leugers) #2

This is the Github commit I mentioned:

https://github.com/thoughtbot/extract-class-exercise/pull/9


(Bill Peregoy) #3

I think you’re looking for the :set listchars command.
I use this to highlight tabs as a certain character and trailing spaces as another.

Here is the help for the command.

http://vimdoc.sourceforge.net/htmldoc/options.html#‘listchars’

Note that I first learned this technique from the dotfile examples on the thoughtbot gitnub.

These are great “study aids” in earning the finer points of dotfiles for a number of tools.


(Kevin Leugers) #4

Thanks! That’s exactly what I need. I’ll take some time and browse through the dotfiles there as well. Very helpful.