Try and set the indent style to whatever is in the file being edited.
Vim script
Switch branches/tags
Nothing to show
Latest commit 89319b4 Feb 6, 2017 @conormcd committed on GitHub Merge pull request #3 from jhand2/master
Modified 2 space vs 4 space logic
Permalink
Failed to load latest commit information.
plugin change logic when there is a mix of 2 and 4 spaces Feb 6, 2017
README.md First version. Patches welcome. Apr 27, 2012

README.md

Match Indentation Style

Some people like tabs, some like spaces. Very few people like it when you edit their stuff and use a different method of indentation.

This plugin scans through a file when it's opened and attempts to guess which style of indentation is being used. It then overrides your preferences so that you match the style of the file.

Currently it only detects the three most common styles of indentation, tabs, 2 spaces and 4 spaces. Patches to make this plugin more general are welcomed.

Installation

Using Pathogen

cd ~/.vim
git clone git://github.com/conormcd/matchindent.vim bundle/matchindent.vim

Manual Install

git clone git://github.com/conormcd/matchindent.vim
cp -R matchindent.vim/plugin/* ~/.vim/plugin/