9

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

1 Answer 1

7

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .