title: Autoindent : smartindent and indentexpr
body: <p>When I'm editing a Python file, for example:</p>
  
  <pre class="lang-py prettyprint-override"><code>def my_func():
      print('Something')
      &lt;-- CURSOR IS HERE
  </code></pre>
  
  <p>and I want to add a comment by typing a <code>#</code>, the line is automatically reindenting to the very beginning of the line:</p>
  
  <pre class="lang-py prettyprint-override"><code>def my_func():
      print('Something')
  #&lt;-- CURSOR IS HERE
  </code></pre>
  
  <p>I found that it's an effect of the <code>smartindent</code> option, so to fix it, I just have to run <code>:set nosi</code> (or disable it in my .vimrc).</p>
  
  <p>But in Vim's help, in <code>:h 'smartindent'</code>, you can read this:</p>
  
  <blockquote>
    <p>When 'cindent' is on or 'indentexpr' is set, setting 'si' has no effect.</p>
  </blockquote>
  
  <p>But my <code>indentexpr</code> option is set to the following:</p>
  
  <pre><code>:set indentexpr?
  indentexpr=GetPythonIndent(v:lnum)
  </code></pre>
  
  <p>I certainly should avoid using <code>smartindent</code> option at all, since it looks to be an old feature, and is designed to work with C-style languages only;</p>
  
  <p>But I wonder why <code>smartindent</code> does have some effect when I'm editing python files, considering what is written in the help?</p>