Sublime Forum

How to create Region object Sublime Text?

#1

How to create Region object Sublime Text?

On the API page https://www.sublimetext.com/docs/3/api_reference.html#sublime.Region I found, the Region object constructor is sublime.Region Class: Region(a, b), however I could not create it when doing this on the Sublime Text console:

view.sel().clear(); view.sel().add(Region(1,1))

The sublime.Selection Class says it requires a Region object so I am trying to pass one, but I cannot create one. Anyways when passing just one Integer the command above succeeds.

view.sel().clear(); view.sel().add(1)

But the documentation says nothing about it accepting integers, it talks about that Region's I cannot to create.

0 Likes

#2

I just fixed it, I prefixed the Region class’ name with sublime. and it is working:

view.sel().clear(); view.sel().add(sublime.Region(1,1))
0 Likes

#3

It’s just that you can access the class Region from the module sublime

import sublime
sublime.Region(0, 5)
import sublime as st
st.Region(0, 5)
from sublime import Region
Region(0, 5)
1 Like