I recorded this macro to register a in Neovim by first pressing qa:


--- Registers ---
"a   f1F1i-^[la0^[j

Then I pressed q and my cursor was left in normal mode at the position marked by | (so that m is highlighted) in the below JavaScript snippet (on line 4).

JavaScript snippet

  timeout = setTimeout(function() {
  }, 350);

Then I tried to apply the macro with @a but nothing happened. I tried the same in Vim and nothing happened. Though the macro will move the cursor to the 1 if I move it away before using it. Am I not understanding something about how Vim macros work?

2 Answers 2


Macros abort when they fail at some point. In your example, f1 fails since there is no 1 after the cursor. To solve it, you can set "a to, say, 0f1i-^[la0^[j.


I would use sdp's suggestion 0f1i-^[la0^[j in a case like this, but my original macro could "directly" be made to work by absorbing the errors by the method described in this answer:

:try|exe "norm! f1"|endtry|try|exe "norm! F1"|endtry^Mi-^[la0^[j

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.