How would I do something like:
:echo call MyFunction()
so that I can see the result of calling the function?
Calling A Function Vim has a :call command to call a function. The call command does not output the return value. Let's call it with echo . To clear any confusion, you have just used two different call commands: the :call command-line command and the call() function.
Try out echo by running the following command: :echo "Hello, world!" You should see Hello, world! appear at the bottom of the window.
l: local to a function. g: global. :help internal-variables. Follow this answer to receive notifications.
You can always execute Vimscript by running each command in command mode (the one you prefix with : ), or by executing the file with commands using a :source command. Historically, Vim scripts have a . vim extension. Here, :so is a short version of :source , and % refers to the currently open file.
Use something like this:
:echo Myfunction()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With