MCPcopy Create free account
hub / github.com/chasingboy/Xtools / ReplaceKeyToValueCommand

Class ReplaceKeyToValueCommand

xtools.py:282–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280
281
282class ReplaceKeyToValueCommand(sublime_plugin.TextCommand):
283 def run(self, edit):
284 text = get_buffer_text(self.view)
285 mapstr = get_console_text(self.view).strip('\n').replace(' => ','=>').split('\n')
286 if len(mapstr) == 0:
287 sublime.message_dialog('[error] Please select input text and input mapping strings(eg: a=>b)')
288 return
289
290 for line in mapstr:
291 if '=>' in line:
292 key, value = line.split('=>')
293 if key == '': continue
294 text = text.replace(key,value)
295
296 new_view(self.view, edit, text)
297
298
299class ReplaceValueToKeyCommand(sublime_plugin.TextCommand):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected