ST3 only (currently).
RegReplace now allows you to do procedural evaluations on found text via plugins.
// Some defintion
"some_definition": {
"find": "some regex here",
"replace": "some optional replace here",
"greedy": true,
"case": true,
"plugin": "User.rr_modules.force_all_caps",
"args": {"some_plugin_rguments": "if_desired"}
},
A plugin with path “User/rr_modules/force_all_caps.py” would be specified in your defintion as “User.rr_modules.force_all_caps”.
Built-in RegReplace modules are simply referenced as “rr_modules.my_module” etc. (though there aren’t any provided at this time).
Plugins are very simple:
def run(text, **optional_keyword_arguments):
# Do some stuff to text
return text
That is it.
You can import RegReplace plugins into other RegReplace plugins if desired by.
[code]from RegReplace.rr_plugin import Plugin
def run(text, **optional_keyword_arguments):
module = Plugin.load(“User.rr_modules.myplugin”)
text = module.run(text)
return text[/code]
If I were creating a User module, I personally would include from a sub-folder in User that does not provide a “init.py”. This just basically means sublime won’t automatically import the plugin file.
I guess you could consider this feature in beta. So, real world feedback may cause some aspects to change in the future, but maybe not.