Created
November 4, 2009 00:08
-
-
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: ''
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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