Hi Marcin!

On Fr, 23 Mär 2012, Marcin Szamotulski wrote:

> Hello,
> 
> I'm trying to make a nice interface for :call system(...). For this I made the
> following function:
> 
> function! System(arg)
>     " Expand %, %:p (all modifiers are allowed except :s?pat?sub? and
>     " :gs?pat?sub?
>     return system(substitute(a:arg, '\(%\%(:[p8~.htre]\)*\)', 
> '\=expand(submatch(0))', 'g'))
> endfunction
> 
> The command 
> command! -nargs=1 System          :echo System("<args>")
> works as expected, but when I change it to:

I am surprised, this actually works and you didn't get E176.

> 
> command! -nargs=1 -complete=file System           :echo System("<args>")
> 
> and use it 
> :System ls /tmp
> I get the E172 error. Any ideas why?

You called the command with 2 arguments, but defined it to only accept 
one. That's wrong use -nargs=+ and possibly instead of "<args>" you can 
also use <q-args>

Mit freundlichen Grüßen
Christian
-- 
Wenn man viel hineinzustecken hat, so hat ein Tag hundert Taschen.
                -- Friedrich Nietzsche

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

Reply via email to