When I try to “execute” my function using the “execute echo Myfunc()\” command, the cursor is moved to the top of the current buffer. Why?
:execute” command runs the normal mode command specified by the argument. In the case of the following command: :execute “echo Myfunc()” The call to “echo Myfunc()” will return 0. The “:execute” command will run the normal mode command “0”, which moves the cursor to the top of the file. To call a Vim function, you should use the “:call” command instead of the “:execute” command: :call Myfunc() For more information, read :help :call :help :execute :help :echo :help user-functions :help 41.5 :help 41.
Related Questions
- When I try to "execute" my function using the "execute echo Myfunc()\" command, the cursor is moved to the top of the current buffer. Why?
- SECTION 23 - AUTOCOMMANDS 23.1. How do I execute a command when I try to modify a read-only file?
- What happens when I try to execute the PRTDOC command on V5R1 of OS/400?