This happens to me sometimes, and I haven't been able to figure out why. Lets say I start recording in vim (press q) then I finish and use the macros a few times. Then I do something else, like continue editing the file. Then I want to use the macros again, but this time something else happens, for example, the cursor moves one word backwards.

This has happened to me a few times. For example, today I start a macros (q 2), then I use it (@ 2) a few times. Then I type some text and try to use the macros again (@ 2), but this time the cursor gets moved one word backwards when the macros was supposed to format some text into HTML.

Every time this happens to me I try to reproduce it. I create a dummy macros, then do the same thing again, but I've never been able to reproduce it at will. The macros just works when I try to reproduce this behavior.

I haven't closed or otherwise suspended vim in any of the times this has happened.

I know this question might be hard to respond with the information provided, but I hope this has happened to some of you before and you've been able to figure out why it happens. I'm pretty sure this is just something I don't know about vim.


Numbered registers are used internally by Vim for commands like y or d.

You shouldn't use them to record your macros as they are overwritten at each yank or delete.

Use registers a to z, which Vim doesn't touch, instead.

  • That sound pretty logical. I'm sure what is happening is exactly what you describe. Thanks mate. – Buzu Feb 13 '12 at 20:41
  • This is pretty interesting. It seems like the macros get pussed to the next number. And in fact, an old macros is now on @ 8, when I initially registered it on @ 2. How exactly does this work? – Buzu Feb 13 '12 at 20:51
  • Each time you y or d the content of the numbered registers is shifted by one: "0's content becomes "1's content and so on with the last thing you yanked always taking the first register, "0. So yeah, it's not really a good idea to save anything there. See :help registers for more. – romainl Feb 13 '12 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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