StarWing schrieb:
> hi everyone
> 
> i want to implment this function, use Vim script. it's just like <f-
> args> in :command (:h <f-args>)
> 
> i had wroten a c program:
> #include <stdio.h>
> #include <string.h>
> 
> void unescape(char *lhs, char *rhs, char token)
> {
>     for (;*rhs != '\0'; ++rhs)
>     {
>         if (*rhs == '\\')
>             *lhs++ = *++rhs;
>         else if (*rhs == token)
>             *lhs++ = '\0';
>         else
>             *lhs++ = *rhs;
>     }
>     if (lhs[-1] != '\0')
>         *lhs++ = '\0';
>     *lhs = '\0';
> }
> 
> int main(void)
> {
>     char a[20], *b = "a\\\\b\\ c\\\\ d\\e\\\\f\\ g", *pt;
>     unescape(a, b, ' ');
>     puts(b);puts("");
> 
>     for (pt = a; *pt != '\0'; pt += strlen(pt) + 1)
>         puts(pt);
> 
>     return 0;
> }
> 
> but i need to implement it with Vim-script. how can i did it?

Is it ok to add a dummy command?

com! -nargs=* Fargs let result = [<f-args>]

func! Unescape(str)
    exec "Fargs" a:str
    return result
endfunc

-- 
Andy


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to