Doing . repeats the last change. Doing 2. repeats the last change two times.
But imagine I want to repeat the change before the last one. How do I do it in Vim?
Doing . repeats the last change. Doing 2. repeats the last change two times.
But imagine I want to repeat the change before the last one. How do I do it in Vim?
Based on Fredrick Phil's answer, here is an example:
Recording your macro
The following shows how to record a macro to delete everything in and including a quoted string and store in register d. The command to delete a string is da". So to store this command in macro register d we can simply do this:
qdda"q
Notice it starts and ends with a q. The second character is the register, in this case d for delete. But we could have given it any letter or number. The remaining characters da" is our command.
Using our macro
Now that our macro is recorded we can invoke it by using the @ symbol followed by the register:
@d
Repeating the last macro command
To use the most recently invoked macro command again:
@@
Unrelated info:
In this example, we used da" which stands for delete a quoted string. (If you instead wanted to delete everything inside the quoted string, but not the quotation marks themselves you can instead use di" instead.).
yes! you can do this in vim!
One of Vim's most useful features is its ability to record what you type for later playback. This is most useful for repeated jobs that cannot easily be done with .
To start recording
To stop recording
To playback your keystrokes/recording
References