Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created September 27, 2010 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondale-sc/599183 to your computer and use it in GitHub Desktop.
Save rondale-sc/599183 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
str = STDIN.read
start_marker, end_marker = "=begin\n", "\n=end"
out = ''
str.each_line do |line|
if str.split.shift == "=begin"
@uncomment = true
end
next if line[/^\=begin/]
next if line[/^\=end/]
next if line[/^\n/]
out << line
end
puts @uncomment? out : start_marker + out + end_marker
@rondale-sc
Copy link
Author

Put in the toggle feature. Changed it from a custom start and end tag marker to ruby standard "=begin" "=end" syntax. Doing so removed the need for long 'if' statements. I'll probably make this into a little bundle at some point or another. TM by default allows code folding so adding the '=begin' '=end' syntax lets you fold multi-line comments. As an aside you could use this to comment and fold non-comment code which could be convenient. This prepends "=begin" and appends "=end" and removes them if they are found. Should be used with caution at this point. More to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment