You can do this:
import sublime
import sublime_plugin
class OpenAutoCompletionCommand(sublime_plugin.TextCommand):
def run(self, edit, **kargs):
# print( "kargs: ", str( kargs ) )
view = self.view
if kargs["keystroke"] == 'a':
view.run_command("insert", {"characters": "l"})
elif kargs["keystroke"] == 'l':
view.run_command("insert", {"characters": "a"})
else:
view.run_command("insert", {"characters": kargs["keystroke"]})
Which needs this keymap file Default.sublime-keymap
:
[
{ "keys": ["a"], "command": "open_auto_completion", "args": {"keystroke": "a" } },
{ "keys": ["b"], "command": "open_auto_completion", "args": {"keystroke": "b" } },
{ "keys": ["c"], "command": "open_auto_completion", "args": {"keystroke": "c" } },
{ "keys": ["d"], "command": "open_auto_completion", "args": {"keystroke": "d" } },
{ "keys": ["e"], "command": "open_auto_completion", "args": {"keystroke": "e" } },
{ "keys": ["f"], "command": "open_auto_completion", "args": {"keystroke": "f" } },
{ "keys": ["g"], "command": "open_auto_completion", "args": {"keystroke": "g" } },
{ "keys": ["h"], "command": "open_auto_completion", "args": {"keystroke": "h" } },
{ "keys": ["i"], "command": "open_auto_completion", "args": {"keystroke": "i" } },
{ "keys": ["j"], "command": "open_auto_completion", "args": {"keystroke": "j" } },
{ "keys": ["k"], "command": "open_auto_completion", "args": {"keystroke": "k" } },
{ "keys": ["l"], "command": "open_auto_completion", "args": {"keystroke": "l" } },
{ "keys": ["m"], "command": "open_auto_completion", "args": {"keystroke": "m" } },
{ "keys": ["n"], "command": "open_auto_completion", "args": {"keystroke": "n" } },
{ "keys": ["o"], "command": "open_auto_completion", "args": {"keystroke": "o" } },
{ "keys": ["p"], "command": "open_auto_completion", "args": {"keystroke": "p" } },
{ "keys": ["q"], "command": "open_auto_completion", "args": {"keystroke": "q" } },
{ "keys": ["r"], "command": "open_auto_completion", "args": {"keystroke": "r" } },
{ "keys": ["s"], "command": "open_auto_completion", "args": {"keystroke": "s" } },
{ "keys": ["t"], "command": "open_auto_completion", "args": {"keystroke": "t" } },
{ "keys": ["u"], "command": "open_auto_completion", "args": {"keystroke": "u" } },
{ "keys": ["v"], "command": "open_auto_completion", "args": {"keystroke": "v" } },
{ "keys": ["w"], "command": "open_auto_completion", "args": {"keystroke": "w" } },
{ "keys": ["x"], "command": "open_auto_completion", "args": {"keystroke": "x" } },
{ "keys": ["y"], "command": "open_auto_completion", "args": {"keystroke": "y" } },
{ "keys": ["z"], "command": "open_auto_completion", "args": {"keystroke": "z" } },
]