Skip to content
This repository was archived by the owner on Jun 24, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugin/snake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,10 @@ def wrapped():
fn = wrapped

call = register_fn(fn)
command("%s <silent> %s :%s %s<CR>" % (map_command, key, PYTHON_CMD, call))
if mode == INSERT_MODE:
command("%s %s <C-\\><C-O>:%s %s<CR>" % (map_command, key, PYTHON_CMD, call))
else:
command("%s <silent> %s :%s %s<CR>" % (map_command, key, PYTHON_CMD, call))

else:
command("%s %s %s" % (map_command, key, maybe_fn))
Expand Down
11 changes: 11 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,17 @@ def process(stuff):
self.assertEqual(output, "quick")
self.assertEqual(changed, "The really fast brown fox jumps over the lazy dog")

def test_insert_key_map(self):
script = r"""
@key_map("a", mode=INSERT_MODE)
def change_words_and_move():
replace_word('Test')
keys('1w')

keys("aaaa")
"""
changed, output = run_vim(script, self.sample_text)
self.assertEqual(changed, "Test Test Test Test jumps over the lazy dog")


class OptionsTests(VimTests):
Expand Down