I’m total noob to both .py and the sublime api.
As a simple exercise I thought I’d create a vbscript commenting plugin - it should insert an apostrophe at the beginning of each line of selected text. Then another plugin will remove the apostrophe.
I am using this code to insert the apostrophe
import sublime, sublime_plugin
def run(self, edit):
for selectedRegion in self.view.sel(): selectedLines = self.view.lines(selectedRegion) adjustBy = 0 for line in selectedLines: insertPoint = line.begin() + adjustBy self.view.insert(edit, insertPoint, "'") adjustBy += 1[/code]
For every line I iterate, I need to adjust the position of line.begin() to allow for the additional apostrophe added. Am I approaching this in the right way by incrementing a counter, or is there a better approach?
How would I go about removing the apostrophe I’ve added? (Basically, deleting the first character of each line).
It took me about 5 hours to create the few working lines of code you see above, so I was hoping somebody kind could point me in the right direction for the deleting side of things.