Visible Whitespace in Sublime Text 2
One thing I care about is trailing whitespace. For whatever reason, I don’t want trailing whitespace in my files. I blame this afliction on Terry Hughes. Also surprisingly enough this is the most common JSHint failure that gets me.
One thing that Terry does in Visual Studio is enable visual whitespace so you can see all the nasty mixed tabs/spaces and trailing garbage. I am using Sublime Text 2 as my main editor at the moment, so I went spelunking to figure out how to enable visual whitespace in it.
It turns out to be pretty easy. From the Sublime Text 2 menu, select Preferences> Default - User.
Then add this setting:
The first setting will make whitespace visible at all times. The next two I threw in as a nice suggestion, they will convert tabs to four spaces if you are into that kind of thing. I apparently am also a jerk who will automate cleaning up after you if you don’t care about whitespace. Just this morning I added a plugin to convert tabs to spaces when I save a document. So if I open a file full of horrible tabs, all I have to do is save and it fixed.
Adding the plugin was pretty easy, just select Sublime Text 2 > Preferences > Browse Packages.
Then create a new directory, I called mine “johnson” to avoid conflicts, and create a python script file named tabs_to_spaces.py and add this code to it.
Happy anal text formatting to you!