title: Vim: Recording a macro with an escape key press does not work correctly
body: <p>I have recorded a macro to the <code>o</code> register to indent and remove a space for a line, then move to the start of the next line.</p>
  
  <p>The original line:</p>
  
  <pre><code>a : 1,
  </code></pre>
  
  <p>Keystrokes used:</p>
  
  <pre><code>qii&lt;tab&gt;&lt;esc&gt;f&lt;space&gt;x+q
  </code></pre>
  
  <p>Result is exactly what I wanted:</p>
  
  <pre><code>    a: 1,
  </code></pre>
  
  <p>The following key strokes are recorded to the regiser: <code>i^I^[f x+</code></p>
  
  <p>Running the macro on the line (after undoing changes) results in this:</p>
  
  <pre><code>æ x+a : 1,
  </code></pre>
  
  <p>A few more tests reveal the following:</p>
  
  <pre><code>"i   i^I^[+
  "o   i^I^[f x+
  "p   i^I^[llx+
  </code></pre>
  
  <p>Register <code>i</code> works as expected.</p>
  
  <p>Register <code>p</code> fails similar to <code>o</code> with the result looking like this:</p>
  
  <pre><code>ìlx+a : 1,
  </code></pre>
  
  <p>Seems that an escape key press recorded as <code>^[</code> does not exit insert mode when executing the macro.  </p>
  
  <p>I am on osx sierra and using vim with the terminal app.</p>
  
  <p>Any ideas whats going on here and how to fix it?</p>