mattfoster (owner)

Revisions

gist: 35668 Download_button fork
public
Public Clone URL: git://gist.github.com/35668.git
Embed All Files: show embed
textmate_end_of_line_comments.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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)