Saturday, July 2, 2011

Re: setline vs call setline

On Jul 1, 1:38 pm, Taylor Hedberg <tmhedb...@gmail.com> wrote:
> Vim scripts are composed of ex commands. Functions are expressions, not
> ex commands, so they can't be used "bare" in a script; that is, they
> must be "wrapped" in a proper command.
>
> Not a valid Vimscript statement:
>
>     foo()
>
> Valid:
>
>     call foo()
>
> :call is just an ex command that essentially just invokes the given
> function and ignores its result. This is useful when you just care about
> the side effects of a function but not the value it returns (if any).
>
> Plenty of other commands can call functions as well, and all are valid
> as statements in a script. The only restriction is that you can't invoke
> a function by itself, without some kind of command that wraps it.
> Another simple example is :echo, which evaluates its argument (which may
> be a function) and prints the result.
>
> Hopefully that clears things up a little.

thanks for the help everyone. i think i got it. taylor, your
explanation did clear it up.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: