0

I am trying to create a command that calls the same function but with different arguments, like the following:

def g:MyFunction(a: string, b: bool) if b echo "foo" else echo "bar" endif enddef command! -nargs=+ -complete=command MyCommand0 silent call MyFunction(<f-args>, false) command! -nargs=+ -complete=command MyCommand1 silent call MyFunction(<f-args>, true) 

But I get no output. I think the problem resides in how I define the commands but I don't know how to fix it. I read here but it didn't really help.

1 Answer 1

1

You are prefixing your function call with silent which effectively suppresses output of your echo in the function.

Remove it and see different output.

vim9script def g:MyFunction(a: string, b: bool) if b echo "foo" else echo "bar" endif enddef command! -nargs=+ -complete=command MyCommand0 call MyFunction(<f-args>, false) command! -nargs=+ -complete=command MyCommand1 call MyFunction(<f-args>, true) 
1
  • Auch! My bad! Thanks! Commented Mar 11, 2023 at 11:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.