I’m trying to create a command to pan the display left all way, i.e., to show the left edge of the page.
I tried this:
def left_adjust(view):
copy, regions = copy_regions(view)
move_to_hard_bol(view)
regions.clear()
regions.add_all(copy)
Where copy_regions, move_to_hard_bol are defined as follows:
def copy_regions(view):
regions = view.sel()
copy = []
for r in regions:
copy.append(sublime.Region(r.a, r.b))
return copy, regions
def move_to_hard_bol(view, extend=False):
copy, regions = copy_regions(view)
regions.clear()
to_be_added = []
for i in range(len(copy)):
line = view.line(copy[i].b)
if extend:
z = sublime.Region(copy[i].a, line.begin())
else:
z = sublime.Region(line.begin(), line.begin())
to_be_added.append(z)
regions.add_all(to_be_added)
This used to work for me, somehow it’s not working anymore.
Any ideas for how to left-justify the view, while leaving the caret in-place?