title: Vim:E523: Not allowed here
body: <p>I received this error when i tab in vim.</p>
  
  <blockquote>
    <p>Traceback (most recent call last):<br>
    File "&lt; string >", line 1, in &lt; module ><br>
    File "utils.py", line 15, in write<br>
    current_buffer.append('some text')<br>
    vim.error: Vim:E523: Not allowed here<br></p>
  </blockquote>
  
  <p><br>
  I have the current .vim file</p>
  
  <pre><code>if expand("%:e") == 'xml'                                                                                                                                                             
      inoremap &lt;expr&gt; &lt;tab&gt; WriteFile()                                                                                                                                                 
  endif                                                                                                                                                                                 
  function! WriteFile()                                                                                                                                                                 
      python3 utils.write()                                                                                                                                                             
  endfunction 
  </code></pre>
  
  <p>and this .py file</p>
  
  <pre class="lang-py prettyprint-override"><code>import vim
  
  def write():
      current_buffer = vim.current.buffer
      current_buffer.append('some text')
  </code></pre>