Sublime Text: Add character in column position
<p>I have a Python file with a few hundred lines of code.  The longest line is 146 characters.  How would I put <code>#</code> in column 200 down the whole file within Sublime Text?  Preferably with one or two Sublime Text commands?</p>

<p><code>1                                                           200</code></p>

<p><code>print("Hello world!")                                       #</code>      </p>

<p>You can try something like this. Note that this writes to a new file: let me know if you want me to modify so that it overwrites the existing file:</p>

<pre><code>data = []
with open('data.txt', 'r') as f:
  data = [line[:-1] + ' ' * (200 - len(line)) + '#\n' for line in f]

with open('new_data.txt', 'w') as f:
  f.writelines(data)
</code></pre>

<p>Note that this will have just append the "#" at the end of the line (regardless of column number) if the line length >= 200.</p>

python comments sublimetext2 sublimetext3