Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

TextMate - Convert Tabs to 2 Spaces and Strip Whitespace

Command for TextMate (or any other editor really) to strip whitespace and convert tabs...
I only ever use 2 spaces so i've gone with that.

#!/usr/bin/env ruby

STDIN.read.each do |line|
  line.sub!(/^(\t+)/) { |c| '  ' * c.length }
  line.sub!(/(\s+)$/, "\n")
  puts line
end

avoid visible whitespace in html

// if you want a line break and want to indent your html code
// but the browser makes problems with the whitespace
// make the whitespace a comment

//example
<div id="topimages">
	<image class="left" src="image/left.jpg"><!--
	--><image class="left" src="image/mid.jpg"><!--
	--><image class="right" src="image/right.jpg">
</div><!--topimages-->
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS