Repeat the nth last command in vim

No, the . command in vim does not have a history, nor is there any sort of repeat history for normal mode commands that I am aware of. For the fewest number of keystrokes, I'd recommend 4oHello<Esc>3jA, World<Esc>. If you've already done oHello<Esc>A, World<Esc>, you could follow that with uyy<Ctrl-r>3p.


There's this plugin called RepeatLast.vim which does what you wantbut with a cost: your vim is always in recording macro mode. You can install it with package manager you're using like any other vim packages or you can simply clone and drop it in ~/.vim/plugin if you're using vim or ~/.config/nvim/plguin if you're using neovim. To repeat second to last action you should type 2\. in normal mode and to repeat th to last action you should type <n>\. in normal mode.

http://www.vim.org/scripts/script.php?script_id=4381 https://github.com/vim-scripts/RepeatLast.vim

Tags:

Vim