Vim indentation for specific file type extensions

Revision history
Tags: vim

I am very fond of 2 spaces for indentation in most of my files, but I want to follow the convention with using a width of 4 when coding in Python.

The easiest way I could find how was to add a line in ~/.vimrc

autocmd FileType python setlocal shiftwidth=4

In my own setup (which may not apply to you), I’ve set the global settings as such:

set shiftwidth=2
set softtabstop=2


If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.