Could you help me with my first plugin? I have a file that is delimited by tilde’s “~”. I would like to insert a new line after the tilde character. I would also like to insert a new line before the string of characters “INS*”. I gave it a first stab, I had written some python years ago, by following the ROT13 example on the website. This is what I cam up with:
[code]import sublime, sublime_plugin
class X12Command(sublime_plugin.TextCommand):
def run(self, view, args):
for region in view.sel():
if not region.empty():
s = view.substr(region)
s = s.replace(’~’, ‘~\n’)
s = s.replace(‘INS*’, ‘\nINS*’)
view.replace(region, s)[/code]
When I run it in the console I don’t get any output:
view.run_command(‘X12’)
But there are no errors. The text in the editor window does not update and there is no other feedback. I tried dropping a print statement in the run method but it didn’t write to the command window like I thought it would.
Any help is appreciated. Thanks!