Vim double-indents python files
<p>I get the following behavior. Given this <code>settings.py</code> snippet, hitting 'o' from line 33</p>

<pre><code>31# Application definition
32 
33 INSTALLED_APPS = [
34     'rest_framework',
</code></pre>

<p>I get this</p>

<pre><code>31# Application definition
32 
33 INSTALLED_APPS = [
34         |&lt;-cursor is here, two indents, 8 spaces
35     'rest_framework',
</code></pre>

<p>What I really want would be one indent, or a total of 4 spaces, in line with the rest of the list. What gives? I'm using the following .vimrc which I mostly cribbed from <a href="https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/" rel="nofollow">here</a>.</p>

<pre><code>set nocompatible              " required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)

" Themes
Plugin 'altercation/vim-colors-solarized'
Plugin 'jnurmine/Zenburn'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

if has('gui_running')
  set background=dark
  colorscheme solarized
else
  colorscheme zenburn
endif

au BufNewFile,BufRead *.py set tabstop=4 shiftwidth=4 textwidth=79 expandtab autoindent fileformat=unix

set encoding=utf-8
set nu
let python_highlight_all=1
syntax on
set backspace=indent,eol,start
</code></pre>

<p>This happens because of default vim indentation plugin for Python. It inserts 2 <code>shiftwidth</code> on the first line below <code>[</code>.</p>

<p>You can see code which causes this behaviour here: <a href="https://github.com/vim/vim/blob/0b9e4d1224522791c0dbbd45742cbd688be823f3/runtime/indent/python.vim#L74" rel="nofollow">https://github.com/vim/vim/blob/0b9e4d1224522791c0dbbd45742cbd688be823f3/runtime/indent/python.vim#L74</a></p>

<p>I would recommend you to install <a href="https://github.com/hynek/vim-python-pep8-indent" rel="nofollow"><code>vim-python-pep8-indent</code></a> plugin which does indentation inside parenthesis exactly as you need.</p>

python vim