In VIM, the -powerful- • command (the dot command) is used to repeat the last action..
But since it is actually defined as a command not an operator, it is not possible to combine it with a motion since only operator are meant to be used with a motion. (Cf. http://www.viemu.com/vi-vim-cheat-sheet.gif for a refresher)
Is it possible to actually use the dot command (when possible) as an operator?
Here is a little use case: I have some lines, and I append to the first one a word. Then I can type j • to do the same to the next line.. And if I wanted to do this for the first ten lines I should repeat this 8 more times...
If I do 8 • j it will repeat 8 times the modification on the same line, then go down one line..
If I do 8 j • it will actually jump down 8 lines and then do it once.
In fact this is obviously the expected (and correct) behaviour, but is there a way to have the . behave like an operator?
Thank you..
Edit: I found a way to achieve that behaviour based on ephemient answer.
In summary just to use the • in the command mode with :norm
At this time, the $ and the Append is not really needed since it is actually registered 'inside' the • command. Indeed, the necessity of the • is actually to use that last modification and avoid to retype it (particularly useful if it was something more complicated like ci ")
norm .⏎This seems to work for me..
Remark, when entering in command mode the following text :'<,'> is already present, but I typed the above afterwards, like this :'<,'>norm .
Try this:
You can find other suggestions on the Vim wikia.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With