From b809746777df6709a249361f4dc070fe8db41879 Mon Sep 17 00:00:00 2001 From: lhark Date: Mon, 4 Apr 2016 21:14:15 +0000 Subject: [PATCH] Vim file indent type autodetection --- vimrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vimrc b/vimrc index 2c29d70..3d01aab 100644 --- a/vimrc +++ b/vimrc @@ -454,3 +454,12 @@ function! ShowModeInStatusLine() endif return g:showMode endfunction +"[Autodetect indent style of a file]" +function AutoDetectTabs() + if len(filter(getbufline(winbufnr(0), 1, "$"), 'v:val =~ "^\\t"')) > len(filter(getbufline(winbufnr(0), 1, "$"), 'v:val =~ "^ "')) + set noet ts=4 sw=4 + endif +endfunction +if has("autocmd") + autocmd BufReadPost * call AutoDetectTabs() +endif