With GNU readline 7.0 / bash 4.4.20(1) it appears to be impossible to insert nth argument of a previous command in vi mode.
According to the manual, setting a numeric argument (e.g. Alt-1) and repeatedly invoking Alt-. should keep inserting nth argument from preceding commands. For example, issuing echo arg1 arg2 echo argA argB and pressing Alt-1 Alt-. Alt-. inserts arg1 (first inserting argA, then replacing with arg1). However, the same sequence of operations fails in vi mode even when the keys are bound appropriately. In particular, pressing Alt-1 Alt-. Alt-. inserts argA arg2. Subsequent invocation of Alt-. replace arg2 with the 2nd argument of the preceding command, i.e. readline is now behaving as if the numeric argument were 2. This certainly seems like buggy/out-of-spec behavior, is there a known workaround? This is observed in bash 4.4.20(1) with ~/.inputrc containing the following: set editing-mode vi set keymap vi-insert "\e.":yank-last-arg set keymap vi-command "\e.":yank-last-arg
