In VIM using. (dot) as an operator?
In VIM, the -powerful- β’(dot command) command is used to repeat the last step .
But since it is actually defined as a non- operator command , it is not possible to combine it with movement, since only the operator must be used with movement. (See http://www.viemu.com/vi-vim-cheat-sheet.gif for updates)
Can you actually use the dot command (when possible) as an operator?
Here's a small example: I have multiple lines and I add to the first word. Then I can enter j β’to do the same with the next line. And if I wanted to do this for the first ten lines, I have to repeat it 8 more times ...
If I do 8 β’ j, it will repeat the modification 8 times on the same line and then go down one line.
If I do 8 j β’, it actually skips 8 lines and then does it once.
In fact this is obviously the expected (and correct) behavior, but is there a way to make it .behave like an operator?
Thank..
Edit: I found a way to achieve this behavior based on ephemient's answer .
In the end, just use β’in command mode with:norm
- On the first line, click Ctrl-Vto enter a visual block selection.
- Go to the last line ( 8 j).
The ppp currently $and Aare not needed, as it actually is registered "in" team β’. Indeed, the need β’is to use this last modification and avoid retyping it (especially useful if it was something more complex, for example ci ")
- Click :to enter command modeand then enter
norm .
β
This seems to work for me.
Note: when entering command mode the following text is already present :'<,'>
, but I typed the above after that like this:'<,'>norm .
source to share
Try the following:
- On the first line, click Ctrl-Vto enter a visual block selection.
- Go to the last line ( 8j).
- Click $to move the cursor to the end of (all) lines.
- Press A(capital A), enter to add a word, and then Escto exit the visual block insert mode.
- Now the word is added to all selected lines.
You can find other Vim wikia suggestions .
source to share
As this Superuser theme suggests, it is unfortunately not possible in vanilla Vim (easy way).
You can use the repmo.vim plugin if you want to use .
like this.
Otherwise, I would use macros @@
to repeat the last used macro too.
source to share