aboutsummaryrefslogtreecommitdiff
path: root/plugin/detect_indent.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-30 19:21:03 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-30 19:21:03 +1200
commit4b364f096f9c5ad06daa99f5d302e0b07424f0bf (patch)
treea2dc101edc23e2a27cca1d6f6213201da954ca8d /plugin/detect_indent.vim
downloadvim-detect-indent-4b364f096f9c5ad06daa99f5d302e0b07424f0bf.tar.gz
vim-detect-indent-4b364f096f9c5ad06daa99f5d302e0b07424f0bf.zip
First version, spun out from dotfiles v9.10.0v0.1.0
Diffstat (limited to 'plugin/detect_indent.vim')
-rw-r--r--plugin/detect_indent.vim23
1 files changed, 23 insertions, 0 deletions
diff --git a/plugin/detect_indent.vim b/plugin/detect_indent.vim
new file mode 100644
index 0000000..e75324a
--- /dev/null
+++ b/plugin/detect_indent.vim
@@ -0,0 +1,23 @@
+"
+" detect_indent.vim: If 'expandtab' doesn't match the shape of the buffer's
+" indents, switch it over, including a guess at 'shiftwidth' if switching it
+" on.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('loaded_detect_indent') || &compatible || v:version < 700
+ finish
+endif
+let loaded_detect_indent = 1
+
+" Set up a user command in case the user wants to set this manually
+command! -bar DetectIndent
+ \ call detect_indent#()
+
+" Add hook for FileType event; this should load *after* filetype plugins
+augroup detect_indent
+ autocmd!
+ autocmd FileType *
+ \ DetectIndent
+augroup END