Searching the default key-bindings to find the equivalent of Ctrl-A and Delete:
- Code: Select all
some_view.run_command("select_all")
some_view.run_command("right_delete")
When working with the ST-API it is easy to forget that often the simplest way is just to run a command.
To do this with the API:
- Code: Select all
some_view.erase(edit, sublime.Region(0, some_view.size())
FYI The content of a view can be considered the region (0, view.size()). This does not correspond directly to the number of (single) character-positions as the Tab character, which might cover e.g. four-space, can be regarded as a single character. Internally, it is a little more detailed than this suggests, because ST is able to extract from a region the line (row) and column positions. It must, therefore, (I'm guessing!) maintain an internal map of how different regions correspond to different
areas of the view.
RegionSets are far less useful (than Regions) as we cannot arbitrarily create these. The most significant RegionSet is sel(), which we can clear and add-to, etc.. However, we can store Regions in a list which, effectively, can then behave like a RegionSet.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.