Skip to content
Automatic reloading of Vim scripts ((file-type) plug-ins, auto-load/syntax/indent scripts, color schemes)
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Automatic reloading of Vim scripts

The reload.vim plug-in automatically reloads various types of Vim scripts as they're being edited in Vim to give you instant feedback on the changes you make. For example while writing a Vim syntax script you can open a split window of the relevant file type and every time you :update your syntax script, reload.vim will refresh the syntax highlighting in the split window. Automatic reloading of Vim scripts is currently supported for the following types of scripts:

Note that vimrc scripts are not reloaded because that seems to cause more trouble than it's worth...


Out of the box the reload.vim plug-in is configured to automatically reload all Vim scripts that it knows how to. If you like it this way then you don't need to configure anything! However if you don't like the automatic reloading then you'll need the following:

The g:reload_on_write option

If you don't like automatic reloading because it slows Vim down or causes problems you can add the following line to your vimrc script:

let g:reload_on_write = 0

This disables automatic reloading which means you'll have to reload scripts using the command discussed below.

The :ReloadScript command

You can execute the :ReloadScript command to reload the Vim script you're editing. If you provide a script name as argument to the command then that script will be reloaded instead, e.g.:

:ReloadScript ~/.vim/plugin/reload.vim

If after executing this command you see Vim errors such as "Function already exists" (E122) or "Command already exists" (E174) then you'll need to change your Vim script(s) slightly to enable reloading, see below.

Things that prevent reloading

If you want your Vim plug-ins and/or other scripts to be automatically reloaded they'll have to be written a certain way, though you can consider the following points good practice for Vim script writing anyway:

Use a bang in command/function definitions!

Function and command definitions using Vim's :command and :function built-ins should include a bang (!) symbol, otherwise Vim will complain that the command or function already exists:

" Bad:
:command MyCmd call MyFun()
:function MyFun()

" Good:
:command! MyCmd call MyFun()
:function! MyFun()

Use automatic command groups

Automatic commands using Vim's :autocmd built-in should be defined inside of an automatic command group that's cleared so the automatic commands don't stack indefinitely when your :autocmd commands are executed several times:

" Bad example: If the following line were re-evaluated, the message would
" appear multiple times the next time the automatic command fires:
:autocmd TabEnter * echomsg "Entered tab page"

" Good example: The following three lines can be reloaded without the
" message appearing multiple times:
:augroup MyPlugin
:  autocmd! TabEnter * echomsg "Entered tab page"
:augroup END


The ReloadScript plug-in on also supports reloading of Vim scripts, but there are a few notable differences:

  • This plug-in focuses on automatic reloading (I'm lazy) while the other one requires manual reloading;

  • This plug-in doesn't clear inclusion guard variables while the other one does;

  • This plug-in will never :source a file that hasn't already been loaded by Vim -- it checks using Vim's :scriptnames command;

  • This plug-in can more or less reload itself ;-)


If you have questions, bug reports, suggestions, etc. the author can be contacted at The latest version is available at and


This software is licensed under the MIT license.
© 2010 Peter Odding <>.

Something went wrong with that request. Please try again.