I have the following file (vimscript.vim):
function HelloWorld()
echo "Hello World"
endfunction
call HelloWorld()
When I open that file and I type the following:
:call HelloWorld()
I get an error:
E117: Unknown function: HelloWorld
You have to source the file first:
:source path/to/file/vimscript.vim
Alternatively, you can put the function in your vimrc instead, which is typically located at ~/.vimrc, so that it's defined every time you open Vim.
Or, you could use a combination of both, and put
source path/to/file/vimscript.vim
in your .vimrc.