Note that there are some explanatory texts on larger screens.

plurals
  1. POMacVim Python Indentation Issue
    primarykey
    data
    text
    <p>For the past 6 hours, I have been trying to find the source of an annoying bug in my MacVim setup. For reasons detailed below, the first time I opened up a Python file, the indentation was set correctly from the file <code>$VIMRUNTIME/ftplugin/python.vim</code>, which for me was <code>/usr/local/Cellar/macvim/7.4-72/MacVim.app/Contents/Resources/vim/runtime/ftplugin</code>.</p> <p>However on every subsequent Python file load, the <code>shiftwidth</code> reverted to the global default of 2, which I have set in my <code>.vimrc</code>. In tracking down the issue, I finally came upon this code in the <code>$VIMRUNTIME/ftpluin/python.vim</code> file:</p> <pre><code>if exists('*&lt;SID&gt;Python_jump') | finish | endif fun! &lt;SID&gt;Python_jump(motion) range let cnt = v:count1 let save = @/ " save last search pattern mark ' while cnt &gt; 0 silent! exe a:motion let cnt = cnt - 1 endwhile call histdel('/', -1) let @/ = save " restore last search pattern endfun if has("gui_win32") &amp;&amp; !exists("b:browsefilter") let b:browsefilter = "Python Files (*.py)\t*.py\n" . \ "All Files (*.*)\t*.*\n" endif " As suggested by PEP8. setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 </code></pre> <p>On the first load, <code>&lt;SID&gt;Python_jump</code> isn't defined, so the PEP8 style indentation settings are applied. However, on every next load, the function is available and so the <code>shiftwidth</code> settings are never applied. If I comment out the <code>if exists('*&lt;SID&gt;Python_jump') | finish | endif</code> line, it works as expected and the indentation settings are set correctly on every file load.</p> <p>Now, what I'm wondering is if this is a genuine problem faced by others as well; in which case I should probably fix it and open up a pull request on the MacVim repo, or do I have something else wrong? I have tried disabling every plugin (I use Vundle, so I just commented out their <code>Bundle</code> lines in my <code>.vimrc</code>), but the result is the same.</p> <p><strong>Edit</strong> As pointed out by krystah, a <code>au FileType python set shiftwidth=4</code> also fixes the issue.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload