When doing <ESC>qq you can record a macro into the q register (still in command mode though). How can I make <ESC>qq go into insert mode right away (without having to type i)? map qq qqi will record and put me into insert mode, but I am unable to replay with @@ or @q. The docs say you cannot use the q command inside a macro, but it does not specify what happens in my case.

  • What problem are you trying to solve? Yes, a macro needs to begin and end in normal mode. Perhaps what you want is a mapping instead? If you share more details of the specific problem you want to solve, it might be easier to give you good suggestions. – filbranden Aug 17 '19 at 5:10
  • Simply dont want to type the extra character if there is a way to get around it (also, forget to go into insert mode sometimes). When mapping qq to qqi, it doest work the same as just typing qqi like normal – Dosisod Aug 17 '19 at 5:16
  • Yeah... But what exactly do you want to do with macros in insert mode? Can you give a specific example of what you'd use that for? – filbranden Aug 17 '19 at 5:25
  • 1
    inoremap and iabbrev didnt do the trick, but Id agree and say its probably best to just type it out. Say the cursor isnt positioned before I start the macro, then I would have to hit <ESC> and move it again anyways. Thanks for clearing that up. – Dosisod Aug 17 '19 at 5:46
  • 2
    Welcome to Vi and Vim! As filbranden mentions, editing to clarify your question would be helpful—I think we’re in a bit of an XY problem situation here. It sounds like you may have a use case for snippets or templates, but it’s really quite hard to tell what your true goal is (because we’re hung up on this macro/insert mode thing). Again, as @filbranden says, macros must start and end in normal mode (and normal mode rocks). Consider editing your question to describe your real goals – D. Ben Knoble Aug 17 '19 at 13:18

Your Answer

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

Browse other questions tagged or ask your own question.