Sure, no problem.
Here’s the updated plugin code:
[code]import sublime, sublime_plugin
class WrapTextCommand(sublime_plugin.TextCommand):
def run(self, edit, tag=“tag”):
regions = ]
for region in self.view.sel():
text = self.view.substr(region)
self.view.replace(edit, region, “<%s>%s</%s>” % (tag, text, tag))
off = 1
regions.append(sublime.Region(region.begin()+off, region.begin()+off+len(tag)))
off += len(tag)+3
regions.append(sublime.Region(region.end()+off, region.end()+off+len(tag)))
self.view.sel().clear()
for region in regions:
self.view.sel().add(region)
[/code]
And then you can add keybindings such as this:
{ "keys": "alt+p"], "command": "wrap_text"},
{ "keys": "ctrl+b"], "command": "wrap_text", "args": {"tag": "b"}},
{ "keys": "alt+i"], "command": "wrap_text", "args": {"tag": "img"}},