i have made a macro that reformat a word that example apple
to be .apple(apple)
and i have saved that macro to be remapped with the <leader>z
combination as follows
nnoremap <leader>z 0yiwI.<esc>a(<esc>hpA),<esc>j0
the problem is when i type a number followed by <leader>z
expecting the command to be repeated by the number i have given, it instead moves 10 lines downward i.e. it excutes the part only how do i fix that behaviour where i enter the number of repetitions of the command i want and it excutes correctly
Note: I have the leader key remapped to space
Asked
Active
Viewed 191 times
3

Ramy Osama
- 98
- 1
- 9
-
For what it's worth, those are *mappings* not "remappings". – romainl Mar 28 '21 at 16:00
-
Store your macro in a register, say register z, and execute it 10 times with `10@z`. – romainl Mar 28 '21 at 16:04
-
I use the macro everyday and i thought it would be a nice addition to have a way to store it as to not do it again everytime i use VIM – Ramy Osama Mar 29 '21 at 08:00
1 Answers
3
If you want to keep using that macro over and over again, the most effortless way is to assign it to a register in your vimrc
:
let @z = "0yiwI.\<esc>a(\<esc>hpA),\<esc>j0"
and use it like this:
@z
10@z

romainl
- 186,200
- 21
- 280
- 313