I record this macro:


It should open insert mode, write a, exit, replace with b, then exit insert mode again.

you can bind it to @w with:

:let @w='ia^[sb^['

For whatever reason instead of a line with b I get the following a^[sb^[

Is there something I can do to get the esc key working in my macros? I've tried using <Esc> instead of ^[ as well to no avail.

Thanks in advance!

1 Answer 1


It looks like your ^[ is not a literal <Esc>. More likely a ^ followed by a [ (two characters);

You are supposed to insert a literal escape character (a single character displayed as ^[). This is done with Ctrl+V followed by Esc.

  • is there any way i can force it to use the one character ^[ as an escape? I have confirmed that this is not the problem, the Ctrl+V followed by Esc outputs the ^[ in a lighter looking font, for sure that's the escape key, yet instead of escaping i'm getting è Commented Jan 19, 2016 at 3:48
  • I gave you the right answer to your question. Why, how and when you get that è is another matter. Please ask another question.
    – romainl
    Commented Jan 19, 2016 at 6:15
  • Note that you type Ctrl+v Esc in insert mode, not normal mode.
    – dgrogan
    Commented Apr 16, 2018 at 19:57

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.