From 0b97036e5a5eb58e25392d920b374537aa89d523 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 29 Jan 2019 11:19:42 +0100 Subject: [PATCH] feedkeys(..., 'i') sends keys in the wrong order in Vim 7.0/1/2 The current implementation prefers feedkeys(..., 'i') and only falls back to :normal if Vim 7.4 does not have the 'i' flag and if Vim 7.3 supports :normal with count. For Vim 8.0 (and later), and also for versions between 7.0 and 7.3.99, feedkeys(..., 'i') is used. Due to the prepending action of the 'i' flag, keys must be submitted in reverse order; that's why s is submitted before r . cnt. Vim 7.0...7.3.99 ignore the 'i' flag, though, and append the keys, which are now in the wrong order (this only matters if a register or count is given). Add a separate conditional branch for Vim versions before 7.3.100 that uses feedkeys() in the correct order and omits the ignored 'i' flag. --- autoload/repeat.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/repeat.vim b/autoload/repeat.vim index ce2141b..df75fb5 100644 --- a/autoload/repeat.vim +++ b/autoload/repeat.vim @@ -92,6 +92,9 @@ function! repeat#run(count) let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) exe 'norm ' . r . cnt . s + elseif v:version <= 703 + call feedkeys(r . cnt, 'n') + call feedkeys(s, '') else call feedkeys(s, 'i') call feedkeys(r . cnt, 'ni')