aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/reload_vimrc_filetype.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/plugin/reload_vimrc_filetype.vim')
-rw-r--r--vim/plugin/reload_vimrc_filetype.vim23
1 files changed, 23 insertions, 0 deletions
diff --git a/vim/plugin/reload_vimrc_filetype.vim b/vim/plugin/reload_vimrc_filetype.vim
new file mode 100644
index 00000000..d4f853b8
--- /dev/null
+++ b/vim/plugin/reload_vimrc_filetype.vim
@@ -0,0 +1,23 @@
+"
+" reload_vimrc_filetype.vim: Add hook to reload active buffer's filetype when
+" vimrc reloaded, so that we don't end up indenting four spaces in an open
+" VimL file, etc. Requires Vim 7.1 or 7.0 with patch 187 (SourceCmd event.)
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('g:loaded_reload_vimrc_filetype') || &compatible
+ finish
+endif
+if !has('autocmd') || v:version < 700 || v:version == 700 && !has('patch187')
+ finish
+endif
+let g:loaded_reload_vimrc_filetype = 1
+
+" This SourceCmd intercepts :source for .vimrc
+augroup reload_vimrc_filetype
+ autocmd SourceCmd $MYVIMRC
+ \ source <afile>
+ \|doautocmd filetypedetect BufRead
+ \|echomsg 'Reloaded vimrc: '.expand('<afile>')
+augroup END