Friday, February 20, 2015

Re: defining a function and E488 Trailing characters

On Friday, February 20, 2015 at 10:48:52 AM UTC-5, Ben Fritz wrote:
> On Friday, February 20, 2015 at 9:35:16 AM UTC-6, FlashBurn wrote:
> > I'm trying to learn about vim scripting. I tried to define a new function on the command line with the following:
> >
> > :function Meow() | echom "Meow" | endfunction
> >
> > For some reason the following error show up:
> >
> > E488: Trailing characters
> >
> > What am I doing wrong?
> >
> > Any help is appreciated.
>
> From :help :bar you can see that :function is one of the Vim commands that cannot be separated by a | character to chain commands together.
>
> Unfortunately, unlike most Vim commands, this does not work:
>
> :execute "function Meow()" | echom "Meow" | endfunction
>
> You need to use this workaround for one-liner functions:
>
> exec "function Meow()\nechom \"Meow\"\nendfun"
>
> You can also just type the function one line at a time; Vim goes into some special mode when you run the command ":function Meow()" by itself, which is ended when you enter the ":endfunction" command.
>
> Note that the normal use of functions, is in a script file, where you use multiple lines.

Thanks Ben.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment