Created
December 14, 2008 11:23
-
-
Save mattfoster/35668 to your computer and use it in GitHub Desktop.
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 | |
# Add comments to the end of lines | |
# Set `save` to `nothing` | |
# Set `input` to `selected text` or `line` | |
# Set `output` to `replace selected text` | |
import sys, os | |
comment_char = os.environ.get('TM_COMMENT_START', '#') | |
default_column = 55 # could set TM_DEFAULT_COMMENT_COL or similar | |
lines = sys.stdin.readlines() | |
lens = [len(s) for s in lines] | |
max_len = max([max(lens), default_column]) | |
for line in lines: | |
print "%-*s %s" % (max_len, line.rstrip('\n').rstrip(), comment_char) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment