Please advice how to use sublime not blender's texteditor

Dear blender community,

as mentioned in title, I would like to use sublime text instead of blender’s texteditor.

After some “google-work” I found this repo and blender-addon:

I did installation (like descriped), and it basically works!

Please have a look at this example (there is a different behaviour from using blender’s texteditor to sublime):

Executing the following loop from within blender’s texteditor works fine:

import os
import bpy

for image in os.listdir(fp):
image_name = os.path.basename(image)
x = bpy.context.selected_objects
x[0].name = image_name

Sending same code from sublime to blender (using the installed repo as mentioned above) returns an error:
AttributeError: ‘Context’ object has no attribute ‘selected_objects’

How to fix it?

Thank you, and best regards!

The error seems to indicate the script isn’t running from the live blender instance where context would have a value and is instead running in sublime where it’s valid syntax because bpy is imported, but doesn’t contain anything. That’s a crude interpretation.

There’s a similar plugin for vscode I’m somewhat familiar with. These tools are generally used to build addons and automatically reload them in the launched blender instance. So you can code in the editor of choice, but they’re meant for addons that register their operators and then used and tested in blender. Your script isn’t constructed as an addon.

Thank you very much, sirmaxim! I’ll attent to your advice.
I just did some scripting in maya before. There it was very easy by importing and reloading .py scripts using a button or menu item.
If I got it right, it’s quite similar in blender. You just have to unregister and re-register your addon if you did some changes onto your script and would like to test it.
best regards