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
vim
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
Best Answer
You have to
source
the file first: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
in your
.vimrc
.