Select All loss the cursor position. The suggested solution on this forum (soft undo) only helps if the only thing you have done is select all. If for example you do
Select All
Reindent
then the undo undoes the reindent.
I need to be able to do
Select all
Reindent
then return to the original state, i.e. nothing selected and cursor where I started. Currenty the cursor ends up at the end of the file which is real pain.
Select all loses cursor position. Soft undo does not help
T2KGuru
#1
0 Likes
T2KGuru
#2
So I decided to solve my specific requirement with a new plugin:
import sublime
import sublime_plugin
class ReindentAllCommand(sublime_plugin.TextCommand):
def run(self, edit):
# get the current "selection"
selfie = self.view.sel()
# extract the row, col number at present location
(row,col) = self.view.rowcol(selfie[0].begin())
# convert it to a "point"
here = self.view.text_point(row,col)
# select all
self.view.run_command("select_all")
# reindent
self.view.run_command("reindent")
# clear the current selection
selfie.clear()
# put cursor back where we started
selfie.add(sublime.Region(here,here))
0 Likes
bschaaf
#3
Goto > Jump Back (alt+minus on Linux) goes back to the previous selection without undoing changes.
0 Likes
Lozminda
#5
Bit late but you could do ctrl+F2 to place a mark, do whatever you need to do, then F2 will take you back to that mark…This is ST3, don’t know about ST(4).
0 Likes