How to run a vim script interactively from vim command line?

Open Vim and enter the following:

:source /path/to/vim/file/name.vim

If you are currently editing that file, you can also type:

:w <ENTER>
:source % <ENTER>

The percent sign (%) means the path to the currently opened file.


You could use the command feature of vim. In your unit_test_cpp.vim file you would add something like this:

command Utc call CreateUnitTests()

Now when you type :Utc it will call your function. The only limitation is that your command must start with an uppercase letter.


Script or function? If it is a function, try

:call FunctionName()