Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created November 4, 2009 00:08
Show Gist options
  • Save ibolmo/225610 to your computer and use it in GitHub Desktop.
Save ibolmo/225610 to your computer and use it in GitHub Desktop.
Textmate or E-Texteditor command. My settings: Save: Current File, Input: Entire Document, Environment: Cygwin (generic), Output: Replace Document, Activation: Key Equivalent: F2, Scope Selector: ''
#!/usr/bin/env python
import sys
import re
re_whitespace = re.compile(r"[ \t]+$")
# Remove unnecessary whitespace.
lines = [re.sub(re_whitespace, '', line) for line in sys.stdin.readlines()]
# Ensure that the last line is an empty line.
if lines[-1] is not '':
lines.append('')
sys.stdout.writelines(lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment